blob: 8d4e052635e2fdb8439b9d3eae7af98406267c7a [file] [log] [blame]
Alexander Hansen6498f9f2024-09-13 17:15:33 +02001#!/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"
31logfile = $TEST_LOG
32console-id = $TEST_NAME
33EOF
34
35"$SOCAT" -u PTY,raw,echo=0,link=remote PTY,raw,echo=0,wait-slave,link=local &
36PTYS_PID="$!"
37while ! [ -e remote ] || ! [ -e local ]; do sleep 1; done
38
39"$SERVER" --config "$TEST_CONF" "$(realpath local)" &
40SERVER_PID="$!"
41while ! busctl status --user xyz.openbmc_project.Console."${TEST_NAME}"; do sleep 1; done
42
43echo console-should-log-to-file-legacy-syntax > remote
44sleep 1
45grep -LF console-should-log-to-file-legacy-syntax "$TEST_LOG"