summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2013-01-28 05:38:50 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2013-01-28 05:38:50 (GMT)
commitd6f2cc1a1e6f7bc55d137d653242086c29a1bf32 (patch)
tree6f9612971383d26374bbcf75b389d311a56bf492
parentd0856efe6da545693f9c50a8a2514a9f999ab5ef (diff)
if we are on linux/BSD and there's no X running, try Xvfb automatically.
also workaround some Gallium bugs and Imagemagick bugs
-rw-r--r--tests/CMakeLists.txt73
-rw-r--r--tests/CTestCustom.template68
-rwxr-xr-xtests/test_pretty_print.py17
-rwxr-xr-xtests/virtualfb.sh22
4 files changed, 149 insertions, 31 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 87e5319..8822c92 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -42,6 +42,11 @@ if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG")
endif()
+# MCAD
+if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../libraries/MCAD/__init__.py)
+ message(FATAL_ERROR "MCAD not found. You can install from the OpenSCAD root as follows: \n git submodule update --init")
+endif()
+
#
# Windows
#
@@ -370,6 +375,19 @@ if (NOT SKIP_IMAGEMAGICK)
endif()
endif()
+if ( "${ImageMagick_VERSION_STRING}" VERSION_LESS "6.5.9.4" )
+ message(STATUS "ImageMagick version less than 6.5.9.4, cannot use -morphology comparison")
+ message(STATUS "ImageMagick Using older image comparison method")
+ set(COMPARATOR "old")
+endif()
+
+execute_process(COMMAND ${ImageMagick_convert_EXECUTABLE} --version OUTPUT_VARIABLE IM_OUT )
+if ( ${IM_OUT} MATCHES "OpenMP" )
+ # http://www.daniloaz.com/en/617/systems/high-cpu-load-when-converting-images-with-imagemagick
+ message(STATUS "ImageMagick: OpenMP bug workaround - setting MAGICK_THREAD_LIMIT=1")
+ set(CTEST_ENVIRONMENT "${CTEST_ENVIRONMENT};MAGICK_THREAD_LIMIT=1")
+endif()
+
# Internal includes
include_directories(../src)
@@ -609,12 +627,6 @@ function(get_test_fullname TESTCMD FILENAME FULLNAME)
set(${FULLNAME} ${${FULLNAME}} PARENT_SCOPE)
endfunction()
-# comparison method to use
-if (NOT $ENV{COMPARATOR} STREQUAL "")
- set(COMPARATOR "$ENV{COMPARATOR}")
- message(STATUS "ImageMagick method modified with COMPARATOR: " ${COMPARATOR})
-endif()
-
#
# This functions adds cmd-line tests given files.
# Files are sent as the parameters following TESTSUFFIX
@@ -649,31 +661,14 @@ macro(add_cmdline_test TESTCMD TESTSUFFIX)
set( MINGW_CROSS_ARG "--mingw-cross-env" )
endif()
add_test(NAME ${TEST_FULLNAME} ${CONFARG} ${CONFVAL} COMMAND ${PYTHON_EXECUTABLE} ${tests_SOURCE_DIR}/test_cmdline_tool.py ${MINGW_CROSS_ARG} --comparator=${COMPARATOR} -c ${ImageMagick_convert_EXECUTABLE} -s ${TESTSUFFIX} ${CMAKE_BINARY_DIR}/${TESTCMD} "${SCADFILE}")
+ set_property(TEST ${TEST_FULLNAME} PROPERTY ENVIRONMENT "${CTEST_ENVIRONMENT}")
endif()
endforeach()
endmacro()
enable_testing()
-# set up custom pretty printing of results
-set(INFOCMD "execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/opencsgtest --info OUTPUT_FILE sysinfo.txt)")
-if (MINGW_CROSS_ENV_DIR)
- set(INFOCMD "execute_process(COMMAND wine ${CMAKE_CURRENT_BINARY_DIR}/opencsgtest --info OUTPUT_FILE sysinfo.txt)")
-endif()
-set(PRETTYCMD "\"${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_pretty_print.py --builddir=${CMAKE_CURRENT_BINARY_DIR}\"")
-set(CTEST_CUSTOM_FILE ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake)
-set(CTEST_CUSTOM_TXT "\n
- message(\"running 'opencsgtest --info' to generate sysinfo.txt\")\n
- ${INFOCMD}\n
- set(CTEST_CUSTOM_POST_TEST ${PRETTYCMD})\n
-")
-file(WRITE ${CTEST_CUSTOM_FILE} ${CTEST_CUSTOM_TXT})
-
-foreach(FILE test_pretty_print.py)
- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
- ${CMAKE_CURRENT_BINARY_DIR}/${FILE} COPYONLY)
-endforeach()
set_directory_properties(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_SOURCE_DIR}/EnforceConfig.cmake")
@@ -784,6 +779,36 @@ foreach(FILE ${EXAMPLE_FILES})
set_test_config(Examples ${TEST_FULLNAME})
endforeach()
+# Workaround Gallium bugs
+if ( ${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc")
+ message(STATUS "Workaround PPC bug https://bugs.freedesktop.org/show_bug.cgi?id=42540")
+ set(CTEST_ENVIRONMENT "${CTEST_ENVIRONMENT};GALLIUM_DRIVER=softpipe")
+ set(CTEST_ENVIRONMENT "${CTEST_ENVIRONMENT};DRAW_USE_LLVM=no")
+endif()
+
+# Set up custom commands to run before & after Ctest run.
+# 1. Start/stop Virtual Framebuffer for linux/bsd. 2. Pretty Print
+# Please see the CTestCustom.template file for more info.
+
+file(READ ${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.template TMP)
+string(REPLACE __cmake_current_binary_dir__ ${CMAKE_CURRENT_BINARY_DIR} TMP ${TMP})
+string(REPLACE __cmake_current_source_dir__ ${CMAKE_CURRENT_SOURCE_DIR} TMP ${TMP})
+string(REPLACE __python__ ${PYTHON_EXECUTABLE} TMP ${TMP})
+string(REPLACE __header__ "Generated by cmake from ${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.template" TMP ${TMP})
+string(REPLACE __cmake_system_name__ ${CMAKE_SYSTEM_NAME} TMP ${TMP})
+
+if (MINGW_CROSS_ENV_DIR)
+ string(REPLACE __wine__ wine TMP ${TMP})
+else()
+ string(REPLACE __wine__ " " TMP ${TMP})
+endif()
+
+message(STATUS "creating CTestCustom.cmake")
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake ${TMP})
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test_pretty_print.py
+ ${CMAKE_CURRENT_BINARY_DIR}/test_pretty_print.py COPYONLY)
+
# Add tests
add_cmdline_test(echotest txt ${ECHO_FILES})
diff --git a/tests/CTestCustom.template b/tests/CTestCustom.template
new file mode 100644
index 0000000..72e6443
--- /dev/null
+++ b/tests/CTestCustom.template
@@ -0,0 +1,68 @@
+# __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 start
+ 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 "")
+ message("Virtual framebuffer had a problem starting.")
+ execute_process("cat virtualfblog")
+ 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 "kill ${VFB_PID}")
+ 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} "__python__ __cmake_current_source_dir__/test_pretty_print.py --builddir=__cmake_current_binary_dir__")
+
+if ( ${debug_openscad_template} )
+ foreach(post_test ${CTEST_CUSTOM_POST_TEST} )
+ message("Post test:" ${post_test})
+ endforeach()
+endif()
diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py
index a2a04ed..ed86b65 100755
--- a/tests/test_pretty_print.py
+++ b/tests/test_pretty_print.py
@@ -62,13 +62,16 @@ def ezsearch(pattern,str):
def read_gitinfo():
# won't work if run from outside of branch.
- data = subprocess.Popen(['git','remote','-v'],stdout=subprocess.PIPE).stdout.read()
- origin = ezsearch('^origin *?(.*?)\(fetch.*?$',data)
- upstream = ezsearch('^upstream *?(.*?)\(fetch.*?$',data)
- data = subprocess.Popen(['git','branch'],stdout=subprocess.PIPE).stdout.read()
- branch = ezsearch('^\*(.*?)$',data)
- out = 'Git branch: ' + branch + ' from origin ' + origin + '\n'
- out += 'Git upstream: ' + upstream + '\n'
+ try:
+ data = subprocess.Popen(['git','remote','-v'],stdout=subprocess.PIPE).stdout.read()
+ origin = ezsearch('^origin *?(.*?)\(fetch.*?$',data)
+ upstream = ezsearch('^upstream *?(.*?)\(fetch.*?$',data)
+ data = subprocess.Popen(['git','branch'],stdout=subprocess.PIPE).stdout.read()
+ branch = ezsearch('^\*(.*?)$',data)
+ out = 'Git branch: ' + branch + ' from origin ' + origin + '\n'
+ out += 'Git upstream: ' + upstream + '\n'
+ except:
+ out = 'Problem running git'
return out
def read_sysinfo(filename):
diff --git a/tests/virtualfb.sh b/tests/virtualfb.sh
new file mode 100755
index 0000000..3c0cf0e
--- /dev/null
+++ b/tests/virtualfb.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [ "`command -v Xvfb`" ]; then
+ VFB_BINARY=Xvfb
+fi
+
+if [ "`command -v Xvnc`" ]; then
+ VFB_BINARY=Xvnc
+fi
+
+if [ ! $VFB_BINARY ]; then
+ echo "$0 Failed, cannot find Xvfb or Xvnc"
+ exit 1
+fi
+
+DISPLAY=:98
+$VFB_BINARY $DISPLAY -screen 0 800x600x24 &> virtualfblog &
+echo PID=$! " "
+echo DISPLAY=$DISPLAY
+# trap "kill -KILL $xpid ||:" EXIT
+export DISPLAY
+sleep 3
contact: Jan Huwald // Impressum