diff --git a/docs/screenshots/input-devices.png b/docs/screenshots/input-devices.png new file mode 100644 index 0000000..0716944 Binary files /dev/null and b/docs/screenshots/input-devices.png differ diff --git a/docs/screenshots/output-devices.png b/docs/screenshots/output-devices.png new file mode 100644 index 0000000..f1cab8f Binary files /dev/null and b/docs/screenshots/output-devices.png differ diff --git a/docs/screenshots/playback.png b/docs/screenshots/playback.png new file mode 100644 index 0000000..4af12e2 Binary files /dev/null and b/docs/screenshots/playback.png differ diff --git a/docs/screenshots/recording.png b/docs/screenshots/recording.png new file mode 100644 index 0000000..b264c06 Binary files /dev/null and b/docs/screenshots/recording.png differ diff --git a/tools/smoke-test.sh b/tools/smoke-test.sh new file mode 100755 index 0000000..504bfb8 --- /dev/null +++ b/tools/smoke-test.sh @@ -0,0 +1,92 @@ +#!/bin/sh +# Headless smoke test: start a private PipeWire + WirePlumber (null sink, +# null source, one playback stream), then run moonmix-probe against it and, +# if a display backend is available, render GUI screenshots. +# +# Only this *test harness* uses pw-cat (to create a playing stream); moonmix +# itself talks to PipeWire through libwireplumber. +# +# tools/smoke-test.sh [screenshot-prefix] +set -eu +ROOT=$(cd "$(dirname "$0")/.." && pwd) +BUILD="$ROOT/_build/native/debug/build/cmd" +PROBE="$BUILD/moonmix-probe/moonmix-probe.exe" +GUI="$BUILD/moonmix/moonmix.exe" +SHOTS="${1:-}" + +export XDG_RUNTIME_DIR="$(mktemp -d)" +export PIPEWIRE_RUNTIME_DIR="$XDG_RUNTIME_DIR" +export XDG_CONFIG_HOME="$XDG_RUNTIME_DIR/config" +export XDG_STATE_HOME="$XDG_RUNTIME_DIR/state" +mkdir -p "$XDG_CONFIG_HOME/pipewire/pipewire.conf.d" "$XDG_STATE_HOME" +cat > "$XDG_CONFIG_HOME/pipewire/pipewire.conf.d/moonmix-test.conf" <<'CONF' +context.objects = [ + { factory = adapter + args = { factory.name = support.null-audio-sink + node.name = "test_speakers" node.description = "Test Speakers" + media.class = "Audio/Sink" audio.position = [ FL FR ] + monitor.channel-volumes = true object.linger = true } } + { factory = adapter + args = { factory.name = support.null-audio-sink + node.name = "test_headphones" node.description = "Test Headphones" + media.class = "Audio/Sink" audio.position = [ FL FR ] + object.linger = true } } + { factory = adapter + args = { factory.name = support.null-audio-sink + node.name = "test_mic" node.description = "Test Microphone" + media.class = "Audio/Source/Virtual" audio.position = [ MONO ] + object.linger = true } } +] +CONF + +# Ubuntu's WirePlumber asks snapd before granting clients access; there is +# no snapd in a sandbox/CI container, so turn that off for the test session. +mkdir -p "$XDG_CONFIG_HOME/wireplumber/wireplumber.conf.d" +cat > "$XDG_CONFIG_HOME/wireplumber/wireplumber.conf.d/moonmix-test.conf" <<'CONF' +wireplumber.profiles = { + main = { + support.snapd-permission-prompting = disabled + script.client.access-snap = disabled + } +} +CONF + +PIDS="" +cleanup() { for p in $PIDS; do kill "$p" 2>/dev/null || true; done; [ -n "${KEEP:-}" ] || rm -rf "$XDG_RUNTIME_DIR"; } +trap cleanup EXIT INT TERM + +pipewire >"$XDG_RUNTIME_DIR/pipewire.log" 2>&1 & PIDS="$PIDS $!" +sleep 1 +wireplumber >"$XDG_RUNTIME_DIR/wireplumber.log" 2>&1 & PIDS="$PIDS $!" +sleep 2 +pw-cat --playback --raw --rate 48000 --channels 2 --format s16 \ + -P '{ application.name = "Test Player" media.name = "Smoke test tone" }' \ + /dev/zero >/dev/null 2>&1 & PIDS="$PIDS $!" +pw-cat --record --raw --rate 48000 --channels 1 --format s16 \ + -P '{ application.name = "Test Recorder" media.name = "Mic capture" }' \ + /dev/null >/dev/null 2>&1 & PIDS="$PIDS $!" +sleep 2 + +fail=0 +step() { echo "### $*"; "$PROBE" "$@" || fail=1; } +step +[ -z "${DEBUG:-}" ] || { pw-dump > "$XDG_RUNTIME_DIR/dump.json"; echo "dump in $XDG_RUNTIME_DIR"; } +step volume test_headphones 50 +step mute test_mic 1 +step default test_headphones +# Move the playback stream (found by name lookup in the probe's output). +STREAM=$("$PROBE" | awk -F: '/Test Player/ {gsub(/ /,"",$1); print $1; exit}') +step move "$STREAM" test_speakers + +if [ -n "$SHOTS" ] && [ -x "$GUI" ]; then + echo "### GUI screenshots -> $SHOTS-.png" + if command -v gtk4-broadwayd >/dev/null; then + gtk4-broadwayd :5 >/dev/null 2>&1 & PIDS="$PIDS $!" + sleep 1 + GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 MOONMIX_SCREENSHOT="$SHOTS" \ + timeout 30 "$GUI" || fail=1 + else + echo "gtk4-broadwayd not found; skipping GUI" + fi +fi +exit $fail