-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·32 lines (29 loc) · 826 Bytes
/
test.sh
File metadata and controls
executable file
·32 lines (29 loc) · 826 Bytes
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
#!/usr/bin/env bash
passed=0
failed=0
libc_path=$1
ld_flags="$libc_path/crt1.o $libc_path/crti.o $libc_path/crtn.o -lc -dynamic-linker $libc_path/ld-linux-x86-64.so.2 -z noexecstack"
for f in test/*; do
name=$(basename $f)
name=${name%.*}
rm -f build/$name.o
build/mcc test/$name.c build/$name.o
rm -f build/$name
ld $ld_flags build/$name.o -o build/$name
expected=$(cat test/$name.c | grep -m 1 '^// [0-9]' | awk '{print $2}')
(set -x; build/$name)
actual=$?
if [[ $expected == $actual ]]; then
echo -e "\e[32mok\e[0m $name"
((passed++))
else
echo -e "\e[31mfail\e[0m $name: expected $expected, got $actual"
((failed++))
fi
done
echo -ne "$passed \e[32mok\e[0m"
if (( failed != 0 )); then
echo -e ", $failed \e[31mfail\e[0m"
exit 1
fi
echo