Skip to content

Commit 671ca13

Browse files
committed
Run CSmith to compare compiler's output
CSmith itself causes, * with safe-math, infinite loop happens * without safe-math, divide by zero * undefined behavior: * right shift more than bit width
1 parent a891a62 commit 671ca13

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tool/check-csmith.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
INC_PATH="-I $CSMITH_PATH"
6+
7+
CSMITH_OPT="
8+
--max-funcs 3
9+
--max-expr-complexity 3
10+
--no-packed-struct
11+
--no-safe-math
12+
--no-jumps
13+
"
14+
15+
RUN_AOUT="./a.out"
16+
CC=gcc
17+
XCC=./xcc
18+
# RUN_AOUT="./tool/run-riscv64 ./a.out"
19+
# CC=riscv64-unknown-elf-gcc
20+
21+
# wcc
22+
# RUN_AOUT="./tool/runwasi ./a.wasm"
23+
# CC="emcc -o a.wasm"
24+
# XCC="./wcc --stack-size=0x10000"
25+
26+
for i in `seq 0 99`; do
27+
echo "Test $i"
28+
29+
csmith $CSMITH_OPT > tmp.c
30+
# csmith creates platform.info
31+
rm -f platform.info
32+
33+
$XCC $INC_PATH tmp.c > /dev/null 2>&1
34+
$RUN_AOUT > tmp_out.xcc.txt
35+
36+
$CC $INC_PATH tmp.c > /dev/null 2>&1
37+
$RUN_AOUT > tmp_out.gcc.txt
38+
diff tmp_out.xcc.txt tmp_out.gcc.txt
39+
done
40+
41+
rm tmp_out.*
42+
echo "SUCCESS"

0 commit comments

Comments
 (0)