-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.sh
executable file
·64 lines (51 loc) · 1.12 KB
/
run_tests.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
set -u
export LANG=C
mkdir -p test_out
function error() {
echo "$1"
exit 1
}
function hex2bin() {
xxd -r test/"$1"_hex.txt > test/"$1".bin
}
function disassemble() {
(cd "$1" && avr-objdump -b binary -m avr -D "$2".bin > "$2"_dis.txt) || error "disassembly failed: $1/$2.bin"
}
function assemble() {
file="$1"
shift
rasm --no-vectors "$@" test/"$file".s -o test_out/"$file".bin || error "assembly failed: test/$file"
}
function diff_disassembly() {
colordiff -u test/"$1"_dis.txt test_out/"$1"_dis.txt || error "output not correct"
}
function diff_binary() {
cmp test/"$1".bin test_out/"$1".bin || error "output not correct"
}
function check_raw() {
echo "$1"
hex2bin "$1"
assemble "$@"
diff_binary "$1"
}
function check() {
echo "$1"
hex2bin "$1"
disassemble test "$1"
assemble "$@"
disassemble test_out "$1"
diff_disassembly "$1"
}
rm -rf test_out/ test/*.bin
mkdir -p test_out/
check_raw empty
check syntax
check vectors --vectors
check jumps --vectors
check variables
check arithlog
check branches
check bits
check xfer
check mcuctrl