diff options
author | Marius Kintel <marius@kintel.net> | 2013-02-07 18:43:20 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2013-02-07 18:43:20 (GMT) |
commit | 4e519078d60a92fce4c30b7d60b5b3e26181090f (patch) | |
tree | 4c47cfeee7c60f942442e83811b9b05929fd3fe5 /tests | |
parent | b911a3615e7c28f3448ca73d7f48a263a568c00c (diff) | |
parent | 03be37d16b585e64de87118053206aaae06e7cf8 (diff) |
Merge branch 'master' into issue11_2
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 14 | ||||
-rw-r--r-- | tests/CTestCustom.template | 13 | ||||
-rwxr-xr-x | tests/test_cmdline_tool.py | 2 | ||||
-rw-r--r-- | tests/test_pretty_print.cc | 24 | ||||
-rwxr-xr-x | tests/virtualfb.sh | 74 |
5 files changed, 104 insertions, 23 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bb2ab06..bcdd6af 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -179,6 +179,11 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON) find_package(OpenGL REQUIRED) +if ( "${OPENGL_glu_LIBRARY}" MATCHES "NOTFOUND" ) + # GLU and Mesa split in late 2012 so some systems dont have GLU + find_library(OPENGL_glu_LIBRARY GLU HINTS "$ENV{OPENSCAD_LIBRARIES}/lib" REQUIRED) + set( OPENGL_LIBRARY ${OPENGL_glu_LIBRARY} ${OPENGL_LIBRARY} ) +endif() if (MINGW_CROSS_ENV_DIR) mingw_cross_env_find_qt() @@ -822,6 +827,15 @@ endif() # 1. Start/stop Virtual Framebuffer for linux/bsd. 2. Pretty Print # Please see the CTestCustom.template file for more info. +# +# Post-test pretty print +# + +add_executable(test_pretty_print test_pretty_print.cc) +set_target_properties(test_pretty_print PROPERTIES COMPILE_FLAGS + "-DPYBIN=${PYTHON_EXECUTABLE} -DPYSRC=test_pretty_print.py -DBUILDDIR=--builddir=${CMAKE_CURRENT_BINARY_DIR}" +) + 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}) diff --git a/tests/CTestCustom.template b/tests/CTestCustom.template index 72e6443..338f4b6 100644 --- a/tests/CTestCustom.template +++ b/tests/CTestCustom.template @@ -24,8 +24,7 @@ if( __cmake_system_name__ MATCHES "Linux|BSD") 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) + 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}") @@ -37,8 +36,10 @@ if( __cmake_system_name__ MATCHES "Linux|BSD") 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") + 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() @@ -50,7 +51,7 @@ if( __cmake_system_name__ MATCHES "Linux|BSD") # in the build directory). set(ENV{DISPLAY} "${VFB_DISPLAY}") - set(CTEST_CUSTOM_POST_TEST "kill ${VFB_PID}") + set(CTEST_CUSTOM_POST_TEST "__cmake_current_source_dir__/virtualfb.sh") endif() endif() @@ -59,7 +60,7 @@ endif() 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__") +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} ) diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index 78524bf..ebe60df 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -107,7 +107,7 @@ def compare_png(resultfilename): msg += '\n expected image: ' + expectedfilename + '\n' print >> sys.stderr, msg if not resultfilename: - print >> sys.stderr, "Error: OpenSCAD did not generate an image to test" + print >> sys.stderr, "Error: OpenSCAD error during test image generation" return False print >> sys.stderr, ' actual image: ', resultfilename diff --git a/tests/test_pretty_print.cc b/tests/test_pretty_print.cc new file mode 100644 index 0000000..9959189 --- /dev/null +++ b/tests/test_pretty_print.cc @@ -0,0 +1,24 @@ +/* Workaround for CTEST_CUSTOM_POST_TEST not allowing arguments + compile with + -DPYBIN=/usr/bin/python + -DPYSRC=/home/janedoe/openscad/tests/test_pretty_print.py + -DBUILDDIR=--builddir=/home/janedoe/openscad/tests/bin" +*/ + +#include <unistd.h> +//#include <stdio.h> + +#define PREQUOTE(x) #x +#define QUOTE(x) PREQUOTE(x) +int main( int argc, char * argv[] ) +{ + char *newargs[4]; + newargs[0] = const_cast<char *>(QUOTE( PYBIN )); + newargs[1] = const_cast<char *>(QUOTE( PYSRC )); + newargs[2] = const_cast<char *>(QUOTE( BUILDDIR )); + newargs[3] = NULL; + //printf(":%s:%s:%s\n", newargs[0], newargs[1], newargs[2]); + return execv( newargs[0], newargs ); +} + + diff --git a/tests/virtualfb.sh b/tests/virtualfb.sh index 3c0cf0e..5abd804 100755 --- a/tests/virtualfb.sh +++ b/tests/virtualfb.sh @@ -1,22 +1,64 @@ #!/bin/sh -if [ "`command -v Xvfb`" ]; then - VFB_BINARY=Xvfb -fi +# Toggle the Virtual Framebuffer +# If started, stop. If stopped, start. -if [ "`command -v Xvnc`" ]; then - VFB_BINARY=Xvnc -fi +start() +{ + 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 + + VFB_DISPLAY=`echo | awk 'BEGIN{srand();} {printf ":%.0f", rand()*1000+100};'` + $VFB_BINARY $VFB_DISPLAY -screen 0 800x600x24 &> ./virtualfb.log & + VFB_PID=$! + + echo $VFB_DISPLAY > ./virtualfb.DISPLAY + echo $VFB_PID > ./virtualfb.PID + + echo "Started virtual fb, PID=$VFB_PID , DISPLAY=$VFB_DISPLAY" + sleep 1 +} + +stop() +{ + VFB_PID=`cat ./virtualfb.PID` + VFB_DISPLAY=`cat ./virtualfb.DISPLAY` + + echo "Stopping virtual fb, PID was $VFB_PID, DISPLAY was $VFB_DISPLAY" + kill $VFB_PID + LOCKFILE=`echo "/tmp/.X"$VFB_DISPLAY"-lock"` + if [ -e $LOCKFILE ]; then + rm $LOCKFILE + fi + rm ./virtualfb.PID + rm ./virtualfb.DISPLAY +} + +isrunning() +{ + isrunning_result= + if [ -e ./virtualfb.PID ]; then + VFB_PID=`cat ./virtualfb.PID` + if [ "`ps cax | awk ' { print $1 } ' | grep ^$VFB_PID\$`" ]; then + isrunning_result=1 + fi + fi +} -if [ ! $VFB_BINARY ]; then - echo "$0 Failed, cannot find Xvfb or Xvnc" - exit 1 +isrunning +if [ $isrunning_result ]; then + stop +else + start fi -DISPLAY=:98 -$VFB_BINARY $DISPLAY -screen 0 800x600x24 &> virtualfblog & -echo PID=$! " " -echo DISPLAY=$DISPLAY -# trap "kill -KILL $xpid ||:" EXIT -export DISPLAY -sleep 3 |