test: Add simple e2e test runner
This commit is contained in:
parent
eb8cceacc4
commit
2d6c68b2ed
3 changed files with 47 additions and 0 deletions
30
test/run_tests.sh
Executable file
30
test/run_tests.sh
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
BASEFOLDER=$(dirname "$PWD")
|
||||
INPUT_FILES=$(find "$BASEFOLDER" -type f -name "*.c0")
|
||||
|
||||
"$BASEFOLDER"/build.sh
|
||||
echo "$INPUT_FILES"
|
||||
|
||||
echo
|
||||
echo TESTING
|
||||
echo
|
||||
|
||||
for f in $INPUT_FILES; do
|
||||
out_file=$f.s
|
||||
expected_file=$f.expected
|
||||
echo -n Testing "$(basename \""$f")" "$(basename \""$out_file")"
|
||||
"$BASEFOLDER"/run.sh "$f" "$out_file" &> /dev/null
|
||||
if test $? -ne 0; then
|
||||
echo " FAILED <Compiler error>"
|
||||
continue
|
||||
fi
|
||||
diff -q "$out_file" "$expected_file" > /dev/null
|
||||
if test $? -eq 0; then
|
||||
echo " PASSED"
|
||||
rm "$out_file"
|
||||
else
|
||||
echo " FAILED <Invalid result>"
|
||||
diff "$out_file" "$expected_file"
|
||||
fi
|
||||
done
|
||||
3
test/simple_return.c0
Normal file
3
test/simple_return.c0
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
int main () {
|
||||
return 0;
|
||||
}
|
||||
14
test/simple_return.c0.expected
Normal file
14
test/simple_return.c0.expected
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
.global main
|
||||
.global _main
|
||||
.text
|
||||
main:
|
||||
call _main
|
||||
# move the return value into the first argument for the syscall
|
||||
movq %rax, %rdi
|
||||
# move the exit syscall number into rax
|
||||
movq $0x3C, %rax
|
||||
syscall
|
||||
_main:
|
||||
# your generated code here
|
||||
mov $0,%0
|
||||
ret
|
||||
Loading…
Add table
Add a link
Reference in a new issue