From 39153e074de498f4795cc740694c7432907bce32 Mon Sep 17 00:00:00 2001 From: Andrew Ekstedt Date: Sun, 16 Apr 2023 11:15:00 -0700 Subject: [PATCH] add a test case --- Makefile | 4 ++++ test/true.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100755 test/true.sh diff --git a/Makefile b/Makefile index eea76d5..096359b 100644 --- a/Makefile +++ b/Makefile @@ -12,3 +12,7 @@ all: true false %.o: %.s $(AS) -o $@ $< + +.PHONY: test +test: + @BIN=. test/true.sh diff --git a/test/true.sh b/test/true.sh new file mode 100755 index 0000000..5bba19f --- /dev/null +++ b/test/true.sh @@ -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