mirror of
https://github.com/saphid/frame-control.git
synced 2026-10-06 01:00:18 +02:00
tests/fakeframe: a container that stands in for the Frame (Arch Linux, or Arch Linux ARM on arm64) with sshd, rsync, Valve's steamos-devkit-service and hooks (vendored unmodified), a fake Steam client for the devkit pipe and the DevTools port (the app's JavaScript runs in Node against stand-in SteamClient/appStore objects), stubs for steam, wpctl, flatpak, podman, Lepton and friends, battery and thermal files under /sys, and fault switches (fakeframe-ctl): pairing mode, approve/deny/timeout, Steam not running, headset asleep, sshd off, disk full, runtimes missing. A second container is the computer running Frame Control. tests/e2e: 29 tests driving the real ui/server.py, frame_connect.py and frame_titles.py against it; skipped unless FRAME_E2E=1. scripts/e2e.sh builds, runs and tears down; CI runs it on ubuntu-24.04-arm. tests/smoke + scripts/frame-smoke.sh: the core cases against a real Frame, recorded with its BUILD_ID, cleaning up after itself; --pair to pair a throwaway key. docs/testing.md describes the layers. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
72 lines
2.5 KiB
Python
Executable File
72 lines
2.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
import os
|
|
import logging
|
|
import tempfile
|
|
from urllib.parse import quote_plus as urllib_quote_plus
|
|
import subprocess
|
|
import json
|
|
|
|
ENABLE_SSHD = '/usr/bin/steamos-polkit-helpers/steamos-enable-sshd'
|
|
|
|
logger = logging.getLogger(os.path.realpath(__file__))
|
|
|
|
import devkit_utils
|
|
|
|
if __name__ == '__main__':
|
|
logger.setLevel(logging.INFO)
|
|
ch = logging.StreamHandler()
|
|
ch.setLevel(logging.INFO)
|
|
ch.setFormatter(logging.Formatter('%(name)s:%(message)s'))
|
|
logger.addHandler(ch)
|
|
|
|
request = open(sys.argv[1], 'rt').read()
|
|
requestIP = 'Unknown'
|
|
try:
|
|
requestIP = sys.argv[2]
|
|
except NameError:
|
|
logger.warning('request IP not given as argument to hook')
|
|
pass
|
|
|
|
key_identifier = request.split(' ')[2]
|
|
request = f'Development host at IP {requestIP} key: {key_identifier!r}'
|
|
|
|
ret = {}
|
|
|
|
try:
|
|
devkit_utils.validate_steam_client()
|
|
except devkit_utils.SteamClientNotRunningException as e:
|
|
msg = 'Steam is not running'
|
|
logger.warning(msg)
|
|
ret['error'] = msg
|
|
else:
|
|
with tempfile.TemporaryDirectory(prefix='approve-ssh-key') as tempdir:
|
|
logger.info('Sending pairing request to Steam')
|
|
response = os.path.join(tempdir, 'response')
|
|
cmd = 'approve-ssh-key?response={}&request={}'.format(
|
|
urllib_quote_plus(response),
|
|
urllib_quote_plus(request),
|
|
)
|
|
devkit_utils.execute_steam_client_command(cmd)
|
|
try:
|
|
with devkit_utils.wait_on_file_response(response, timeout=30) as f:
|
|
logger.debug('Got response from Steam client')
|
|
# Make sure sshd is enabled to support development features
|
|
if os.path.exists(ENABLE_SSHD):
|
|
subprocess.check_call(ENABLE_SSHD)
|
|
else:
|
|
subprocess.check_call('sudo systemctl enable --now sshd', shell=True)
|
|
except devkit_utils.SteamResponse_Timeout:
|
|
ret['error'] = 'timeout - Steam did not respond to the pairing request'
|
|
except devkit_utils.SteamResponse_Error as e:
|
|
ret['error'] = e.error_response
|
|
|
|
# json dictionary response gets written to stdout
|
|
# NOTE: the devkit service unfortunately smashes stdout/stderr all together in a text response, but we can still work with that
|
|
sys.stdout.flush()
|
|
sys.stderr.flush()
|
|
print(json.dumps(ret))
|
|
retcode = 1 if 'error' in ret else 0
|
|
sys.exit(retcode)
|