summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-03-13 14:58:44 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-03-13 14:59:03 (GMT)
commit1b5554e863b4f2a14bb327a6ae3a2ec40ae4af41 (patch)
tree903d7e0f75d7dff19050a44bd8c385e3f7956ab5 /Tests
parentc3ab1c22b069b64483a0525c3244e3377f256a87 (diff)
parent9aa4640792bd99b232abfe826b0cb0ae72f6644a (diff)
downloadCMake-1b5554e863b4f2a14bb327a6ae3a2ec40ae4af41.zip
CMake-1b5554e863b4f2a14bb327a6ae3a2ec40ae4af41.tar.gz
CMake-1b5554e863b4f2a14bb327a6ae3a2ec40ae4af41.tar.bz2
Merge topic 'profiling'
9aa4640792 cmake: add command line options to output script profiling data Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Ben Boeckel <ben.boeckel@kitware.com> Acked-by: Pavel Solodovnikov <hellyeahdominate@gmail.com> Acked-by: Leonid Pospelov <pospelovlm@yandex.ru> Acked-by: Cristian Adam <cristian.adam@gmail.com> Merge-request: !2760
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CommandLine/ProfilingTest-check.cmake18
-rw-r--r--Tests/RunCMake/CommandLine/ProfilingTest.cmake1
-rw-r--r--Tests/RunCMake/CommandLine/RunCMakeTest.cmake22
-rw-r--r--Tests/RunCMake/CommandLine/profiling-all-params-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/profiling-all-params-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/profiling-invalid-format-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/profiling-invalid-format-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/profiling-missing-format-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/profiling-missing-format-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/profiling-missing-output-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/profiling-missing-output-stderr.txt1
11 files changed, 49 insertions, 0 deletions
diff --git a/Tests/RunCMake/CommandLine/ProfilingTest-check.cmake b/Tests/RunCMake/CommandLine/ProfilingTest-check.cmake
new file mode 100644
index 0000000..19ece86
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/ProfilingTest-check.cmake
@@ -0,0 +1,18 @@
+if (NOT EXISTS ${ProfilingTestOutput})
+ set(RunCMake_TEST_FAILED "Expected ${ProfilingTestOutput} to exists")
+endif()
+
+file(READ "${ProfilingTestOutput}" JSON_HEADER LIMIT 2)
+if (NOT JSON_HEADER MATCHES "^\\[{")
+ set(RunCMake_TEST_FAILED "Expected valid JSON start")
+ return()
+endif()
+
+file(SIZE "${ProfilingTestOutput}" OUTPUT_SIZE)
+math(EXPR END_OFFSET "${OUTPUT_SIZE} -2 ")
+
+file(READ "${ProfilingTestOutput}" JSON_TRAILER OFFSET ${END_OFFSET})
+if (NOT JSON_TRAILER MATCHES "^}]$")
+ set(RunCMake_TEST_FAILED "Expected valid JSON end")
+ return()
+endif()
diff --git a/Tests/RunCMake/CommandLine/ProfilingTest.cmake b/Tests/RunCMake/CommandLine/ProfilingTest.cmake
new file mode 100644
index 0000000..837f4bf
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/ProfilingTest.cmake
@@ -0,0 +1 @@
+# This file is intentionally left blank
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index 087ef21..41f13db 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -697,3 +697,25 @@ function(run_llvm_rc)
unset(LLVMRC_RESULT)
endfunction()
run_llvm_rc()
+
+set(RunCMake_TEST_OPTIONS --profiling-output=/no/such/file.txt --profiling-format=google-trace)
+run_cmake(profiling-all-params)
+unset(RunCMake_TEST_OPTIONS)
+
+set(RunCMake_TEST_OPTIONS --profiling-output=/no/such/file.txt --profiling-format=invalid-format)
+run_cmake(profiling-invalid-format)
+unset(RunCMake_TEST_OPTIONS)
+
+set(RunCMake_TEST_OPTIONS --profiling-output=/no/such/file.txt)
+run_cmake(profiling-missing-format)
+unset(RunCMake_TEST_OPTIONS)
+
+set(RunCMake_TEST_OPTIONS --profiling-format=google-trace)
+run_cmake(profiling-missing-output)
+unset(RunCMake_TEST_OPTIONS)
+
+set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/profiling-test")
+set(ProfilingTestOutput ${RunCMake_TEST_BINARY_DIR}/output.json)
+set(RunCMake_TEST_OPTIONS --profiling-format=google-trace --profiling-output=${ProfilingTestOutput})
+run_cmake(ProfilingTest)
+unset(RunCMake_TEST_OPTIONS)
diff --git a/Tests/RunCMake/CommandLine/profiling-all-params-result.txt b/Tests/RunCMake/CommandLine/profiling-all-params-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/profiling-all-params-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/profiling-all-params-stderr.txt b/Tests/RunCMake/CommandLine/profiling-all-params-stderr.txt
new file mode 100644
index 0000000..6b5c373
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/profiling-all-params-stderr.txt
@@ -0,0 +1 @@
+^.*Could not start profiling: Unable to open: /no/such/file.txt$
diff --git a/Tests/RunCMake/CommandLine/profiling-invalid-format-result.txt b/Tests/RunCMake/CommandLine/profiling-invalid-format-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/profiling-invalid-format-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/profiling-invalid-format-stderr.txt b/Tests/RunCMake/CommandLine/profiling-invalid-format-stderr.txt
new file mode 100644
index 0000000..459bc3a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/profiling-invalid-format-stderr.txt
@@ -0,0 +1 @@
+^.*Invalid format specified for --profiling-format$
diff --git a/Tests/RunCMake/CommandLine/profiling-missing-format-result.txt b/Tests/RunCMake/CommandLine/profiling-missing-format-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/profiling-missing-format-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/profiling-missing-format-stderr.txt b/Tests/RunCMake/CommandLine/profiling-missing-format-stderr.txt
new file mode 100644
index 0000000..459bc3a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/profiling-missing-format-stderr.txt
@@ -0,0 +1 @@
+^.*Invalid format specified for --profiling-format$
diff --git a/Tests/RunCMake/CommandLine/profiling-missing-output-result.txt b/Tests/RunCMake/CommandLine/profiling-missing-output-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/profiling-missing-output-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/profiling-missing-output-stderr.txt b/Tests/RunCMake/CommandLine/profiling-missing-output-stderr.txt
new file mode 100644
index 0000000..9ab0c8f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/profiling-missing-output-stderr.txt
@@ -0,0 +1 @@
+^.*--profiling-format specified but no --profiling-output!$