summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeLib/PseudoMemcheck
diff options
context:
space:
mode:
authorTobias Ribizel <ribizel@kit.edu>2020-07-01 14:08:03 (GMT)
committerTobias Ribizel <ribizel@kit.edu>2020-07-09 17:08:34 (GMT)
commitf38e4a18717a70fc5602a3e9b89e52dcb3d646b2 (patch)
tree9f6d74e9103bb031b8aeba2f01f87d27e73c6dc2 /Tests/CMakeLib/PseudoMemcheck
parentfe062800f0f214833120bfb04fed0cfd37739c2c (diff)
downloadCMake-f38e4a18717a70fc5602a3e9b89e52dcb3d646b2.zip
CMake-f38e4a18717a70fc5602a3e9b89e52dcb3d646b2.tar.gz
CMake-f38e4a18717a70fc5602a3e9b89e52dcb3d646b2.tar.bz2
Tests: Add cases for CTest cuda-memcheck parser
Diffstat (limited to 'Tests/CMakeLib/PseudoMemcheck')
-rw-r--r--Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt3
-rw-r--r--Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in34
2 files changed, 35 insertions, 2 deletions
diff --git a/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt b/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt
index 7c84ee1..4bef6c5 100644
--- a/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt
+++ b/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt
@@ -15,6 +15,9 @@ target_link_libraries(pseudo_purify CMakeLib)
add_executable(pseudo_BC "${CMAKE_CURRENT_BINARY_DIR}/ret0.cxx")
set_target_properties(pseudo_BC PROPERTIES OUTPUT_NAME BC)
target_link_libraries(pseudo_BC CMakeLib)
+add_executable(pseudo_cuda-memcheck "${CMAKE_CURRENT_BINARY_DIR}/ret0.cxx")
+set_target_properties(pseudo_cuda-memcheck PROPERTIES OUTPUT_NAME cuda-memcheck)
+target_link_libraries(pseudo_cuda-memcheck CMakeLib)
# binary to be used as pre- and post-memcheck command that fails
add_executable(memcheck_fail "${CMAKE_CURRENT_BINARY_DIR}/ret1.cxx")
diff --git a/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in b/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in
index 3183bc0..f37ad59 100644
--- a/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in
+++ b/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in
@@ -1,8 +1,14 @@
-#include <cmSystemTools.h>
-#include "cmsys/Encoding.hxx"
#include <string>
+#include <vector>
+
+#include "cmsys/Encoding.hxx"
+
+#include <cmSystemTools.h>
+// clang-format off
#define RETVAL @_retval@
+#define CMAKE_COMMAND "@CMAKE_COMMAND@"
+// clang-format on
int main(int ac, char** av)
{
@@ -14,6 +20,9 @@ int main(int ac, char** av)
std::string exename = argv[0];
std::string logarg;
bool nextarg = false;
+ // execute the part after the last argument?
+ // the logfile path gets passed as environment variable PSEUDO_LOGFILE
+ bool exec = false;
if (exename.find("valgrind") != std::string::npos) {
logarg = "--log-file=";
@@ -26,6 +35,10 @@ int main(int ac, char** av)
} else if (exename.find("BC") != std::string::npos) {
nextarg = true;
logarg = "/X";
+ } else if (exename.find("cuda-memcheck") != std::string::npos) {
+ nextarg = true;
+ exec = true;
+ logarg = "--log-file";
}
if (!logarg.empty()) {
@@ -45,8 +58,25 @@ int main(int ac, char** av)
}
}
+ // find the last argument position
+ int lastarg_pos = 1;
+ for (int i = 1; i < argc; ++i) {
+ std::string arg = argv[i];
+ if (arg.find("--") == 0) {
+ lastarg_pos = i;
+ }
+ }
+
if (!logfile.empty()) {
cmSystemTools::Touch(logfile, true);
+ // execute everything after the last argument with additional environment
+ int callarg_pos = lastarg_pos + (nextarg ? 2 : 1);
+ if (exec && callarg_pos < argc) {
+ std::vector<std::string> callargs{ CMAKE_COMMAND, "-E", "env",
+ "PSEUDO_LOGFILE=" + logfile };
+ callargs.insert(callargs.end(), &argv[callarg_pos], &argv[argc]);
+ cmSystemTools::RunSingleCommand(callargs);
+ }
}
}