From 63fc53b11724fc0e0b76005c6525fdf0f98f6e86 Mon Sep 17 00:00:00 2001 From: reuk Date: Fri, 15 Sep 2017 10:19:12 +0100 Subject: [PATCH] Stop using sed to modify scripts! --- appveyor.yml | 10 --------- regression/CMakeLists.txt | 2 ++ regression/goto-cc-cbmc/CMakeLists.txt | 10 +++++++++ regression/goto-cc-cbmc/Makefile | 15 +++++++++++-- regression/goto-cc-cbmc/chain.sh | 22 ++++++++++++------- .../goto-cc-goto-analyzer/CMakeLists.txt | 10 +++++++++ regression/goto-cc-goto-analyzer/Makefile | 16 +++++++++++--- regression/goto-cc-goto-analyzer/chain.sh | 22 ++++++++++++------- 8 files changed, 76 insertions(+), 31 deletions(-) create mode 100644 regression/goto-cc-cbmc/CMakeLists.txt create mode 100644 regression/goto-cc-goto-analyzer/CMakeLists.txt diff --git a/appveyor.yml b/appveyor.yml index 3e35e5e75ab..7fe07b6da72 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -61,16 +61,6 @@ test_script: - cmd: | cd regression - sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" goto-cc-cbmc/chain.sh || true - sed -i "11s/.*/$GC $NAME.c/" goto-cc-cbmc/chain.sh || true - sed -i "12i mv $NAME.exe $NAME.gb" goto-cc-cbmc/chain.sh || true - cat goto-cc-cbmc/chain.sh || true - - sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" goto-cc-goto-analyzer/chain.sh || true - sed -i "11s/.*/$gc $name.c/" goto-cc-goto-analyzer/chain.sh || true - sed -i "12i mv $name.exe $name.gb" goto-cc-goto-analyzer/chain.sh || true - cat goto-cc-goto-analyzer/chain.sh || true - rem HACK disable failing tests rmdir /s /q ansi-c\arch_flags_mcpu_bad rmdir /s /q ansi-c\arch_flags_mcpu_good diff --git a/regression/CMakeLists.txt b/regression/CMakeLists.txt index 245e8611246..3d9bb16e741 100644 --- a/regression/CMakeLists.txt +++ b/regression/CMakeLists.txt @@ -27,6 +27,8 @@ add_subdirectory(cbmc-java) add_subdirectory(cbmc-java-inheritance) add_subdirectory(cpp) add_subdirectory(goto-analyzer) +add_subdirectory(goto-cc-cbmc) +add_subdirectory(goto-cc-goto-analyzer) add_subdirectory(goto-diff) add_subdirectory(goto-instrument) add_subdirectory(goto-instrument-typedef) diff --git a/regression/goto-cc-cbmc/CMakeLists.txt b/regression/goto-cc-cbmc/CMakeLists.txt new file mode 100644 index 00000000000..258e36f94a0 --- /dev/null +++ b/regression/goto-cc-cbmc/CMakeLists.txt @@ -0,0 +1,10 @@ +if(WIN32) + set(is_windows true) +else() + set(is_windows false) +endif() + +add_test_pl_tests( + "goto-cc-cbmc" + "${CMAKE_CURRENT_SOURCE_DIR}/chain.sh $ $ ${is_windows}" +) diff --git a/regression/goto-cc-cbmc/Makefile b/regression/goto-cc-cbmc/Makefile index 191f99fcba1..11ce6deb0ca 100644 --- a/regression/goto-cc-cbmc/Makefile +++ b/regression/goto-cc-cbmc/Makefile @@ -1,13 +1,24 @@ default: tests.log +include ../../src/config.inc +include ../../src/common + +ifeq ($(BUILD_ENV_),MSVC) + exe=../../../src/goto-cc/goto-cl + is_windows="true" +else + exe=../../../src/goto-cc/goto-cc + is_windows="false" +endif + test: - @if ! ../test.pl -c ../chain.sh ; then \ + @if ! ../test.pl -c '../chain.sh $(exe) ../../../src/cbmc/cbmc $(is_windows)' ; then \ ../failed-tests-printer.pl ; \ exit 1; \ fi tests.log: - @if ! ../test.pl -c ../chain.sh ; then \ + @if ! ../test.pl -c '../chain.sh $(exe) ../../../src/cbmc/cbmc $(is_windows)' ; then \ ../failed-tests-printer.pl ; \ exit 1; \ fi diff --git a/regression/goto-cc-cbmc/chain.sh b/regression/goto-cc-cbmc/chain.sh index 1440e03272d..9a344a3ea09 100755 --- a/regression/goto-cc-cbmc/chain.sh +++ b/regression/goto-cc-cbmc/chain.sh @@ -1,12 +1,18 @@ -#!/bin/bash +#!/usr/bin/env bash -SRC=../../../src +goto_cc=$1 +cbmc=$2 +is_windows=$3 -GC=$SRC/goto-cc/goto-cc -CBMC=$SRC/cbmc/cbmc +options=${*:4:$#-4} +name=${*:$#} +name=${name%.c} -OPTS=$1 -NAME=${2%.c} +if [[ "${is_windows}" == "true" ]]; then + "${goto_cc}" "${name}.c" + mv "${name}.exe" "${name}.gb" +else + "${goto_cc}" "${name}.c" -o "${name}.gb" +fi -$GC $NAME.c -o $NAME.gb -$CBMC $NAME.gb $OPTS +"${cbmc}" "${name}.gb" ${options} diff --git a/regression/goto-cc-goto-analyzer/CMakeLists.txt b/regression/goto-cc-goto-analyzer/CMakeLists.txt new file mode 100644 index 00000000000..e10f2aace47 --- /dev/null +++ b/regression/goto-cc-goto-analyzer/CMakeLists.txt @@ -0,0 +1,10 @@ +if(WIN32) + set(is_windows true) +else() + set(is_windows false) +endif() + +add_test_pl_tests( + "goto-cc-goto-analyzer" + "${CMAKE_CURRENT_SOURCE_DIR}/chain.sh $ $ ${is_windows}" +) diff --git a/regression/goto-cc-goto-analyzer/Makefile b/regression/goto-cc-goto-analyzer/Makefile index 18f4d370eb8..7f62e471b48 100644 --- a/regression/goto-cc-goto-analyzer/Makefile +++ b/regression/goto-cc-goto-analyzer/Makefile @@ -1,15 +1,25 @@ - default: tests.log +include ../../src/config.inc +include ../../src/common + +ifeq ($(BUILD_ENV_),MSVC) + exe=../../../src/goto-cc/goto-cl + is_windows="true" +else + exe=../../../src/goto-cc/goto-cc + is_windows="false" +endif + test: - @if ! ../test.pl -c ../chain.sh ; then \ + @if ! ../test.pl -c '../chain.sh $(exe) ../../../src/goto-analyzer/goto-analyzer $(is_windows)' ; then \ ../failed-tests-printer.pl ; \ exit 1; \ fi tests.log: pwd - @if ! ../test.pl -c ../chain.sh ; then \ + @if ! ../test.pl -c '../chain.sh $(exe) ../../../src/goto-analyzer/goto-analyzer $(is_windows)' ; then \ ../failed-tests-printer.pl ; \ exit 1; \ fi diff --git a/regression/goto-cc-goto-analyzer/chain.sh b/regression/goto-cc-goto-analyzer/chain.sh index b34d0e7750e..1af154b978c 100755 --- a/regression/goto-cc-goto-analyzer/chain.sh +++ b/regression/goto-cc-goto-analyzer/chain.sh @@ -1,12 +1,18 @@ -#!/bin/bash +#!/usr/bin/env bash -src=../../../src +goto_cc=$1 +goto_analyzer=$2 +is_windows=$3 -gc=$src/goto-cc/goto-cc -goto_analyzer=$src/goto-analyzer/goto-analyzer +options=${*:4:$#-4} +name=${*:$#} +name=${name%.c} -options=$1 -name=${2%.c} +if [[ "${is_windows}" == "true" ]]; then + "${goto_cc}" "${name}.c" + mv "${name}.exe" "${name}.gb" +else + "${goto_cc}" "${name}.c" -o "${name}.gb" +fi -$gc $name.c -o $name.gb -$goto_analyzer $name.gb $options +"${goto_analyzer}" "${name}.gb" ${options}