Skip to content

Commit 9a77872

Browse files
authored
Merge pull request #5578 from tautschnig/goto-harness-windows
Make goto-harness-multi-file-project regression test work on Windows
2 parents a503f5c + 156db79 commit 9a77872

File tree

5 files changed

+47
-17
lines changed

5 files changed

+47
-17
lines changed
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
2-
set(exclude_win_broken_tests -X winbug)
1+
if(WIN32)
2+
set(is_windows true)
33
else()
4-
set(exclude_win_broken_tests "")
4+
set(is_windows false)
55
endif()
66

77
add_test_pl_tests(
8-
"${CMAKE_CURRENT_LIST_DIR}/chain.sh $<TARGET_FILE:goto-cc> $<TARGET_FILE:goto-harness> $<TARGET_FILE:cbmc>" ${exclude_win_broken_tests})
8+
"${CMAKE_CURRENT_LIST_DIR}/chain.sh \
9+
$<TARGET_FILE:goto-cc> \
10+
$<TARGET_FILE:goto-harness> \
11+
$<TARGET_FILE:cbmc> \
12+
${is_windows}")
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1-
default: test
1+
default: tests.log
2+
3+
include ../../src/config.inc
4+
include ../../src/common
5+
6+
GOTO_HARNESS_EXE=../../../src/goto-harness/goto-harness
7+
CBMC_EXE=../../../src/cbmc/cbmc
8+
9+
ifeq ($(BUILD_ENV_),MSVC)
10+
GOTO_CC_EXE=../../../src/goto-cc/goto-cl
11+
is_windows=true
12+
else
13+
GOTO_CC_EXE=../../../src/goto-cc/goto-cc
14+
is_windows=false
15+
endif
216

317
test:
4-
@../test.pl -e -p -c "../chain.sh \
5-
../../../src/goto-cc/goto-cc \
6-
../../../src/goto-harness/goto-harness \
7-
../../../src/cbmc/cbmc"
18+
@../test.pl -e -p -c "../chain.sh $(GOTO_CC_EXE) $(GOTO_HARNESS_EXE) $(CBMC_EXE) $(is_windows)"
19+
20+
tests.log: ../test.pl
21+
@../test.pl -e -p -c "../chain.sh $(GOTO_CC_EXE) $(GOTO_HARNESS_EXE) $(CBMC_EXE) $(is_windows)"
22+
823
clean:
924
find -name '*.out' -execdir $(RM) '{}' \;
1025
$(RM) tests.log

regression/goto-harness-multi-file-project/chain.sh

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ set -e
55
goto_cc="$1"
66
goto_harness="$2"
77
cbmc="$3"
8-
goto_harness_args="${@:4:$#-4}"
8+
is_windows=$4
9+
goto_harness_args="${@:5:$#-5}"
910

1011
cleanup()
1112
{
@@ -14,19 +15,29 @@ cleanup()
1415

1516
trap cleanup EXIT
1617

17-
source_dir="$(pwd)"
18-
target_dir="$(mktemp -d)"
18+
# create the temporary directory relative to the current directory, thus
19+
# avoiding file names that start with a "/", which confuses goto-cl (Windows)
20+
# when running in git-bash.
21+
target_dir="$(TMPDIR=. mktemp -d)"
1922

2023
# Compiling
21-
for file in "$source_dir"/*.c; do
24+
for file in *.c; do
2225
file_name="$(basename "$file")"
23-
"$goto_cc" -c "$file" -o "$target_dir"/"${file_name%.c}.o"
26+
if [[ "${is_windows}" == "true" ]]; then
27+
"$goto_cc" "/c" "$file" "/Fo$target_dir/${file_name%.c}.obj"
28+
else
29+
"$goto_cc" -c "$file" -o "$target_dir"/"${file_name%.c}.o"
30+
fi
2431
done
2532

2633
# Linking
2734

2835
main_exe="$target_dir/main.gb"
29-
"$goto_cc" "$target_dir"/*.o -o "$main_exe"
36+
if [[ "${is_windows}" == "true" ]]; then
37+
"$goto_cc" "$target_dir"/*.obj "/Fe$main_exe"
38+
else
39+
"$goto_cc" "$target_dir"/*.o -o "$main_exe"
40+
fi
3041

3142
harness_out_file="$target_dir/harness.c"
3243
"$goto_harness" "$main_exe" "$harness_out_file" --harness-function-name harness $goto_harness_args

regression/goto-harness-multi-file-project/static_functions/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE winbug
1+
CORE
22
dummy.c
33
--function main --harness-type call-function
44
\[default_serve\.assertion\.1\] line \d+ assertion 0 && \"default serve should fail so we can see it is being called\": FAILURE

regression/goto-harness-multi-file-project/static_symbols_referencing/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE winbug
1+
CORE
22
dummy.c
33
--function another --harness-type call-function
44
^EXIT=10$

0 commit comments

Comments
 (0)