diff options
Diffstat (limited to 'tests')
20 files changed, 290 insertions, 87 deletions
| diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 87e5319..8b7a252 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  # @@ -174,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() @@ -289,8 +299,7 @@ if (NOT $ENV{GLEWDIR} STREQUAL "")  elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")    set(GLEW_DIR "$ENV{OPENSCAD_LIBRARIES}")  endif() -if (NOT GLEW_INCLUDE_DIR) -  message(STATUS "OPENCSG_DIR: " ${OPENCSG_DIR}) +if (GLEW_DIR)    find_path(GLEW_INCLUDE_DIR              GL/glew.h              HINTS ${GLEW_DIR}/include @@ -299,16 +308,18 @@ if (NOT GLEW_INCLUDE_DIR)                 NAMES GLEW glew                 HINTS ${GLEW_DIR}/lib ${GLEW_DIR}/lib64  	       NO_DEFAULT_PATH) -  if (NOT GLEW_LIBRARY) -    find_package(GLEW REQUIRED) -    if (NOT GLEW_LIBRARY) -      message(FATAL_ERROR "GLEW not found") -    endif() +  if (GLEW_INCLUDE_DIR AND GLEW_LIBRARY) +    set(GLEW_FOUND 1)    endif() -  message(STATUS "GLEW include: " ${GLEW_INCLUDE_DIR}) -  message(STATUS "GLEW library: " ${GLEW_LIBRARY})  endif() +if (NOT GLEW_FOUND) +  find_package(GLEW REQUIRED) +endif() + +message(STATUS "GLEW include: " ${GLEW_INCLUDE_DIR}) +message(STATUS "GLEW library: " ${GLEW_LIBRARY}) +  inclusion(GLEW_DIR GLEW_INCLUDE_DIR)  # Flex/Bison @@ -370,6 +381,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 +633,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 +667,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 +785,45 @@ 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.  + +# +# 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}) +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..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() diff --git a/tests/FindGLEW.cmake b/tests/FindGLEW.cmake index 1d94ca2..674741d 100644 --- a/tests/FindGLEW.cmake +++ b/tests/FindGLEW.cmake @@ -10,56 +10,56 @@  # a few lines of this file are based on the LGPL code found at   # http://openlibraries.org/browser/trunk/FindGLEW.cmake?rev=1383  -include(FindPkgConfig) +if (WIN32 AND MSVC) +  if (WIN32_STATIC_BUILD) # passed from caller +    set(GLEW_LIB_SEARCH_NAME glew32s.lib) # static, non-debug (Release) +  else () +    set(GLEW_LIB_SEARCH_NAME glew32.lib) # other. untested with OpenSCAD +  endif() +else () # GCC +  set(GLEW_LIB_SEARCH_NAME "libglew32s.a") +endif () -if (PKG_CONFIG_FOUND) -  message("Doing pkg config glew check...") -  pkg_check_modules(GLEW glew>=1.6) +if (WIN32) +  find_path(GLEW_INCLUDE_DIR GL/glew.h +    $ENV{PROGRAMFILES}/GLEW/include +    ${PROJECT_SOURCE_DIR}/src/nvgl/glew/include +    DOC "The directory where GL/glew.h resides") +  find_library(GLEW_LIBRARY +    NAMES ${GLEW_LIB_SEARCH_NAME} +    PATHS +    $ENV{PROGRAMFILES}/GLEW/lib +    ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin +    ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib +    DOC "The GLEW library") +else() +  find_path(GLEW_INCLUDE_DIR GL/glew.h +    PATHS /usr/include /usr/local/include /usr/pkg/include +    DOC "The directory where GL/glew.h resides") +  find_library(GLEW_LIBRARY +    NAMES GLEW glew +    PATHS /usr/lib /usr/local/lib /usr/pkg/lib /lib /lib64 /usr/lib64 +    DOC "The GLEW library")  endif() -if (GLEW_LIBRARIES) -  set(GLEW_INCLUDE_DIR "${GLEW_INCLUDE_DIRS}") -  set(GLEW_LIBRARY ${GLEW_LDFLAGS}) +if ("${GLEW_INCLUDE_DIR}" STREQUAL "" AND "${GLEW_LIBRARY}" STREQUAL "") +  set(GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise")  else() -  if (WIN32 AND MSVC) -    if (WIN32_STATIC_BUILD) # passed from caller -      set(GLEW_LIB_SEARCH_NAME glew32s.lib) # static, non-debug (Release) -    else () -      set(GLEW_LIB_SEARCH_NAME glew32.lib) # other. untested with OpenSCAD -    endif() -  else () # GCC -    set(GLEW_LIB_SEARCH_NAME "libglew32s.a") -  endif () - -  if (WIN32) -    find_path(GLEW_INCLUDE_DIR GL/glew.h -      $ENV{PROGRAMFILES}/GLEW/include -      ${PROJECT_SOURCE_DIR}/src/nvgl/glew/include -      DOC "The directory where GL/glew.h resides") -    find_library(GLEW_LIBRARY -      NAMES ${GLEW_LIB_SEARCH_NAME} -      PATHS -      $ENV{PROGRAMFILES}/GLEW/lib -      ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin -      ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib -      DOC "The GLEW library") -  else (WIN32) -    find_path(GLEW_INCLUDE_DIR GL/glew.h -      PATHS /usr/include /usr/local/include /usr/pkg/include -      NO_DEFAULT_PATH -      DOC "The directory where GL/glew.h resides") -    find_library(GLEW_LIBRARY -      NAMES GLEW glew -      PATHS /usr/lib /usr/local/lib /usr/pkg/lib -      NO_DEFAULT_PATH -      DOC "The GLEW library") -  endif (WIN32) +  set(GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") +endif() -  if (GLEW_INCLUDE_DIR) -    set(GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") -    message(STATUS "GLEW include found in " ${GLEW_INCLUDE_DIR} ) -    message(STATUS "GLEW library found in " ${GLEW_LIBRARY} ) -  else() -    set(GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") +if (NOT GLEW_FOUND) +  find_package(PkgConfig REQUIRED) +  if (PKG_CONFIG_FOUND) +    message(STATUS "Doing pkg config glew check...") +    pkg_search_module(GLEW glew) +    if (GLEW_FOUND) +			set(GLEW_INCLUDE_DIR "${GLEW_INCLUDEDIR}") +      set(GLEW_LIBRARY "-L${GLEW_LIBRARY_DIRS} -l${GLEW_LIBRARIES}") +    endif()    endif()  endif() + +if (NOT GLEW_FOUND) +  message(FATAL_ERROR "GLEW not found") +endif() diff --git a/tests/regression/cgalpngtest/import_stl-tests-expected.png b/tests/regression/cgalpngtest/import_stl-tests-expected.pngBinary files differ index de7638a..c6a4b2d 100644 --- a/tests/regression/cgalpngtest/import_stl-tests-expected.png +++ b/tests/regression/cgalpngtest/import_stl-tests-expected.png diff --git a/tests/regression/cgalpngtest/polygon-intersect-expected.png b/tests/regression/cgalpngtest/polygon-intersect-expected.pngBinary files differ index 6f4f437..54e8d6b 100644 --- a/tests/regression/cgalpngtest/polygon-intersect-expected.png +++ b/tests/regression/cgalpngtest/polygon-intersect-expected.png diff --git a/tests/regression/cgalpngtest/polygon-mesh-expected.png b/tests/regression/cgalpngtest/polygon-mesh-expected.pngBinary files differ index 6f4f437..a8fe41a 100644 --- a/tests/regression/cgalpngtest/polygon-mesh-expected.png +++ b/tests/regression/cgalpngtest/polygon-mesh-expected.png diff --git a/tests/regression/cgalpngtest/polygon-self-intersect-expected.png b/tests/regression/cgalpngtest/polygon-self-intersect-expected.pngBinary files differ index 6f4f437..b93b5fb 100644 --- a/tests/regression/cgalpngtest/polygon-self-intersect-expected.png +++ b/tests/regression/cgalpngtest/polygon-self-intersect-expected.png diff --git a/tests/regression/dumptest/import_stl-tests-expected.txt b/tests/regression/dumptest/import_stl-tests-expected.txt index 947f137..0d46a6f 100644 --- a/tests/regression/dumptest/import_stl-tests-expected.txt +++ b/tests/regression/dumptest/import_stl-tests-expected.txt @@ -5,6 +5,9 @@  	multmatrix([[1, 0, 0, 4], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {  		import(file = "import_bin.stl", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2);  	} +	multmatrix([[1, 0, 0, 0], [0, 1, 0, 4], [0, 0, 1, 0], [0, 0, 0, 1]]) { +		import(file = "import_bin_solid.stl", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2); +	}  	multmatrix([[1, 0, 0, 0], [0, 1, 0, 2], [0, 0, 1, 0], [0, 0, 0, 1]]) {  		import(file = "import.stl", layer = "", origin = [0, 0], scale = 1, convexity = 1, $fn = 0, $fa = 12, $fs = 2);  	} diff --git a/tests/regression/opencsgtest/import_stl-tests-expected.png b/tests/regression/opencsgtest/import_stl-tests-expected.pngBinary files differ index 0bd9ab6..583f3f6 100644 --- a/tests/regression/opencsgtest/import_stl-tests-expected.png +++ b/tests/regression/opencsgtest/import_stl-tests-expected.png diff --git a/tests/regression/opencsgtest/polygon-intersect-expected.png b/tests/regression/opencsgtest/polygon-intersect-expected.pngBinary files differ index 6f4f437..c0a3cc9 100644 --- a/tests/regression/opencsgtest/polygon-intersect-expected.png +++ b/tests/regression/opencsgtest/polygon-intersect-expected.png diff --git a/tests/regression/opencsgtest/polygon-mesh-expected.png b/tests/regression/opencsgtest/polygon-mesh-expected.pngBinary files differ index 6f4f437..b907a74 100644 --- a/tests/regression/opencsgtest/polygon-mesh-expected.png +++ b/tests/regression/opencsgtest/polygon-mesh-expected.png diff --git a/tests/regression/opencsgtest/polygon-self-intersect-expected.png b/tests/regression/opencsgtest/polygon-self-intersect-expected.pngBinary files differ index 6f4f437..899bb6f 100644 --- a/tests/regression/opencsgtest/polygon-self-intersect-expected.png +++ b/tests/regression/opencsgtest/polygon-self-intersect-expected.png diff --git a/tests/regression/throwntogethertest/import_stl-tests-expected.png b/tests/regression/throwntogethertest/import_stl-tests-expected.pngBinary files differ index 0bd9ab6..583f3f6 100644 --- a/tests/regression/throwntogethertest/import_stl-tests-expected.png +++ b/tests/regression/throwntogethertest/import_stl-tests-expected.png diff --git a/tests/regression/throwntogethertest/polygon-intersect-expected.png b/tests/regression/throwntogethertest/polygon-intersect-expected.pngBinary files differ index 81eb514..d889f06 100644 --- a/tests/regression/throwntogethertest/polygon-intersect-expected.png +++ b/tests/regression/throwntogethertest/polygon-intersect-expected.png diff --git a/tests/regression/throwntogethertest/polygon-mesh-expected.png b/tests/regression/throwntogethertest/polygon-mesh-expected.pngBinary files differ index 81eb514..1c2751c 100644 --- a/tests/regression/throwntogethertest/polygon-mesh-expected.png +++ b/tests/regression/throwntogethertest/polygon-mesh-expected.png diff --git a/tests/regression/throwntogethertest/polygon-self-intersect-expected.png b/tests/regression/throwntogethertest/polygon-self-intersect-expected.pngBinary files differ index 81eb514..ebce31e 100644 --- a/tests/regression/throwntogethertest/polygon-self-intersect-expected.png +++ b/tests/regression/throwntogethertest/polygon-self-intersect-expected.png diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index f29acc0..889c429 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -101,7 +101,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/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..5abd804 --- /dev/null +++ b/tests/virtualfb.sh @@ -0,0 +1,64 @@ +#!/bin/sh + +# Toggle the Virtual Framebuffer +# If started, stop. If stopped, start. + +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 +} + +isrunning +if [ $isrunning_result ]; then +  stop +else +  start +fi + | 
