Skip to content

Commit 272fe76

Browse files
committed
Run C regression tests using clang and gcc when both are available
Our C front-end seeks to conform to whatever interpretation of the C standard the underlying host C compiler has. To avoid incompatibilities as documented in diffblue#2370, run regression tests using both Clang and GCC, if available on a particular system.
1 parent 4467719 commit 272fe76

File tree

5 files changed

+49
-8
lines changed

5 files changed

+49
-8
lines changed

regression/ansi-c/CMakeLists.txt

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,34 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
1919
"CORE"
2020
)
2121
else()
22-
add_test_pl_tests(
23-
"$<TARGET_FILE:goto-cc>"
24-
)
22+
find_program(CLANG_EXISTS "clang")
23+
find_program(GCC_EXISTS "gcc")
24+
if(CLANG_EXISTS)
25+
add_test_pl_profile(
26+
"ansi-c-clang"
27+
"$<TARGET_FILE:goto-cc> --native-compiler clang"
28+
"-C;-s;ansi-c-clang"
29+
"CORE"
30+
)
31+
endif()
32+
if(GCC_EXISTS)
33+
add_test_pl_profile(
34+
"ansi-c-gcc"
35+
"$<TARGET_FILE:goto-cc> --native-compiler gcc"
36+
"-C;-X;fake-gcc-version;-s;ansi-c-gcc"
37+
"CORE"
38+
)
39+
add_test_pl_profile(
40+
"ansi-c-fake-gcc"
41+
"$<TARGET_FILE:goto-cc>"
42+
"-C;-I;fake-gcc-version;-s;ansi-c-fake-gcc"
43+
"CORE"
44+
)
45+
elseif(NOT CLANG_EXISTS)
46+
add_test_pl_tests(
47+
"$<TARGET_FILE:goto-cc>"
48+
)
49+
endif()
2550

2651
add_test_pl_profile(
2752
"ansi-c-c++-front-end"

regression/ansi-c/Makefile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,29 @@ endif
2323
endif
2424

2525
test:
26-
@../test.pl -e -p -c $(exe) $(excluded_tests)
26+
if which clang ; then \
27+
../test.pl -e -p -c "$(exe) --native-compiler clang" $(excluded_tests) ; \
28+
fi
29+
if which gcc ; then \
30+
../test.pl -e -p -c "$(exe) --native-compiler gcc" $(excluded_tests) -X fake-gcc-version && \
31+
../test.pl -e -p -c $(exe) $(excluded_tests) -I fake-gcc-version ; \
32+
elif ! which clang ; then \
33+
../test.pl -e -p -c $(exe) $(excluded_tests) ; \
34+
fi
2735
ifneq ($(BUILD_ENV_),MSVC)
2836
@../test.pl -e -p -c "$(exe) -xc++ -D_Bool=bool" -I test-c++-front-end -s c++-front-end $(excluded_tests)
2937
endif
3038

3139
tests.log: ../test.pl
32-
@../test.pl -e -p -c $(exe) $(excluded_tests)
40+
if which clang ; then \
41+
../test.pl -e -p -c "$(exe) --native-compiler clang" $(excluded_tests) ; \
42+
fi
43+
if which gcc ; then \
44+
../test.pl -e -p -c "$(exe) --native-compiler gcc" $(excluded_tests) -X fake-gcc-version && \
45+
../test.pl -e -p -c $(exe) $(excluded_tests) -I fake-gcc-version ; \
46+
elif ! which clang ; then \
47+
../test.pl -e -p -c $(exe) $(excluded_tests) ; \
48+
fi
3349
ifneq ($(BUILD_ENV_),MSVC)
3450
@../test.pl -e -p -c "$(exe) -xc++ -D_Bool=bool" -I test-c++-front-end -s c++-front-end $(excluded_tests)
3551
endif

regression/ansi-c/gcc_version1/test-gcc-4.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE gcc-only
1+
CORE gcc-only fake-gcc-version
22
gcc-4.c
33
--native-compiler ./fake-gcc-4
44
^EXIT=0$

regression/ansi-c/gcc_version1/test-gcc-5.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE gcc-only
1+
CORE gcc-only fake-gcc-version
22
gcc-5.c
33
--native-compiler ./fake-gcc-5
44
^EXIT=0$

regression/ansi-c/gcc_version1/test-gcc-7.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE gcc-only
1+
CORE gcc-only fake-gcc-version
22
gcc-7.c
33
--native-compiler ./fake-gcc-7
44
^EXIT=0$

0 commit comments

Comments
 (0)