1#!/usr/bin/sh 2 3set -eux 4 5SOCAT="$1" 6SERVER="$2" 7 8# Meet DBus bus and path name constraints, append own PID for parallel runs 9TEST_NAME="$(basename "$0" | tr '-' '_')"_${$} 10TEST_DIR="$(mktemp --tmpdir --directory "${TEST_NAME}.XXXXXX")" 11PTYS_PID="" 12SERVER_PID="" 13 14cd "$TEST_DIR" 15 16cleanup() 17{ 18 [ -z "$SERVER_PID" ] || kill -s INT "$SERVER_PID" 19 [ -z "$PTYS_PID" ] || kill "$PTYS_PID" 20 wait 21 cd - 22 rm -rf "$TEST_DIR" 23} 24 25trap cleanup EXIT 26 27TEST_CONF="${TEST_NAME}.conf" 28TEST_LOG="${TEST_NAME}.log" 29 30cat <<EOF > "$TEST_CONF" 31active-console = $TEST_NAME 32[$TEST_NAME] 33logfile = $TEST_LOG 34console-id = $TEST_NAME 35EOF 36 37"$SOCAT" -u PTY,raw,echo=0,link=remote PTY,raw,echo=0,wait-slave,link=local & 38PTYS_PID="$!" 39while ! [ -e remote ] || ! [ -e local ]; do sleep 1; done 40 41"$SERVER" --config "$TEST_CONF" "$(realpath local)" & 42SERVER_PID="$!" 43while ! busctl status --user xyz.openbmc_project.Console."${TEST_NAME}"; do sleep 1; done 44 45echo console-should-log-to-file > remote 46sleep 1 47grep -LF console-should-log-to-file "$TEST_LOG" 48