cat / goq
clone

turns a linux box into a private steam streaming appliance: plug in, tap your key, play from another computer

main
goq / scripts / tests / bazzite-inventory-gstreamer.sh
bazzite-inventory-gstreamer.sh 3.2K executable
1#!/usr/bin/env bash23set -euo pipefail45script_dir="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"6temp_parent="${TMPDIR:-/tmp}"7temp_parent="${temp_parent%/}"8temp_root="$(mktemp -d "$temp_parent/sigil-gstreamer-inventory.XXXXXX")"910cleanup() {11 local status=$?12 trap - EXIT INT TERM HUP13 case "$temp_root" in14 "$temp_parent"/sigil-gstreamer-inventory.??????) rm -rf -- "$temp_root" ;;15 esac16 exit "$status"17}18trap cleanup EXIT INT TERM HUP1920export SIGIL_INVENTORY_SOURCE_ONLY=121# shellcheck source=../bazzite-inventory.sh22# shellcheck disable=SC109123source "$script_dir/../bazzite-inventory.sh"2425fail() {26 printf 'FAIL: %s\n' "$1" >&227 exit 128}2930install -d -m 0700 "$temp_root/bin"31cat >"$temp_root/bin/gst-inspect-1.0" <<'EOF'32#!/usr/bin/env bash33set -euo pipefail34case "${1:-}" in35 appsink)36 [[ "${SIGIL_TEST_APPSINK:-present}" == present ]]37 ;;38 pipewiresrc)39 printf 'Factory Details: pipewiresrc fixture\n'40 ;;41 queue|videoconvert|videoscale|videorate|h264parse|fdsink|vah264enc)42 exit 043 ;;44 '')45 printf 'va: vah264enc: VA-API H.264 Encoder\n'46 ;;47 *)48 exit 149 ;;50esac51EOF52chmod 0755 "$temp_root/bin/gst-inspect-1.0"53cat >"$temp_root/bin/pkg-config" <<'EOF'54#!/usr/bin/env bash55set -euo pipefail56[[ "${1:-}" == --modversion && $# -eq 2 ]]57if [[ "${SIGIL_TEST_MISSING_MODULE:-}" == "$2" ]]; then58 exit 159fi60printf '1.26.11\n'61EOF62chmod 0755 "$temp_root/bin/pkg-config"63cat >"$temp_root/bin/ffmpeg" <<'EOF'64#!/usr/bin/env bash65set -euo pipefail66while [[ $# -gt 0 ]]; do67 if [[ "$1" == -vaapi_device && $# -ge 2 ]]; then68 [[ "$2" == "${SIGIL_TEST_VAAPI_NODE:?}" ]]69 exit70 fi71 shift72done73exit 174EOF75chmod 0755 "$temp_root/bin/ffmpeg"7677PATH="$temp_root/bin:$PATH"78export PATH7980present_output="$(SIGIL_TEST_APPSINK=present gstreamer_inventory)"81grep -qxF 'gstreamer_element=appsink status=present' <<<"$present_output" || \82 fail 'appsink presence was not recorded'83grep -qxF 'gstreamer_va_h264_factory=vah264enc' <<<"$present_output" || \84 fail 'GstVA factory was not recorded'8586missing_output="$(SIGIL_TEST_APPSINK=missing gstreamer_inventory)"87grep -qxF 'gstreamer_element=appsink status=missing' <<<"$missing_output" || \88 fail 'appsink absence was not recorded'8990install -d -m 0700 "$temp_root/dev/dri"91install -m 0600 /dev/null "$temp_root/dev/dri/renderD128"92install -m 0600 /dev/null "$temp_root/dev/dri/renderD129"93SIGIL_TEST_VAAPI_NODE="$temp_root/dev/dri/renderD129"94export SIGIL_TEST_VAAPI_NODE95render_node=''96select_h264_vaapi_render_node "$temp_root/dev/dri" false || \97 fail 'a capability-backed non-AMD render node was not selected'98[[ "$render_node" == "$SIGIL_TEST_VAAPI_NODE" ]] || \99 fail 'render-node selection used enumeration order instead of the encode probe'100101development_output="$(SIGIL_TEST_MISSING_MODULE=gstreamer-video-1.0 \102 gstreamer_development_inventory)"103grep -qxF \104 'gstreamer_development_module=gstreamer-app-1.0 status=present version=1.26.11' \105 <<<"$development_output" || fail 'GStreamer app development version was not recorded'106grep -qxF \107 'gstreamer_development_module=gstreamer-video-1.0 status=missing' \108 <<<"$development_output" || fail 'missing GStreamer video development module was not recorded'109110printf 'bazzite_inventory_gstreamer_tests=ok\n'