Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions tests/idle-policy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,33 @@ bin="$tmp/bin"
conf="$tmp/hypridle.conf"
mkdir -p "$bin" "$tmp/proc"

# fake_daemon <path>: a process that stays alive under its own name (comm is
# the script's basename). Not a renamed copy of sleep: on uutils coreutils
# sleep is a multicall binary that dispatches on argv[0] and exits at once
# under any other name.
fake_daemon() {
cat >"$1" <<'EOF'
#!/bin/sh
sleep "${1:-60}" &
child=$!
trap 'kill "$child" 2>/dev/null; exit 0' TERM INT HUP
wait "$child"
EOF
chmod +x "$1"
}

# wait_fake_ready <pid>: the fake has read its script and forked its sleeper,
# so its file may be replaced and its comm is already its own name.
wait_fake_ready() {
local _
for _ in {1..300}; do
[[ -n $(pgrep -P "$1" 2>/dev/null) ]] && return 0
sleep 0.01
done
printf 'fake daemon %s did not start\n' "$1" >&2
return 1
}

cat >"$bin/ryoku-power" <<'EOF'
#!/usr/bin/env bash
printf '%s\n' "$RYOKU_IDLE_TEST_POLICY"
Expand Down Expand Up @@ -285,7 +312,7 @@ touch "$tmp/fail-on"
export RYOKU_IDLE_WM_FAIL_ALWAYS="$tmp/fail-on"
"$helper" output-on &
wake_pid=$!
for _ in {1..50}; do
for _ in {1..200}; do
[[ -r $RYOKU_IDLE_WM_COUNT ]] && break
sleep 0.01
done
Expand Down Expand Up @@ -316,9 +343,10 @@ fi

# `apply` is an update safety gate: a running daemon with the old generated
# hooks must actually be gone before it reports success.
cp /usr/bin/sleep "$bin/hypridle"
fake_daemon "$bin/hypridle"
"$bin/hypridle" 60 &
idle_pid=$!
wait_fake_ready "$idle_pid"
ln -s "/proc/$idle_pid" "$tmp/proc/$idle_pid"
export RYOKU_IDLE_TEST_POLICY='{"enabled":false,"onDesktops":false}'
"$helper" apply
Expand All @@ -335,9 +363,10 @@ idle_pid=""
rm -f "$sway_bin/hypridle"
ln -s "$(command -v setsid)" "$sway_bin/setsid"
ln -s "$(command -v sleep)" "$sway_bin/sleep"
cp /usr/bin/sleep "$sway_bin/swayidle"
fake_daemon "$sway_bin/swayidle"
PATH="$sway_bin" "$sway_bin/swayidle" 60 &
idle_pid=$!
wait_fake_ready "$idle_pid"
ln -s "/proc/$idle_pid" "$tmp/proc/$idle_pid"
rm -f "$sway_bin/swayidle"
cat >"$sway_bin/swayidle" <<'EOF'
Expand All @@ -357,7 +386,7 @@ fi
wait "$idle_pid" 2>/dev/null || true
rm -f "$tmp/proc/$idle_pid"
idle_pid=""
for _ in {1..50}; do
for _ in {1..200}; do
[[ -r $RYOKU_IDLE_SWAY_PID ]] && break
sleep 0.01
done
Expand Down
5 changes: 3 additions & 2 deletions tests/void-installer-plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ packages=${package_command#*DRYRUN: sudo -n xbps-install -Sy }
for package in $packages; do
printf '%s\n' "$package" >> "$installed"
case $package in
# the Ryoku apps are installer choices, on by default, outside the desktop lane
ryoku-keyring|ryoku-desktop|ryoku-desktop-niri|ryotunes|ryomanager) ;;
# the Ryoku apps and the launcher radio are installer choices, on by
# default, outside the desktop lane
ryoku-keyring|ryoku-desktop|ryoku-desktop-niri|ryotunes|ryomanager|mpv|mpv-mpris) ;;
*) grep -Fxq "$package" "$resolved" ||
fail "XBPS package transaction contains '$package', which the resolver did not return" ;;
esac
Expand Down
Loading