blob: 2fc4ba360ba3cf43fc62ae94d8289b0bba19b61e (
plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#!/bin/bash -e
#
# Script for running all of the automated which will go from source to binary.
#
fail() {
echo -e '[\e[1;31mFAIL\e[0m] '"$1:" "$2"
has_failure=1
}
pass() {
echo -e '[\e[1;32mPASS\e[0m] '"$1"
}
clean() {
echo "Removing work dir $WORK"
rm -r "$WORK"
}
if [ "$1" == "noclean" ]; then
NO_CLEAN=1
else
NO_CLEAN=0
fi
WORK=$(mktemp -d)
pushd $(dirname "$0") >/dev/null
source ../valgrind.sh
export ASM="$PWD/../../assembler"
export DISASM="$PWD/../../disassembler"
has_failure=0
test_should_fail() {
local t="$1"
local xc="$2"
if (( xc > 0 && xc < 128 )); then
pass "$t" "assembly xfailed"
elif (( xc == 0 )); then
fail "$t" "assembly didn't fail as expected"
else
fail "$t" "assembler was sent signal $(( xc - 128 ))"
fi
}
test_should_pass() {
local t="$1"
local xc="$2"
if (( xc == 0 )); then
pass "$t"
else
fail "$t" "assembly failed"
fi
}
echo "Should pass:"
for first_stage_asm in should-pass/*.asm ; do
t=$(basename "$first_stage_asm")
first_stage_bin="$WORK/${t}-first_stage.bin"
log="$WORK/${t}.log"
# Assemble test code
set +e
$VALGRIND $VALGRIND_OPTS "$ASM" "$first_stage_asm" "$first_stage_bin" 2>"$log"
xc="$?"
set -e
test_should_pass "$t" "$xc"
done
echo "Should fail (pass means asm failed as expected):"
for first_stage_asm in should-fail/*.asm ; do
t=$(basename "$first_stage_asm")
first_stage_bin="$WORK/${t}-first_stage.bin"
log="$WORK/${t}.log"
# Assemble test code
set +e
$VALGRIND $VALGRIND_OPTS "$ASM" "$first_stage_asm" "$first_stage_bin" 2>"$log"
xc="$?"
set -e
test_should_fail "$t" "$xc"
done
popd >/dev/null
if [[ "$failure" != "0" && "$NO_CLEAN" == "1" ]] ; then
echo "Warning: Leaving work dir $WORK in place. Please remove this yourself"
else
clean
fi
exit "$has_failure"
|