Skip to content

Commit 62df39e

Browse files
authored
Merge pull request #5398 from NlightNFotis/name_mangling_test_add
Add test for the name mangler regression in #5380.
2 parents d3c99f4 + 11c01e2 commit 62df39e

File tree

8 files changed

+115
-0
lines changed

8 files changed

+115
-0
lines changed

regression/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ add_subdirectory(contracts)
5555
add_subdirectory(goto-harness)
5656
add_subdirectory(goto-harness-multi-file-project)
5757
add_subdirectory(goto-cc-file-local)
58+
add_subdirectory(goto-cc-regression-gh-issue-5380)
5859
add_subdirectory(linking-goto-binaries)
5960
add_subdirectory(symtab2gb)
6061
add_subdirectory(validate-trace-xml-schema)

regression/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ DIRS = cbmc \
2828
systemc \
2929
contracts \
3030
goto-cc-file-local \
31+
goto-cc-regression-gh-issue-5380 \
3132
linking-goto-binaries \
3233
symtab2gb \
3334
solver-hardness \
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
if(WIN32)
2+
set(is_windows true)
3+
else()
4+
set(is_windows false)
5+
endif()
6+
7+
add_test_pl_tests(
8+
"${CMAKE_CURRENT_SOURCE_DIR}/chain.sh $<TARGET_FILE:goto-cc> ${is_windows}"
9+
)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
default: test.log
2+
3+
include ../../src/config.inc
4+
include ../../src/common
5+
6+
ifeq ($(BUILD_ENV_),MSVC)
7+
exe=../../../src/goto-cc/goto-cl
8+
is_windows=true
9+
else
10+
exe=../../../src/goto-cc/goto-cc
11+
is_windows=false
12+
endif
13+
14+
test:
15+
@../test.pl -e -p -c '../chain.sh $(exe) $(is_windows)'
16+
17+
tests.log:
18+
@../test.pl -e -p -c '../chain.sh $(exe) $(is_windows)'
19+
20+
show:
21+
@for dir in *; do
22+
if [ -d "$$dir" ]; then \
23+
vim -o "$$dir/*.c" "$$dir/*.out"; \
24+
fi; \
25+
done;
26+
27+
clean:
28+
@for dir in *; do
29+
$(RM) tests.log; \
30+
if [ -d "$$dir" ]; then \
31+
cd "$$dir"; \
32+
$(RM) *.out *.gb; \
33+
cd ..; \
34+
fi; \
35+
done;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This particular file and chain.sh make sure that a particular
4+
# file is passed twice to goto-cc, causing a crash under some
5+
# specific name mangling configuration.
6+
#
7+
# Author: Fotis Koutoulakis [email protected]
8+
9+
set -e # cause the script to immediately exit when it errors
10+
11+
goto_cc=$1
12+
is_windows=$2
13+
14+
# collect compilation files
15+
PROBLEM_SRC="test.c"
16+
MAIN_SRC="main.c"
17+
18+
echo "source files are ${SRC}"
19+
20+
MAIN_OUTFILE="main.gb"
21+
PROBLEM_OUTFILE="test.gb"
22+
23+
# first drive: compile the problematic file into a gb
24+
if [[ "${is_windows}" == "true" ]]; then
25+
"${goto_cc}" --export-file-local-symbols "${PROBLEM_SRC}" /Fe"${PROBLEM_OUTFILE}"
26+
else
27+
"${goto_cc}" --export-file-local-symbols "${PROBLEM_SRC}" -o "${PROBLEM_OUTFILE}"
28+
fi
29+
30+
# second drive: compile and link the main source, problematic source and problematic
31+
# binary - note: the double inclusion of a similar artifact (source and binary) is
32+
# by design, to test a regression in goto-cc
33+
"${goto_cc}" --export-file-local-symbols "${PROBLEM_SRC}" "${MAIN_SRC}" "${PROBLEM_OUTFILE}"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
static inline int foo()
2+
{
3+
return 42;
4+
}
5+
6+
int bar()
7+
{
8+
return foo();
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
static inline int foo()
2+
{
3+
return 42;
4+
}
5+
6+
int bar();
7+
8+
int test()
9+
{
10+
return foo() + bar();
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CORE
2+
test.c
3+
--export-function-local-symbols
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^Invariant check failed$
9+
--
10+
This test guards against a regression added when the local file
11+
name mangler would not add the required name into the symbol
12+
table. When the regression was present, we were met with an
13+
invariant violation during goto-cc compilation. Without it,
14+
nothing spectacular happens - compilation proceeds as expected.
15+
For more information look up issue 5380 in github.com/diffblue/cbmc.
16+

0 commit comments

Comments
 (0)