diff options
Diffstat (limited to 'test/monniaux/csmith')
-rw-r--r-- | test/monniaux/csmith/Makefile | 99 | ||||
-rw-r--r-- | test/monniaux/csmith/Makefile.old | 23 | ||||
-rwxr-xr-x | test/monniaux/csmith/reduce/reduce.sh | 15 | ||||
-rwxr-xr-x | test/monniaux/csmith/reduce/reduce_wrt_host.sh | 37 |
4 files changed, 174 insertions, 0 deletions
diff --git a/test/monniaux/csmith/Makefile b/test/monniaux/csmith/Makefile new file mode 100644 index 00000000..1412921d --- /dev/null +++ b/test/monniaux/csmith/Makefile @@ -0,0 +1,99 @@ +all: + +.SECONDARY: + +INCLUDES=-I csmith/include/csmith-2.3.0/ +TARGET_CCOMP=../../../ccomp + +ifndef TARGET_CC +TARGET_CC=gcc +endif + +ifndef EXECUTE +EXECUTE=timeout 10s +endif + +CFLAGS += -Wno-incompatible-pointer-types + +ifndef CSMITH +CSMITH=csmith/bin/csmith +endif +CSMITHOPT=--max-funcs 10 --no-packed-struct + +MAX=500 +PREFIX=ran%06.f + +# CCOMPOPTS=-Wl,--defsym=USER_STACK_SIZE=0x80000 +CCOMPFLAGS+= -fstruct-passing -fbitfields -fno-cse2 -fno-cse -fno-cse3 -stdlib ../../../runtime + +TESTS_C=$(shell seq --format $(PREFIX)/source.c 1 $(MAX)) + +TESTS_CCOMP_TARGET_S=$(TEST_C:.c=.ccomp.target.s) +TESTS_GCC_TARGET_S=$(TEST_C:.c=.gcc.target.s) +TESTS_GCC_HOST_S=$(TEST_C:.c=.gcc.host.s) +TESTS_CCOMP_TARGET_OUT=$(shell seq --format $(PREFIX)/example.ccomp.target.out 1 $(MAX)) +TESTS_GCC_TARGET_OUT=$(shell seq --format $(PREFIX)/example.gcc.target.out 1 $(MAX)) +TESTS_GCC_HOST_OUT=$(shell seq --format $(PREFIX)/example.gcc.host.out 1 $(MAX)) +TESTS_CMP=$(shell seq --format $(PREFIX)/example.target.cmp 1 $(MAX)) # $(shell seq --format $(PREFIX)/example.host_target.cmp 1 $(MAX)) + + +all: $(TESTS_CCOMP_TARGET_OUT) $(TESTS_GCC_TARGET_OUT) $(TESTS_CCOMP_TARGET_S) $(TESTS_GCC_TARGET_S) $(TESTS_CMP) $(TESTS_C) + +$(TESTS_C): $(CSMITH) + +tests_c: $(TESTS_C) + +tests_s: $(TESTS_CCOMP_TARGET_S) + +%.ccomp.target.s : %.c + $(TARGET_CCOMP) $(INCLUDES) $(CCOMPOPTS) $(CCOMPFLAGS) -S -o $@ $< + +%.gcc.target.s : %.c + $(TARGET_CC) $(INCLUDES) $(CFLAGS) -S -o $@ $< + +%.gcc.host.s : %.c + $(CC) $(INCLUDES) $(CFLAGS) -S -o $@ $< + +%.target.o : %.target.s + $(TARGET_CC) -c -o $@ $< + +%.host.o : %.host.s + $(CC) $(CFLAGS) -c -o $@ $< + +%.target.out : %.target + $(EXECUTE) $< | tee $@ + +%.host.out : %.host + ./$< | tee $@ + +ran%/example.ccomp.target: ran%/source.ccomp.target.o + $(TARGET_CCOMP) $(CCOMPOPTS) $(CCOMPFLAGS) $+ -o $@ + +ran%/example.gcc.target: ran%/source.gcc.target.o + $(TARGET_CC) $(TARGET_CFLAGS) $+ -o $@ + +ran%/example.gcc.host: ran%/source.gcc.host.o + $(CC) $(CFLAGS) $+ -o $@ + +ran%/source.c: + mkdir -p ran$* + $(CSMITH) $(CSMITHOPT) --seed $* --output ran$*/source.c + +ran%/example.target.cmp : ran%/example.ccomp.target.out ran%/example.gcc.target.out + cmp $+ > $@ + cat $< + +ran%/example.host_target.cmp : ran%/example.ccomp.target.out ran%/example.gcc.host.out + cmp $+ > $@ + +.PHONY: all clean tests_c tests_c + +clean: + -rm -rf ran* + +csmith-2.3.0.tar.gz: + curl -L -o $@ https://embed.cs.utah.edu/csmith/csmith-2.3.0.tar.gz + +csmith/bin/csmith: csmith-2.3.0.tar.gz + tar xfz csmith-2.3.0.tar.gz + WD=`pwd` && cd csmith-2.3.0 && ./configure --prefix=$$WD/csmith && make install diff --git a/test/monniaux/csmith/Makefile.old b/test/monniaux/csmith/Makefile.old new file mode 100644 index 00000000..56313452 --- /dev/null +++ b/test/monniaux/csmith/Makefile.old @@ -0,0 +1,23 @@ +CSMITH?=/local/monniaux/packages/csmith-2.3.0/bin/csmith +MAX=1000 + +include ../rules.mk +KVX_CCOMPFLAGS+=-I/local/monniaux/packages/csmith-2.3.0/include/csmith-2.3.0 -fstruct-passing -fbitfields + +TARGETS_S=$(shell seq --format src%06.f.ccomp.kvx.s 0 $(MAX)) +TARGETS_C=$(shell seq --format src%06.f.c 0 $(MAX)) +TARGETS_O=$(shell seq --format src%06.f.ccomp.kvx.o 0 $(MAX)) + +all: c s o + +s: $(TARGETS_S) +c: $(TARGETS_C) +o: $(TARGETS_O) + +src%.c : + $(CSMITH) --output $@ --seed $* + +clean: + -rm -f $(TARGETS_C) $(TARGETS_S) $(TARGETS_O) + +.PHONY: s c o clean diff --git a/test/monniaux/csmith/reduce/reduce.sh b/test/monniaux/csmith/reduce/reduce.sh new file mode 100755 index 00000000..d8df11a5 --- /dev/null +++ b/test/monniaux/csmith/reduce/reduce.sh @@ -0,0 +1,15 @@ +#!/bin/bash +INCLUDE=-I$COMPCERT/test/monniaux/csmith/csmith/include/csmith-2.3.0 +if kvx-cos-gcc $INCLUDE -Werror=uninitialized -Werror=implicit source.c -o source.gcc.target && kvx-cluster -- source.gcc.target >& source.gcc.log +then + if $COMPCERT/ccomp $INCLUDE -fall -fno-cse -fno-cse2 -fno-cse3 source.c -o source.ccomp.target + then + kvx-cluster -- source.ccomp.target >& source.ccomp.log + grep OPCODE source.ccomp.log + else + exit 2 + fi +else + exit 1 +fi + diff --git a/test/monniaux/csmith/reduce/reduce_wrt_host.sh b/test/monniaux/csmith/reduce/reduce_wrt_host.sh new file mode 100755 index 00000000..7a11596f --- /dev/null +++ b/test/monniaux/csmith/reduce/reduce_wrt_host.sh @@ -0,0 +1,37 @@ +#!/bin/bash +INCLUDE=-I$COMPCERT/test/monniaux/csmith/csmith/include/csmith-2.3.0 +if /usr/bin/clang $INCLUDE -O -Werror=int-conversion -Werror=format -Werror=strict-prototypes -Werror=uninitialized -Werror=implicit -Werror=return-type source.c -o source.clang.host && valgrind --exit-on-first-error=yes --error-exitcode=120 --log-file=valgrind.out ./source.clang.host > source.clang.host.out ; +then + if gcc $INCLUDE -Werror=int-conversion -Werror=format -Werror=strict-prototypes -Werror=uninitialized -Werror=implicit -Werror=return-type -fsanitize=undefined -fsanitize=address source.c -o source.gcc+san.host && ./source.gcc+san.host > source.gcc+san.host.out ; + then + if grep "runtime error" source.gcc+san.host.out + then + exit 66 + fi + if cmp source.clang.host.out source.gcc+san.host.out && riscv64-linux-gnu-gcc $INCLUDE -Werror=format -Werror=uninitialized -Werror=implicit source.c -Werror=return-type -o source.gcc.target && qemu-riscv64 -L /usr/riscv64-linux-gnu source.gcc.target >& source.gcc.target.out && grep checksum source.gcc.target.out > source.gcc.target.check && diff source.clang.host.out source.gcc.target.out + then + if $COMPCERT/ccomp $INCLUDE -Werror=missing-declarations -fall -fno-cse -fno-cse2 -fno-cse3 source.c -o source.ccomp.target + then + qemu-riscv64 -L /usr/riscv64-linux-gnu source.ccomp.target >& source.ccomp.target.out + if grep checksum source.ccomp.target.out > source.ccomp.target.check + then + if diff source.ccomp.target.check source.gcc.target.check + then exit 40 + else exit 0 + fi + else + exit 50 + fi + else + exit 2 + fi + else + exit 1 + fi + else + exit 4 + fi +else + exit 5 +fi + |