add a test case

main
magical 2023-04-16 11:15:00 -07:00
parent 6f4ee19f88
commit 39153e074d
2 changed files with 33 additions and 0 deletions

View File

@ -12,3 +12,7 @@ all: true false
%.o: %.s
$(AS) -o $@ $<
.PHONY: test
test:
@BIN=. test/true.sh

29
test/true.sh 100755
View File

@ -0,0 +1,29 @@
#!/bin/bash
set -eu
set -o pipefail
: ${BIN:-..}
: ${EMU:=qemu-riscv64}
cmd=$BIN/true
name=true
fail=0
err() {
echo "FAIL $name: $*"
fail=1
}
out=$($EMU $cmd)
stat=$?
if [ -n "$out" ]; then
err "expected no output"
fi
if [ "$stat" -ne 0 ]; then
err "exited with status code $stat, expected 0"
fi
if [ "$fail" -eq 0 ]; then
echo PASS $name
fi