compiler/
lib/
scripts/
seed/
test/
asm/
run
1.1 KiB
lower/
vim/
.gitignore
353 B
.gitsigners
112 B
LICENSE
1.1 KiB
Makefile
3.1 KiB
README
2.5 KiB
std.lib
987 B
std.lib.test
252 B
test/asm/run
raw
| 1 | #!/bin/sh |
| 2 | # Run assembly generation tests. |
| 3 | # Usage: test/asm/run <test.rad>.. |
| 4 | # |
| 5 | # Each test is compiled to a binary and run with the emulator. |
| 6 | |
| 7 | EMU="${RAD_EMULATOR:-emulator} -run" |
| 8 | |
| 9 | if [ $# -eq 0 ]; then |
| 10 | echo "error: no tests specified" >&2 |
| 11 | exit 1 |
| 12 | fi |
| 13 | |
| 14 | # Disable core dumps for tests. |
| 15 | ulimit -c 0 |
| 16 | |
| 17 | passed=0 |
| 18 | failed=0 |
| 19 | |
| 20 | # Run each test. |
| 21 | for test in "$@"; do |
| 22 | bin="${test%.rad}.rv64" |
| 23 | echo -n "test $test ... " |
| 24 | |
| 25 | if [ ! -f "$bin" ]; then |
| 26 | echo "FAILED (binary not found: $bin)" |
| 27 | failed=$((failed + 1)) |
| 28 | continue |
| 29 | fi |
| 30 | |
| 31 | # Parse expected return code from `//! returns: N` header (default 0). |
| 32 | expected=0 |
| 33 | line=$(grep -m1 '^//! returns:' "$test" | sed 's/^\/\/! returns: *//') |
| 34 | if [ -n "$line" ]; then |
| 35 | expected="$line" |
| 36 | fi |
| 37 | |
| 38 | $EMU "$bin" >/dev/null 2>&1 |
| 39 | ret=$? |
| 40 | |
| 41 | if [ "$ret" -eq "$expected" ]; then |
| 42 | echo "ok" |
| 43 | passed=$((passed + 1)) |
| 44 | else |
| 45 | echo "FAILED (expected: $expected, got: $ret)" |
| 46 | failed=$((failed + 1)) |
| 47 | fi |
| 48 | done |
| 49 | echo |
| 50 | |
| 51 | if [ "$failed" -eq 0 ]; then |
| 52 | echo "test result: ok. $passed passed; $failed failed" |
| 53 | exit 0 |
| 54 | else |
| 55 | echo "test result: FAILED. $passed passed; $failed failed" |
| 56 | exit 1 |
| 57 | fi |