-
Notifications
You must be signed in to change notification settings - Fork 0
/
c.sh
executable file
·75 lines (64 loc) · 1.28 KB
/
c.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
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
if ! command -v iverilog >/dev/null 2>&1; then
echo "You should install iverilog"
exit 1
fi
if command -v rg >/dev/null 2>&1; then
GREP="rg"
else
GREP="grep"
fi
clean() {
rm -f ./a.out
}
compile() {
if ! iverilog -g2005-sv riscv.sv; then
exit 1
fi
}
run_single_test() {
_run_single_test__path="$1"
if [ -n "$_run_single_test__path" ]; then
python3 ./encode.py "$_run_single_test__path" memory_contents.hex
echo Testing - "$_run_single_test__path"
if [ ! -f ./a.out ]; then
compile
fi
./a.out
else
echo Missing file argument, maybe you meant: "$0" test
fi
unset _run_single_test__path
}
run_test() {
_run_test__path="$1"
python3 ./encode.py "$_run_test__path" memory_contents.hex
echo Testing - "$_run_test__path"
if [ ! -f ./a.out ]; then
compile
fi
./a.out | $GREP -i test
unset _run_test__path
}
run_tests() {
for f in $(/bin/ls examples); do
run_test "examples/$f"
done
}
case "$1" in
clean)
clean
;;
compile)
compile
;;
test)
run_tests
;;
run)
run_single_test "$2"
;;
*)
echo "Usage $0 [compile/test/run]"
;;
esac