#!/usr/bin/env bash
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

make -C "$ROOT" -s >/dev/null

BIN="$ROOT/flowlog"

fail() {
  echo "fail: $1" >&2
  exit 1
}

tmpdir="$(mktemp -d -t flowlog_siginfo_key.XXXXXX)"
cleanup() {
  rm -rf "$tmpdir" >/dev/null 2>&1 || true
}
trap cleanup EXIT

tester="$tmpdir/siginfo_key_tty"
cc -O2 -Wall -Wextra "$ROOT/tests/repl_siginfo_key_tty.c" -lutil -o "$tester" || fail "siginfo_key_build"

"$tester" "$BIN" >/dev/null 2>&1 || fail "siginfo_key_output"

echo "ok"
