summaryrefslogtreecommitdiff
path: root/tests/CTestCustom.template
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2013-03-06 04:27:12 (GMT)
committerMarius Kintel <marius@kintel.net>2013-03-06 04:27:12 (GMT)
commitf70578f362c8c2c78036c9de846c20802ac7aa81 (patch)
treef327de271f14382c0915677a87e53867785551f7 /tests/CTestCustom.template
parent32469374cfe2985f936f017a204d4e9d7dcd3e2f (diff)
parent03be37d16b585e64de87118053206aaae06e7cf8 (diff)
Merge branch 'master' into epec-kernel
Diffstat (limited to 'tests/CTestCustom.template')
-rw-r--r--tests/CTestCustom.template69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/CTestCustom.template b/tests/CTestCustom.template
new file mode 100644
index 0000000..338f4b6
--- /dev/null
+++ b/tests/CTestCustom.template
@@ -0,0 +1,69 @@
+# __header__
+#
+# This template enables ctest to do things before and after the test runs.
+# In our case, 1. Setup a virtual framebuffer, 2. pretty-print results
+#
+# As a template, this file is read inside of CMakeList.txt and certain
+# words (__word__) are replaced with the cmake build dir/etc, at the time that
+# cmake itself is run. Typically these are signified by two underscores (__)
+# before and after the word in smallcase.
+#
+# The file then becomes CTestCustom.cmake inside the cmake build
+# directory. It is 'run' at the time that ctest is run.
+
+
+# Part 0. X11 and Virtual Framebuffer, for Linux/BSD. This is not used by
+# Windows or Mac because they have alternate means of accessing OpenGL.
+
+set(debug_openscad_template 0)
+
+if( __cmake_system_name__ MATCHES "Linux|BSD")
+ set(DISPLAY_ENV $ENV{DISPLAY})
+ if(DISPLAY_ENV)
+ message("X11 DISPLAY environment variable found. Assuming framebuffer exists at DISPLAY=${DISPLAY_ENV}")
+ else()
+ message("X11 DISPLAY environment variable not found. Calling virtualfb.sh")
+ execute_process(
+ COMMAND __cmake_current_source_dir__/virtualfb.sh OUTPUT_VARIABLE SVFB_OUT)
+ string(REGEX MATCH "DISPLAY=:[0-9.]*" VFB_DISPLAY_STR "${SVFB_OUT}")
+ string(REGEX MATCH ":[0-9.]*" VFB_DISPLAY "${VFB_DISPLAY_STR}")
+ string(REGEX MATCH "PID=[0-9.]*" VFB_PID_STR "${SVFB_OUT}")
+ string(REPLACE "PID=" "" VFB_PID "${VFB_PID_STR}")
+
+ if (debug_openscad_template)
+ message("Output from virtualfb.sh script: ${SVFB_OUT}")
+ message("Display: ${VFB_DISPLAY}")
+ message("Process ID of vfb: ${VFB_PID}")
+ endif()
+ if ("${VFB_DISPLAY}" STREQUAL "" OR "${VFB_PID}" STREQUAL "")
+ set(VFBLOG "virtualfb.log")
+ message("Virtual framebuffer had a problem starting. Printing ${VFBLOG}")
+ execute_process(COMMAND cat virtualfb.log OUTPUT_VARIABLE VFBLOGTXT)
+ message("Log: ${VFBLOGTXT}")
+ else()
+ message("Virtual framebuffer started. DISPLAY=${VFB_DISPLAY}, PID=${VFB_PID}")
+ endif()
+
+
+ # This line is the heart of the mechanism by which ctest is able to take
+ # the DISPLAY env variable of the Virtual Framebuffer it just started, and
+ # pass it on to its child processes (the tests from CTestTestfile.cmake
+ # in the build directory).
+ set(ENV{DISPLAY} "${VFB_DISPLAY}")
+
+ set(CTEST_CUSTOM_POST_TEST "__cmake_current_source_dir__/virtualfb.sh")
+ endif()
+endif()
+
+
+# Part 1. Pretty Printing
+
+message("running 'opencsgtest --info' to generate sysinfo.txt")
+execute_process(COMMAND __wine__ __cmake_current_binary_dir__/opencsgtest --info OUTPUT_FILE sysinfo.txt)
+set(CTEST_CUSTOM_POST_TEST ${CTEST_CUSTOM_POST_TEST} "__cmake_current_binary_dir__/test_pretty_print")
+
+if ( ${debug_openscad_template} )
+ foreach(post_test ${CTEST_CUSTOM_POST_TEST} )
+ message("Post test:" ${post_test})
+ endforeach()
+endif()
contact: Jan Huwald // Impressum