-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·41 lines (41 loc) · 866 Bytes
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
set -eou pipefail
tests=0
passed=0
test() {
tests=$((tests+1))
./lc3ash "tests/$1/main.asm"
lc3as "tests/$1/main.asm" 2>/dev/null 1>&2
file1="$(hexdump -C "tests/$1/main.asm.out")"
file2="$(hexdump -C "tests/$1/main.obj")"
if [ ! "$file1" = "$file2" ]; then
printf 'TEST FAILED %s\nlc3ash:\n%s\nlc3as:\n%s' "$1" "$file1" "$file2"
# failed=$((failed+1))
else
printf 'TEST PASSED %s\n' "$1" # "$lc3ash_time" "$lc3as_time"
passed=$((passed+1))
fi
rm "tests/$1/main.asm.out" "tests/$1/main.obj" "tests/$1/main.sym"
}
shellcheck -s sh lc3ash test.sh
test getc
test out
test puts
test in
test putsp
test halt
test orig_decimal
test fill
test helloworld
test 2labels
test 3labels
test end
test lea
test ld
test ldi
test st
test sti
test jmp
test big_file
printf 'TESTS PASSED: (%s/%s)' "$passed" "$tests"
exit $((tests-passed))