forked from fuhsnn/slimcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcctest_simplecc.bash
More file actions
97 lines (81 loc) · 1.91 KB
/
Copy pathcctest_simplecc.bash
File metadata and controls
97 lines (81 loc) · 1.91 KB
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
91
92
93
94
95
96
97
set -u
err_skips=(
# '##' at start/end of never used macro
error/0035-cpp.c
# infinite #include recursion
error/0003-junkinclude.c
# k&r old style function
error/0019-kr_names.c
error/0030-krtypes.c
error/0031-krtypes.c
error/0032-krtypes.c
# warning only
error/0040-vararg.c
# gcc allow
error/0004-macroredef.c
error/0016-arrayinitsize.c
error/0022-cpp-if.c
error/0025-bad-init.c
error/0027-constoverflow.c
error/0028-noconstinit.c
error/0039-struct.c
# old gcc allow
error/0037-pointer.c
)
fix_up() {
sed -i 's|0 == s.d\[2\]|0 != s.d[2]|g' execute/0166-desig.c
# (i % 0) shouldn't be folded
sed -i 's|i % 0|i % 5|g' execute/0140-int_fold.c
# gcc disallow
mv execute/0180-incomplete.c error/_0180-incomplete.c
}
match_skip() {
local -n arr=$2
for f in "${arr[@]}"; do
if [ $f == $1 ]; then
return 0
fi
done
return 1
}
err_test() {
for src in error/*.c; do
if match_skip $src err_skips; then continue; fi
echo $src
$CC $src -S -o/dev/null 2>./warn_log.txt
if [ $? -eq 0 ]; then exit 1; fi
if grep 'internal error' ./warn_log.txt; then exit 1; fi
if grep AddressSanitizer ./warn_log.txt; then exit 1; fi
done
}
exec_test() {
for src in execute/0*.c; do
local ARG
if [ $src == 'execute/0026-implicitret.c' ] ||
[ $src == 'execute/0121-localinit.c' ] ||
[ $src == 'execute/0128-kr_names.c' ] ||
[ $src == 'execute/0143-int_const.c' ] ||
[ $src == 'execute/0156-duff2.c' ]; then
ARG='-std=c89'
elif [ $src == 'execute/0193-incomplete.c' ]; then
ARG='-std=c99 execute/test.c'
else
ARG='-std=c99'
fi
echo $src
$CC $src $ARG -Iexecute/sysinclude -D__SCC__=1 -o ./_tst.exe
if [ $? -ne 0 ]; then
echo 'compile failed'
exit 1;
fi
./_tst.exe >/dev/null
if [ $? -ne 0 ]; then
echo 'exec failed'
exit 1
fi
done
}
cd tests/cc/
fix_up
err_test
exec_test