test/lower/run 977 B raw
1
#!/bin/sh
2
# Run lowering tests.
3
# Usage: test/lower/run [<test.rad>...]
4
#
5
# If no arguments are provided, runs all tests in `lib/std/lang/lower/tests/`.
6
7
BINARY="test/lower/lower-test.rv64"
8
TEST_DIR="lib/std/lang/lower/tests"
9
EMU="${RAD_EMULATOR:-emulator} -stack-size=1024 -run"
10
11
if [ ! -f "$BINARY" ]; then
12
  echo "error: test binary not found: $BINARY" >&2
13
  echo "hint: run 'make lower-test' first" >&2
14
  exit 1
15
fi
16
17
# Disable core dumps for tests.
18
ulimit -c 0
19
20
# Collect tests.
21
if [ $# -eq 0 ]; then
22
  tests=$(find "$TEST_DIR" -name '*.rad' | sort)
23
else
24
  tests="$*"
25
fi
26
27
if [ -z "$tests" ]; then
28
  echo "error: no tests found" >&2
29
  exit 1
30
fi
31
32
passed=0
33
failed=0
34
35
for test in $tests; do
36
  if $EMU "$BINARY" -- "$test"; then
37
    passed=$((passed + 1))
38
  else
39
    failed=$((failed + 1))
40
  fi
41
done
42
echo
43
44
if [ "$failed" -eq 0 ]; then
45
  echo "test result: ok. $passed passed; $failed failed"
46
  exit 0
47
else
48
  echo "test result: FAILED. $passed passed; $failed failed"
49
  exit 1
50
fi