about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorLukas Zaoral <lzaoral@redhat.com>2021-04-13 15:30:23 +0200
committerCristian Cadar <c.cadar@imperial.ac.uk>2021-04-18 18:34:39 +0100
commitd309c4fa0ca2cd55e36cf1462b9057d6eb97a297 (patch)
tree3f14da778b58b906e7092485bdc7e1357c3a992f
parent292600cf54d5fd73278f67a4f98c2f955cbdaa10 (diff)
downloadklee-d309c4fa0ca2cd55e36cf1462b9057d6eb97a297.tar.gz
tests: Do not add klee tools to PATH in lit
It may happen that some older instance of klee is already present
in PATH.  All tests that call plain klee instead of %klee may use
it and then unexpectedly fail.

This commit will make all tests that rely on klee tools being
explicitly in PATH fail in our CI.  From now on, only LLVM tools,
FileCheck and not will be in lit's PATH.
-rwxr-xr-xscripts/build/run-tests.sh6
-rw-r--r--test/CMakeLists.txt3
-rw-r--r--test/lit.cfg10
3 files changed, 14 insertions, 5 deletions
diff --git a/scripts/build/run-tests.sh b/scripts/build/run-tests.sh
index 927cf160..48337f40 100755
--- a/scripts/build/run-tests.sh
+++ b/scripts/build/run-tests.sh
@@ -37,6 +37,12 @@ run_tests() {
   # TODO change to pinpoint specific directory
   cd "${build_dir}"
 
+  # Remove klee from PATH
+  export PATH=${PATH%":/home/klee/klee_build/bin"}
+  if which klee; then
+    return 1 # should not happen
+  fi
+
   ###############################################################################
   # Unit tests
   ###############################################################################
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 2ff9b0eb..2a968333 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -71,6 +71,9 @@ if (NOT EXISTS "${LLVM_TOOLS_BINARY_DIR}/not")
   set(DOWNLOAD_NOT_SOURCE TRUE)
 endif()
 
+# Do not build FileCheck and not to ${KLEE_TOOLS_DIR} as it will not be in lit's PATH.
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${KLEE_TOOLS_DIR}/testtools)
+
 if (DOWNLOAD_FILECHECK_SOURCE)
   if (${LLVM_VERSION_MAJOR} GREATER 3)
     set(FILECHECK_SRC_URL "https://raw.githubusercontent.com/llvm/llvm-project/release/${LLVM_VERSION_MAJOR}.x/llvm/utils/FileCheck/FileCheck.cpp")
diff --git a/test/lit.cfg b/test/lit.cfg
index 6a02daee..a195a1dc 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -35,21 +35,21 @@ klee_src_root = getattr(config, 'klee_src_root', None)
 if klee_obj_root is not None:
   config.test_exec_root = os.path.join(klee_obj_root, 'test')
 
-# Tweak the PATH to include the tool dir.
-if klee_obj_root is not None:
+  # Check KLEE tools directory
   klee_tools_dir = getattr(config, 'klee_tools_dir', None)
   if not klee_tools_dir:
     lit_config.fatal('No KLEE tools dir set!')
 
-  # Check LLVM tool directory
+  # Check LLVM tools directory
   llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
   if not llvm_tools_dir:
-    lit_config.fatal('No LLVM tool directory set!')
+    lit_config.fatal('No LLVM tools directory set!')
 
+  # Add LLVM tools and FileCheck with not to PATH
   path = os.path.pathsep.join(
     (
+      os.path.join(klee_tools_dir, "testtools"),
       llvm_tools_dir,
-      klee_tools_dir,
       config.environment['PATH']
     )
   )