#!/usr/bin/env python3 """Installed-image, injected-touch regression. Run only on the reserved board.""" import datetime, hashlib, json, os, pathlib, signal, socket, subprocess, sys, time sys.path.insert(0, '/run') import rollback_check as pixels os.environ.update(XDG_RUNTIME_DIR='/run/shell', WAYLAND_DISPLAY='wayland-1', SWAYSOCK='/run/shell/sway-ipc.sock') OUT=pathlib.Path('/run/final-shell-check'); OUT.mkdir(exist_ok=True) result={'provenance':'injected-touch on physical board; no real-finger claim', 'at_utc':datetime.datetime.now(datetime.timezone.utc).isoformat(), 'checks':{}} result['system']=os.path.realpath('/run/current-system') result['boot_id']=pathlib.Path('/proc/sys/kernel/random/boot_id').read_text().strip() def command(args): return subprocess.check_output(args, text=True, timeout=15) def wait(test,label,seconds=15): end=time.monotonic()+seconds while time.monotonic()1,'Video media time did not advance',45) state=json.loads(pathlib.Path('/run/shell/k230-video.pid').read_text()) result.setdefault('video_sessions',{})[action]=state tap(245,25);wait(lambda:bar()!=home_bar,'Windows controls did not appear');tap(x,25) wait(lambda:not pathlib.Path('/run/shell/k230-video.pid').exists(),'Video state persisted',12) assert not list(pathlib.Path('/run/shell').glob('k230-video-*.sock')) assert not video_present() for key in ('controller','child'): if isinstance(state.get(key),int):wait(lambda:not pathlib.Path('/proc/'+str(state[key])).exists(),'Video process persisted: '+key,12) if action=='home':wait(lambda:focused('k230-terminal'),'Home failed to focus Terminal') wait(lambda:bar()==home_bar,'Video recovery did not return to home bar') record('video_apps_launch_'+action+'_cleanup') for service in ('shell','seatd','k230-wifi'): assert command(['systemctl','is-active',service]).strip()=='active' apps();close_apps();record('post_video_apps_back_services') result['result']='pass' except Exception as error: result['result']='fail';result['error_type']=type(error).__name__;result['error']=str(error) raise finally: (OUT/'result.json').write_text(json.dumps(result,indent=2)+'\n')