. "$BST_LIB" # BST-TIMEOUT: 3600 # the boot's session (waited for up to 300 s, or # 1800 s when the boot chose GNOME), the # compositor start (bounded at 180 s), a GTK3 client # on Wayland and one through Xwayland (each mapped within # 180 s and bounded at 240 s), one failed weston start, # the stub runs, and a service start bounded at 240 s. # The desktop session at boot: brintos-session-start starts the Wayland # session (weston on the DRM backend, pixman, the desktop shell, Xwayland) and # falls back to the X session when the compositor does not come up, saying on # the console which session started and why. # # /etc/inittab ::once -> /usr/sbin/brintos-session-start (busybox init) # brintos-session.service -> /usr/sbin/brintos-session-start (systemd, graphical.target) # /.bashrc -> /etc/bashrc.d/brintos-session-start.sh, PID 1 only # brintos-session-start -> brintos-wayland-start (SESSION=wayland) # -> brintos-x11-start (x11, or fallback) # # WHAT RUNS HERE. Section 3 drives the choice with stub start programs. # Section 4 runs the real brintos-wayland-start with a weston that cannot load # its backend, and checks the fallback is taken with weston's reason. Section 5 # runs the real session on the DRM device -- or reads the one this boot # started -- and a GTK3 client on X11 through Xwayland, and on Wayland where # GTK3 has that backend, receives a key and a click written into the evdev # node, and checks weston started no on-screen keyboard. A client with the # desktop shell's environment then has the session bus start # gnome-terminal-server, and the bus and the client both carry a UTF-8 LANG. # That environment names the session's bus at $XDG_RUNTIME_DIR/bus, and GIO # keeps a file's metadata through it. # # The X session itself is not started here: a started session cannot be # stopped (brintos/linux#21), and the Wayland session needs the KMS device. # The fallback's X11 start program is a stub that records it ran; # 57-brintos-x11-config covers brintos-x11-start. # # NOTHING IS STOPPED BY SIGNAL (brintos/linux#21): the compositor, Xwayland and # a client still running at a bound keep running after the suite ends. S=wayland-session START=/usr/sbin/brintos-session-start WSTART=/usr/sbin/brintos-wayland-start CONF=/etc/default/brintos-session W=$(mktemp -d "${TMPDIR:-/tmp}/bst-wlsession.XXXXXX") mkdir -p "$W/xdg" "$W/home" chmod 700 "$W/xdg" # A client of the session bus activates xdg-document-portal, which mounts its # FUSE file system on $XDG_RUNTIME_DIR/doc; rm cannot remove a mounted tree. rm_w() { awk -v w="$W/" 'index($2, w) == 1 { print $2 }' /proc/mounts | sort -r | while IFS= read -r m; do fusermount3 -u -z "$m" 2>/dev/null || umount -l "$m" 2>/dev/null done rm -rf "$W" } if [ ! -x "$START" ]; then bst_skip $S/present "$START not installed on this image" rm_w exit 0 fi bst_ok $S/present wu() { read -r _wu _ < /proc/uptime; echo "${_wu%.*}"; } # =========================================================================== # 1. The shipped tree. # =========================================================================== check $S/exec-session-start test -x "$START" check $S/exec-wayland-start test -x "$WSTART" check $S/exec-x11-start test -x /usr/sbin/brintos-x11-start check $S/xorg-present test -x /usr/bin/Xorg check $S/weston-present test -x /usr/bin/weston check $S/xwayland-present test -x /usr/bin/Xwayland check $S/weston-ini test -s /etc/xdg/weston/weston.ini check $S/weston-ini-no-input-method awk '/^\[/ { s = $0 } s == "[input-method]" && $0 == "path=" { f = 1 } END { exit !f }' /etc/xdg/weston/weston.ini check $S/no-at-bridge grep -qx 'export NO_AT_BRIDGE=1' "$WSTART" check $S/gdk-backend-x11-first grep -qx 'export GDK_BACKEND=x11,wayland' "$WSTART" check $S/wayland-display-exported grep -qxF 'export WAYLAND_DISPLAY=$WESTON_SOCKET' "$WSTART" # wayland, or gnome where the image carries the GNOME session's start. dflt=$(. "$CONF"; echo "$SESSION") case $dflt in wayland|weston|x11|icewm) bst_ok $S/default-session ;; gnome) if [ -x /usr/sbin/brintos-gnome-session ]; then bst_ok $S/default-session else bst_notok $S/default-session "SESSION=gnome in $CONF, and /usr/sbin/brintos-gnome-session is absent"; fi ;; *) bst_notok $S/default-session "SESSION=$dflt in $CONF" ;; esac if bst_pid1_systemd; then # Under systemd brintos-session.service starts the session, from graphical.target. U=/usr/lib/systemd/system/brintos-session.service check_eq $S/unit-execstart "ExecStart=$START" "$(grep -x "ExecStart=$START" "$U" 2>/dev/null)" check $S/unit-enabled test -L /usr/lib/systemd/system/graphical.target.wants/brintos-session.service check_eq $S/default-target graphical.target "$(systemctl get-default 2>/dev/null)" check_eq $S/no-inittab "" "$(ls /etc/inittab 2>/dev/null)" # graphical.target wants display-manager.service: no unit may hold that alias, # or a display manager starts beside the session (gdm, xserver-nodm). check_eq $S/no-display-manager "" "$(readlink /etc/systemd/system/display-manager.service 2>/dev/null)" else check_eq $S/inittab-once-line 1 "$(grep -cx "::once:$START" /etc/inittab)" check_eq $S/inittab-no-x11-line 0 "$(grep -cx '::once:/usr/sbin/brintos-x11-start' /etc/inittab)" once=$(grep -n "^::once:$START\$" /etc/inittab | cut -d: -f1) resp=$(grep -n '^::respawn:' /etc/inittab | head -n 1 | cut -d: -f1) if [ -n "$once" ] && [ -n "$resp" ] && [ "$once" -lt "$resp" ]; then bst_ok $S/inittab-once-before-respawn else bst_notok $S/inittab-once-before-respawn "::once line ${once:-absent}, first ::respawn ${resp:-absent}" fi fi FRAG=/etc/bashrc.d/brintos-session-start.sh check $S/bashrc-names-start grep -q "$START" "$FRAG" check $S/bashrc-pid1-guard grep -q '"\$\$" = 1' "$FRAG" check $S/bashrc-x11-defers grep -q "brintos-session-start" /etc/bashrc.d/brintos-x11-start.sh # =========================================================================== # 2. The session this boot started, when PID 1 started one. # =========================================================================== # busybox init (::once), bash (/.bashrc, in the background) and systemd # (brintos-session.service) all start the session beside the console, so this case can run before the session has # written its log. It waits: 60 s for the start program to run, then the # compositor's own bound plus 60 s for its verdict. A boot that chose GNOME # adds the GNOME session's bound, and this suite takes either session: GNOME's # own suite judges which one came up. BOOT=/tmp/brintos-session.log BOOT_STAMP=/tmp/.brintos-session-started p1=$(cat /proc/1/comm 2>/dev/null) case $p1 in init|bash|systemd) wt=$(. "$CONF" 2>/dev/null; echo "${WAYLAND_TIMEOUT:-180}") bs=$(. "$CONF" 2>/dev/null; echo "$SESSION") for x in $(cat /proc/cmdline); do case $x in brintos.session=*) bs=${x#*=} ;; esac done want="brintos-session: started the Wayland session" if [ "$bs" = gnome ]; then wt=$(( wt + $(. "$CONF" 2>/dev/null; echo "${GNOME_TIMEOUT:-2400}") )) want="brintos-session: started the" fi t0=$(wu); el=0 until [ -s "$BOOT" ]; do lim=60 [ -e "$BOOT_STAMP" ] && lim=$(( wt + 60 )) [ "$el" -ge "$lim" ] && break sleep 1 el=$(( $(wu) - t0 )) done if [ -s "$BOOT" ]; then check_out $S/boot-line "$want" cat "$BOOT" elif [ -e "$BOOT_STAMP" ]; then bst_notok $S/boot-line "PID 1 is $p1: the session start ran, and $BOOT is still empty after ${el}s" else bst_notok $S/boot-line "PID 1 is $p1: no session start ran within ${el}s ($BOOT_STAMP is absent)" fi ;; *) bst_skip $S/boot-line "no session was started at boot: PID 1 is ${p1:-unknown}, not busybox init, bash or systemd" ;; esac # =========================================================================== # 3. The choice, with stub start programs. # =========================================================================== cat > "$W/wl-ok" <<'EOF' #!/bin/sh echo wayland >> "$BST_MARKS" exit 0 EOF cat > "$W/wl-fail" <<'EOF' #!/bin/sh echo wayland >> "$BST_MARKS" echo "first line" echo "the stub compositor refused" exit 1 EOF cat > "$W/x11" <<'EOF' #!/bin/sh echo x11 >> "$BST_MARKS" exit 0 EOF cat > "$W/dirs" <<'EOF' #!/bin/sh echo dirs >> "$BST_MARKS" exit 0 EOF chmod 0755 "$W/wl-ok" "$W/wl-fail" "$W/x11" "$W/dirs" BST_MARKS=$W/marks export BST_MARKS # choose : run the installed script on a private # stamp and state file. Sets out, rc and marks. choose() { rm -f "$W/stamp" "$W/state" "$BST_MARKS" printf 'SESSION=%s\nWAYLAND_START=%s\nX11_START=%s\nSTAMP=%s\nSTATE=%s\nCURRENT=%s\nUSER_DIRS_UPDATE=%s\n' \ "$1" "$2" "$W/x11" "$W/stamp" "$W/state" "$W/current" "$W/dirs" > "$W/conf" BRINTOS_SESSION_CONF=$W/conf bst_run 60 "$START" marks=$(cat "$BST_MARKS" 2>/dev/null | tr '\n' ' ') } # The kernel command line overrides every case below. if grep -q 'brintos.session=' /proc/cmdline; then for c in wayland-chosen fallback x11-chosen none-chosen once-per-boot state-file; do bst_skip "$S/$c" "brintos.session= is on the kernel command line" done else choose wayland "$W/wl-ok" check_eq $S/wayland-chosen \ "0 dirs wayland |brintos-session: started the Wayland session (weston; X11 clients through Xwayland): SESSION=wayland in $W/conf" \ "$rc $marks|$out" check_eq $S/state-file "$out" "$(cat "$W/state" 2>/dev/null)" BRINTOS_SESSION_CONF=$W/conf bst_run 60 "$START" check_eq $S/once-per-boot "0 " "$rc $out" choose wayland "$W/wl-fail" check_eq $S/fallback \ "0 dirs wayland x11 |brintos-session: starting the X11 session: the Wayland compositor did not start: the stub compositor refused" \ "$rc $marks|$out" choose x11 "$W/wl-ok" check_eq $S/x11-chosen \ "0 dirs x11 |brintos-session: starting the X11 session: SESSION=x11 in $W/conf" \ "$rc $marks|$out" choose none "$W/wl-ok" check_eq $S/none-chosen \ "0 |brintos-session: no session started: SESSION=none in $W/conf" \ "$rc $marks|$out" fi # =========================================================================== # 4. A compositor that does not start: the real brintos-wayland-start, weston # asked for a backend that does not exist. weston exits before it opens a # device, so this touches nothing a live session holds. The reason names # the backend weston was started on; without the GL transport it follows # the line that says so. # =========================================================================== if grep -q 'brintos.session=' /proc/cmdline; then bst_skip $S/fallback-real-weston "brintos.session= is on the kernel command line" else rm -f "$W/stamp" "$W/state" "$BST_MARKS" printf 'SESSION=wayland\nX11_START=%s\nSTAMP=%s\nSTATE=%s\nCURRENT=%s\nWESTON_SOCKET=bst-fail-%s\nWESTON_LOG=%s\nWESTON_ARGS=--backend=bst-no-such-backend.so\nWAYLAND_TIMEOUT=120\n' \ "$W/x11" "$W/stamp" "$W/state" "$W/current" "$$" "$W/fail.log" > "$W/conf" XDG_RUNTIME_DIR=$W/xdg HOME=$W/home BRINTOS_SESSION_CONF=$W/conf bst_run 180 "$START" marks=$(cat "$BST_MARKS" 2>/dev/null | tr '\n' ' ') case "$rc $marks|$out" in "0 x11 |brintos-session: starting the X11 session: the Wayland compositor did not start: "*"weston (drm) exited with status "*"; log: $W/fail.log") bst_ok $S/fallback-real-weston ;; *) bst_notok $S/fallback-real-weston "rc=$rc marks='$marks' $(_bst_1line "$out")" ;; esac fi # =========================================================================== # 4b. A compositor that never creates its socket: the real # brintos-wayland-start with a stub weston that starts a client and hangs. # When the wait times out, the script stops the stub and its client # before it moves on, so the next backend is not started beside them. # =========================================================================== if [ ! -e /dev/dri/card0 ]; then bst_skip $S/timed-out-weston-stopped "no /dev/dri/card0 on this boot" else mkdir -p "$W/stubbin" cat > "$W/stubbin/weston" <<'EOF2' #!/bin/sh sleep 1000 & echo "$$ $!" > "$BST_HANG_PIDS" while :; do sleep 1; done EOF2 chmod 0755 "$W/stubbin/weston" BST_HANG_PIDS=$W/hang.pids rm -f "$BST_HANG_PIDS" printf 'WESTON_BACKEND=drm\nWESTON_SOCKET=bst-hang-%s\nWESTON_LOG=%s\nWAYLAND_TIMEOUT=5\n' \ "$$" "$W/hang.log" > "$W/hang.conf" PATH=$W/stubbin:$PATH BST_HANG_PIDS=$BST_HANG_PIDS XDG_RUNTIME_DIR=$W/xdg HOME=$W/home \ BRINTOS_SESSION_CONF=$W/hang.conf bst_run 60 "$WSTART" left= for p in $(cat "$BST_HANG_PIDS" 2>/dev/null); do [ -d /proc/$p ] && left="$left $p" done case "$rc|$out|$(cat "$BST_HANG_PIDS" 2>/dev/null)|$left" in "1|no compositor socket after 5s (drm)"*"|"[0-9]*" "[0-9]*"|") bst_ok $S/timed-out-weston-stopped ;; *) bst_notok $S/timed-out-weston-stopped "rc=$rc still running:${left:- none} pids='$(cat "$BST_HANG_PIDS" 2>/dev/null)' $(_bst_1line "$out")" ;; esac for p in $left; do kill -KILL "$p" 2>/dev/null; done fi # =========================================================================== # 4c. A weston that cannot be executed (status 126) is started once more # before the script gives up on that backend. # =========================================================================== if [ ! -e /dev/dri/card0 ]; then bst_skip $S/exec-failure-retried "no /dev/dri/card0 on this boot" else mkdir -p "$W/stub126" cat > "$W/stub126/weston" <<'EOF2' #!/bin/sh echo x >> "$BST_EXEC_COUNT" exit 126 EOF2 chmod 0755 "$W/stub126/weston" BST_EXEC_COUNT=$W/exec.count rm -f "$BST_EXEC_COUNT" printf 'WESTON_BACKEND=drm\nWESTON_SOCKET=bst-126-%s\nWESTON_LOG=%s\nWAYLAND_TIMEOUT=30\n' \ "$$" "$W/126.log" > "$W/126.conf" PATH=$W/stub126:$PATH BST_EXEC_COUNT=$BST_EXEC_COUNT XDG_RUNTIME_DIR=$W/xdg HOME=$W/home \ BRINTOS_SESSION_CONF=$W/126.conf bst_run 90 "$WSTART" n=$(wc -l < "$BST_EXEC_COUNT" 2>/dev/null | tr -d ' ') case "$rc|${n:-0}|$out" in "1|2|weston (drm) exited with status 126:"*) bst_ok $S/exec-failure-retried ;; *) bst_notok $S/exec-failure-retried "rc=$rc starts=${n:-0} $(_bst_1line "$out")" ;; esac fi # =========================================================================== # 5. The live session on the DRM device, and a GTK3 client on Wayland and # through Xwayland receiving a key and a click. # =========================================================================== LIVE="session-up log-drm log-pixman log-desktop-shell weston-env-wayland-display x-listening \ gtk-wayland-backend gtk-wayland-maps gtk-wayland-pointer gtk-wayland-keyboard gtk-wayland-gl \ gtk-x11-backend gtk-x11-maps gtk-x11-pointer gtk-x11-keyboard \ session-lang-utf8 session-bus bus-lang-utf8 terminal-server-locale gio-metadata no-weston-keyboard" if [ ! -e /dev/dri/card0 ] || [ ! -e /dev/input/event0 ]; then for c in $LIVE; do bst_skip "$S/$c" "no /dev/dri/card0 or /dev/input/event0 on this boot"; done rm_w exit 0 fi # gnome-shell presents on the canvas; a second compositor is not started # beside it. if grep -q "started the GNOME session" "$BOOT" 2>/dev/null; then for c in $LIVE; do bst_skip "$S/$c" "the boot's session is GNOME's"; done rm_w exit 0 fi if grep -q "started the Wayland session" "$BOOT" 2>/dev/null; then # The boot's own session holds the KMS device; the clients use it. . "$CONF" for d in /run/user/0 /tmp/runtime-0; do [ -S "$d/$WESTON_SOCKET" ] && XDG_RUNTIME_DIR=$d && break done WS=$WESTON_SOCKET; WLOG=$WESTON_LOG [ -s "$WLOG" ] || WLOG=/tmp/${WESTON_LOG##*/} up=yes [ -S "$XDG_RUNTIME_DIR/$WS" ] || up=no why="the boot's session socket $WS is gone: $(_bst_1line "$(tail -n 3 "$WLOG" 2>/dev/null)")" else XDG_RUNTIME_DIR=$W/xdg WS=bst-session-$$; WLOG=$W/weston.log rm -f "$W/stamp" "$W/state" "$BST_MARKS" printf 'SESSION=wayland\nX11_START=%s\nSTAMP=%s\nSTATE=%s\nCURRENT=%s\nWESTON_SOCKET=%s\nWESTON_LOG=%s\nWAYLAND_TIMEOUT=180\n' \ "$W/x11" "$W/stamp" "$W/state" "$W/current" "$WS" "$WLOG" > "$W/conf" XDG_RUNTIME_DIR=$W/xdg HOME=$W/home BRINTOS_SESSION_CONF=$W/conf bst_run 240 "$START" case "$out" in "brintos-session: started the Wayland session"*) up=yes ;; *) up=no ;; esac why="rc=$rc $(_bst_1line "$out")" fi export XDG_RUNTIME_DIR if [ "$up" != yes ]; then for c in $LIVE; do bst_notok "$S/$c" "no Wayland session: $why"; done rm_w exit 0 fi bst_ok $S/session-up check_out $S/log-drm "drm-backend.so" cat "$WLOG" check_out $S/log-pixman "Using Pixman renderer" cat "$WLOG" check_out $S/log-desktop-shell "desktop-shell.so" cat "$WLOG" # weston runs with its socket's name in its environment, which everything it # starts inherits; the drm backend above was still the one it loaded. wd=none for d in /proc/[0-9]*; do case $(tr '\0' ' ' < "$d/cmdline" 2>/dev/null) in *weston\ *--socket="$WS"\ *) wd=$(tr '\0' '\n' < "$d/environ" 2>/dev/null | sed -n 's/^WAYLAND_DISPLAY=//p') break ;; esac done check_eq $S/weston-env-wayland-display "$WS" "${wd:-unset}" t0=$(wu); xd="" while [ $(( $(wu) - t0 )) -lt 60 ]; do xd=$(sed -n 's/.*xserver listening on display \(:[0-9]*\).*/\1/p' "$WLOG" 2>/dev/null | tail -n 1) [ -n "$xd" ] && break sleep 1 done if [ -n "$xd" ]; then bst_ok $S/x-listening else bst_notok $S/x-listening "no 'xserver listening' in $WLOG"; fi probe=$W/gtk-input-probe inj=$W/wl-input-probe staged=yes for p in gtk-input-probe wl-input-probe; do cp "$BST_DATA/$p" "$W/$p" 2>/dev/null && chmod +x "$W/$p" 2>/dev/null || staged=no done # gtk_client : start the probe fullscreen, write input once it # maps, and judge what reached it. gtk_client() { tag=$1; shift co=$W/gtk-$tag.out env "$@" NO_AT_BRIDGE=1 HOME="$W/home" "$probe" 240 >"$co" 2>&1 & t0=$(wu) while [ $(( $(wu) - t0 )) -lt 180 ]; do grep -q -E "^(MAPPED|FATAL|RESULT)" "$co" && break sleep 1 done sleep 2 grep -q "^MAPPED" "$co" && bst_bound 60 "$inj" inject /dev/input/event0 3 >"$W/inject-$tag.out" 2>&1 t0=$(wu) while [ $(( $(wu) - t0 )) -lt 70 ]; do grep -q "^RESULT" "$co" && break sleep 1 done cwhy="$(_bst_1line "$(grep -E '^(BACKEND|FOCUS|FATAL|RESULT)' "$co" | tail -n 3) $(tail -n 1 "$W/inject-$tag.out" 2>/dev/null)")" case $tag in wayland) want=GdkWaylandDisplay ;; x11) want=GdkX11Display ;; esac check_out "$S/gtk-$tag-backend" "BACKEND $want" cat "$co" if grep -q "^MAPPED" "$co"; then bst_ok "$S/gtk-$tag-maps" else bst_notok "$S/gtk-$tag-maps" "$cwhy"; fi if grep -q "^BUTTON button=1 state=pressed" "$co" && grep -q "^BUTTON button=1 state=released" "$co"; then bst_ok "$S/gtk-$tag-pointer" else bst_notok "$S/gtk-$tag-pointer" "no button 1 press and release reached the client: $cwhy" fi if grep -q "^KEY keyval=a state=pressed" "$co" && grep -q "^KEY keyval=a state=released" "$co"; then bst_ok "$S/gtk-$tag-keyboard" else bst_notok "$S/gtk-$tag-keyboard" "no key press and release reached the client: $cwhy" fi [ "$tag" = wayland ] || return 0 # GDK paints through GL where the GL transport is granted, and through # wl_shm otherwise, with GDK's own warning and no failure. gl="$(_bst_1line "$(grep -E '^GL |Unable to force GL' "$co")")" if [ -e /dev/hwjs-transport ]; then if grep -q "^GL ok es=1" "$co" && ! grep -q "Unable to force GL enabled" "$co"; then bst_ok "$S/gtk-wayland-gl" else bst_notok "$S/gtk-wayland-gl" "no GL paint context with /dev/hwjs-transport present: $gl" fi elif grep -q "^GL none:" "$co" && grep -q "Unable to force GL enabled" "$co" && grep -q "^MAPPED" "$co"; then bst_ok "$S/gtk-wayland-gl" else bst_notok "$S/gtk-wayland-gl" "no clean wl_shm fallback without /dev/hwjs-transport: $gl" fi } if [ "$staged" != yes ]; then for c in gtk-wayland-backend gtk-wayland-maps gtk-wayland-pointer gtk-wayland-keyboard gtk-wayland-gl \ gtk-x11-backend gtk-x11-maps gtk-x11-pointer gtk-x11-keyboard; do bst_notok "$S/$c" "cannot stage $BST_DATA/gtk-input-probe and $BST_DATA/wl-input-probe" done else if grep -q -a gdk_wayland_display_get_type /usr/lib/libgdk-3.so.0 2>/dev/null; then gtk_client wayland GDK_BACKEND=wayland WAYLAND_DISPLAY="$WS" GDK_GL=gles,always GTK_PROBE_GL=1 else for c in gtk-wayland-backend gtk-wayland-maps gtk-wayland-pointer gtk-wayland-keyboard gtk-wayland-gl; do bst_skip "$S/$c" "libgdk-3 is built without its Wayland backend: GTK3 clients run through Xwayland" done fi if [ -n "$xd" ]; then gtk_client x11 GDK_BACKEND=x11 DISPLAY="$xd" WAYLAND_DISPLAY= else for c in gtk-x11-backend gtk-x11-maps gtk-x11-pointer gtk-x11-keyboard; do bst_notok "$S/$c" "no X display from the session's Xwayland" done fi fi # The session's locale reaches what the session bus activates. A client # started with the desktop shell's environment, as the panel and its terminal # start one (less the connected socket weston hands the shell alone), finds # or starts the session bus through the X display, as GDBus does, and asks it # to start gnome-terminal-server, which exits with status 8 on a non-UTF-8 # codeset. The bus's own environment is what every activated service gets. utf8() { case $1 in *.UTF-8|*.utf8|*.UTF8|*.utf-8) return 0 ;; esac; return 1; } sp= t0=$(wu) while [ $(( $(wu) - t0 )) -lt 60 ]; do for d in /proc/[0-9]*; do case $(tr '\0' ' ' < "$d/cmdline" 2>/dev/null) in */weston-desktop-shell*) p=${d#/proc/} if [ -z "$sp" ] || [ "$p" -lt "$sp" ]; then sp=$p; fi ;; esac done [ -n "$sp" ] && break sleep 2 done if [ -z "$sp" ]; then for c in session-lang-utf8 session-bus bus-lang-utf8 terminal-server-locale gio-metadata; do bst_notok "$S/$c" "the Wayland session is up, but no weston-desktop-shell runs" done else B=$W/bus mkdir -p "$B" tr '\0' '\n' < "/proc/$sp/environ" | grep -v '^WAYLAND_SOCKET=' > "$B/shell.env" sl=$(sed -n 's/^LANG=//p' "$B/shell.env") if utf8 "$sl"; then bst_ok $S/session-lang-utf8 else bst_notok $S/session-lang-utf8 "the desktop shell's LANG is '${sl:-unset}'"; fi sa=$(sed -n 's/^DBUS_SESSION_BUS_ADDRESS=//p' "$B/shell.env") sx=$(sed -n 's/^XDG_RUNTIME_DIR=//p' "$B/shell.env") # GVfs takes no bus a client would autolaunch through X11. if [ -n "$sx" ] && [ "$sa" = "unix:path=$sx/bus" ] && [ -S "$sx/bus" ]; then bst_ok $S/session-bus else bst_notok $S/session-bus "the desktop shell's DBUS_SESSION_BUS_ADDRESS is '${sa:-unset}', not unix:path=${sx:-\$XDG_RUNTIME_DIR}/bus" fi cat > "$B/sh" < "$B/launch" 2>&1 echo probe > "$B/meta-probe" gio set "$B/meta-probe" metadata::brintos-probe yes > "$B/gio" 2>&1 gio info -a metadata::brintos-probe "$B/meta-probe" >> "$B/gio" 2>&1 gdbus call --session --timeout 150 --dest org.freedesktop.DBus --object-path /org/freedesktop/DBus \ --method org.freedesktop.DBus.StartServiceByName org.gnome.Terminal 0 > "$B/start" 2>&1 echo "rc=\$?" >> "$B/start" EOF chmod +x "$B/sh" bst_bound 240 env -i /bin/sh -c 'while IFS= read -r kv; do [ -n "$kv" ] && export "$kv"; done < "$1"; shift; exec "$@"' \ sh "$B/shell.env" "$B/sh" > "$B/run.out" 2>&1 bp=$(sed -n "s/^DBUS_SESSION_BUS_PID=\([0-9]*\).*/\1/p" "$B/launch" 2>/dev/null) if [ -z "$bp" ] && [ -n "$sa" ]; then for d in /proc/[0-9]*; do case $(tr '\0' ' ' < "$d/cmdline" 2>/dev/null) in *dbus-daemon*--address="$sa"*) bp=${d#/proc/}; break ;; esac done fi if [ -n "$bp" ] && [ -r "/proc/$bp/environ" ]; then bl=$(tr '\0' '\n' < "/proc/$bp/environ" | sed -n 's/^LANG=//p') if utf8 "$bl"; then bst_ok $S/bus-lang-utf8 else bst_notok $S/bus-lang-utf8 "the session bus (pid $bp) has LANG '${bl:-unset}'"; fi else bst_notok $S/bus-lang-utf8 "no session bus found: $(_bst_1line "$(cat "$B/launch" "$B/run.out" 2>/dev/null | tail -n 3)")" fi bw="$(_bst_1line "$(tail -n 3 "$B/start" 2>/dev/null)")" if [ ! -s "$B/start" ]; then bst_notok $S/terminal-server-locale "the client did not run: $(_bst_1line "$(tail -n 3 "$B/run.out")")" elif grep -q 'exited with status 8\|Non UTF-8 locale' "$B/start"; then bst_notok $S/terminal-server-locale "gnome-terminal-server refused the bus's locale: $bw" elif grep -q '^rc=0$' "$B/start"; then bst_ok $S/terminal-server-locale else bst_notok $S/terminal-server-locale "StartServiceByName failed past the locale check: $bw" fi if grep -q 'metadata::brintos-probe: yes' "$B/gio" 2>/dev/null; then bst_ok $S/gio-metadata else bst_notok $S/gio-metadata "$(_bst_1line "$(grep -v -e CRITICAL -e '^[[:space:]]*$' "$B/gio" 2>/dev/null | head -n 3)")" fi fi # The empty [input-method] path in weston.ini: weston starts no on-screen # keyboard. Read last, after the session has run its clients, and in weston's # log, which names every client it launches. # The bracket keeps grep's own command line from matching. osk=$(grep -l -a '/weston-keyboar[d]' /proc/[0-9]*/cmdline 2>/dev/null | sed 's|^/proc/\([0-9]*\)/cmdline$| \1|' | tr -d '\n') if [ -z "$osk" ] && ! grep -q "launching '.*weston-keyboard'" "$WLOG" 2>/dev/null; then bst_ok $S/no-weston-keyboard else bst_notok $S/no-weston-keyboard "weston-keyboard pid(s):${osk:- none}; $WLOG: $(_bst_1line "$(grep weston-keyboard "$WLOG" 2>/dev/null | tail -n 1)")" fi rm_w