vinix-ports / tests / userland / desktop.sh
49 lines · 49 sloc · 1.52 KB · b41bb3151b4f73b05fc31159672968d19efd81b5
Raw
1#!/bin/sh
2set -eu
3arch=$(/bin/busybox uname -m)
4case "$arch" in
5 aarch64) exec >/dev/console 2>&1 ;;
6 x86_64) exec >/dev/com1 2>&1 ;;
7 *) exit 1 ;;
8esac
9finish() {
10 status=$?
11 if [ "$status" -ne 0 ]; then echo "VPAC desktop fixture failed"; fi
12 /sbin/poweroff -f
13}
14trap finish EXIT
15find_command() {
16 for proc in /proc/[0-9]*; do
17 [ -r "$proc/cmdline" ] || continue
18 command=$(tr '\000' ' ' <"$proc/cmdline" 2>/dev/null) || continue
19 if [ "$command" = "$1 " ]; then echo "${proc##*/}"; return 0; fi
20 done
21 return 1
22}
23echo 'Checking the first-boot Vinix desktop'
24/bin/busybox sha256sum -c /desktop-programs.sha256
25case "$arch" in
26 aarch64) test "$(readlink /proc/1/exe)" = /sbin/init ;;
27 x86_64) tr '\000' '\n' </proc/1/cmdline | grep -Fx /sbin/init ;;
28esac
29watchdog=
30watchdog_program=/usr/libexec/vinix-desktop-watchdog
31for attempt in $(seq 1 60); do
32 if [ -x "$watchdog_program" ] && [ -z "$watchdog" ]; then
33 watchdog=$(find_command "$watchdog_program") || true
34 fi
35 if session=$(find_command '/usr/sbin/vinix-session graphical --desktop /usr/bin/vinix-desktop') &&
36 registration=$(find_command '/usr/bin/vinix-desktop --register-only') &&
37 /framebuffer-check; then
38 if [ -x "$watchdog_program" ]; then
39 test -n "$watchdog"
40 echo "desktop watchdog PID $watchdog"
41 fi
42 echo "graphical session PID $session, registration PID $registration"
43 echo 'VPAC FIXTURE GUEST PASS'
44 exit 0
45 fi
46 sleep 1
47done
48ps
49exit 1
50