diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/CMakeLists.txt | 49 | ||||
| -rw-r--r-- | tests/OffscreenContext.cc | 11 | ||||
| -rw-r--r-- | tests/csgtestcore.cc | 63 | ||||
| -rwxr-xr-x | tests/ctest_pretty_print.py (renamed from tests/cakebaby.py) | 0 | 
4 files changed, 89 insertions, 34 deletions
| diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6966436..69e43a9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -75,24 +75,20 @@ if (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "")    set(BOOST_ROOT "$ENV{MACOSX_DEPLOY_DIR}")  endif() -if(BOOST_ROOT) -  #set(Boost_DEBUG TRUE) -  set(Boost_NO_SYSTEM_PATHS TRUE) -  set(Boost_ADDITIONAL_VERSIONS "1.47.0") -  find_package( Boost 1.35.0 COMPONENTS thread program_options ) -  if(Boost_FOUND) -    message(STATUS "Boost includes found: " ${Boost_INCLUDE_DIRS}) -    message(STATUS "Boost libraries found:") -    foreach(boostlib ${Boost_LIBRARIES}) -      message(STATUS "  " ${boostlib}) -    endforeach() -    include_directories(${Boost_INCLUDE_DIRS}) -  else() -    message(STATUS "BOOST_ROOT:" ${BOOST_ROOT}) -    message(FATAL_ERROR "BOOST_ROOT specified but no boost found") -  endif() +#set(Boost_DEBUG TRUE) +set(Boost_NO_SYSTEM_PATHS TRUE) +set(Boost_ADDITIONAL_VERSIONS "1.47.0") +find_package( Boost 1.35.0 COMPONENTS thread program_options ) +if(Boost_FOUND) +  message(STATUS "Boost includes found: " ${Boost_INCLUDE_DIRS}) +  message(STATUS "Boost libraries found:") +  foreach(boostlib ${Boost_LIBRARIES}) +    message(STATUS "  " ${boostlib}) +  endforeach() +  include_directories(${Boost_INCLUDE_DIRS})  else() -  message(STATUS "BOOST_ROOT unset. Assuming it will be found automatically.") +  message(STATUS "BOOST_ROOT: ${BOOST_ROOT}") +  message(FATAL_ERROR "Boost not found.")  endif()  # Mac OS X @@ -260,13 +256,13 @@ set(COMMON_SOURCES  #  if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")  	message(STATUS "Offscreen OpenGL Context - using Apple CGL") -	set(OFFSCREEN_CTX_SOURCE "OffscreenContext.mm") +	set(OFFSCREEN_CTX_SOURCE "OffscreenContext.mm" CACHE TYPE STRING)  elseif(UNIX)  	message(STATUS "Offscreen OpenGL Context - using Unix GLX") -	set(OFFSCREEN_CTX_SOURCE "OffscreenContext.cc") +	set(OFFSCREEN_CTX_SOURCE "OffscreenContext.cc" CACHE TYPE STRING)  elseif(WIN32)  	message(STATUS "Offscreen OpenGL Context - using Microsoft WGL") -	set(OFFSCREEN_CTX_SOURCE "OffscreenContextWGL.cc") +	set(OFFSCREEN_CTX_SOURCE "OffscreenContextWGL.cc" CACHE TYPE STRING)  endif()  set(OFFSCREEN_SOURCES @@ -362,6 +358,19 @@ endfunction()  enable_testing() +# set up custom pretty printing of results + +set(INFOCMD "execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/opencsgtest --info OUTPUT_FILE sysinfo.txt)") +set(PRETTYCMD "\"${PYTHON_EXECUTABLE} ctest_pretty_print.py\"") +set(CTEST_CUSTOM_FILE ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake) +set(CTEST_CUSTOM_TXT "\n +  ${INFOCMD}\n +  set(CTEST_CUSTOM_POST_TEST ${PRETTYCMD})\n +") +file(WRITE ${CTEST_CUSTOM_FILE} ${CTEST_CUSTOM_TXT}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ctest_pretty_print.py  +                 ${CMAKE_CURRENT_BINARY_DIR}/ctest_pretty_print.py COPYONLY) +  # Find all scad files  file(GLOB MINIMAL_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/minimal/*.scad)  file(GLOB FEATURES_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/features/*.scad) diff --git a/tests/OffscreenContext.cc b/tests/OffscreenContext.cc index 839eea9..e2b28e5 100644 --- a/tests/OffscreenContext.cc +++ b/tests/OffscreenContext.cc @@ -99,6 +99,7 @@ bool create_glx_dummy_window(OffscreenContext &ctx)      GLX_RED_SIZE, 1,      GLX_GREEN_SIZE, 1,      GLX_BLUE_SIZE, 1, +    GLX_DEPTH_SIZE, 1,      None    }; @@ -123,8 +124,8 @@ bool create_glx_dummy_window(OffscreenContext &ctx)    Window root = DefaultRootWindow( dpy );    XSetWindowAttributes xwin_attr; -  int width = 42; -  int height = 42; +  int width = ctx.width; +  int height = ctx.height;    xwin_attr.background_pixel = 0;    xwin_attr.border_pixel = 0;    xwin_attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); @@ -147,7 +148,7 @@ bool create_glx_dummy_window(OffscreenContext &ctx)    XSetErrorHandler( original_xlib_handler );    // Most programs would call XMapWindow here. But we don't, to keep the window hidden -  // XMapWindow( dpy, xWin ); +  XMapWindow( dpy, xWin );    GLXContext context = glXCreateNewContext( dpy, fbconfigs[0], GLX_RGBA_TYPE, NULL, True );    if ( context == NULL ) { @@ -229,11 +230,11 @@ OffscreenContext *create_offscreen_context(int w, int h)    }    glew_dump(); -  ctx->fbo = fbo_new(); +/*  ctx->fbo = fbo_new();    if (!fbo_init(ctx->fbo, w, h)) {      cerr << "GL Framebuffer Object init failed; dumping GLEW info" << endl;      return NULL; -  } +  }*/    return ctx;  } diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 034084c..a6e3747 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -25,8 +25,15 @@  #include <QDir>  #include <QSet>  #include <QTimer> +  #include <sstream> +#include <vector> + +#include <boost/program_options.hpp> +namespace po = boost::program_options; +using std::string; +using std::vector;  using std::cerr;  using std::cout; @@ -41,9 +48,9 @@ public:  	CsgInfo();  	CSGTerm *root_norm_term;          // Normalized CSG products  	class CSGChain *root_chain; -	std::vector<CSGTerm*> highlight_terms; +	vector<CSGTerm*> highlight_terms;  	CSGChain *highlights_chain; -	std::vector<CSGTerm*> background_terms; +	vector<CSGTerm*> background_terms;  	CSGChain *background_chain;  	OffscreenView *glview;  }; @@ -51,9 +58,9 @@ public:  CsgInfo::CsgInfo() {          root_norm_term = NULL;          root_chain = NULL; -        highlight_terms = std::vector<CSGTerm*>(); +        highlight_terms = vector<CSGTerm*>();          highlights_chain = NULL; -        background_terms = std::vector<CSGTerm*>(); +        background_terms = vector<CSGTerm*>();          background_chain = NULL;          glview = NULL;  } @@ -67,15 +74,52 @@ AbstractNode *find_root_tag(AbstractNode *n)  	return NULL;  } +string info_dump(OffscreenView *glview) +{ +	std::stringstream out; +	out << "test"; +	return out.str(); +} + +po::variables_map parse_options(int argc, char *argv[]) +{ +        po::options_description desc("Allowed options"); +        desc.add_options() +                ("info,i", "information on GLEW, OpenGL, OpenSCAD, and OS"); + +        po::options_description hidden("Hidden options"); +        hidden.add_options() +                ("input-file", po::value< vector<string> >(), "input file"); +                ("output-file", po::value< vector<string> >(), "ouput file"); + +        po::positional_options_description p; +        p.add("input-file", -1); +        p.add("output-file", -1); + +        po::options_description all_options; +        all_options.add(desc).add(hidden); + +        po::variables_map vm; +        po::store(po::command_line_parser(argc, argv).options(all_options).positional(p).run(), vm); + +	return vm; +} +  int csgtestcore(int argc, char *argv[], test_type_e test_type)  { -	if (argc != 3) { -		fprintf(stderr, "Usage: %s <file.scad> <output.png>\n", argv[0]); -		exit(1); +	bool sysinfo_dump = false; +	const char *filename, *outfilename = NULL; +	po::variables_map vm = parse_options(argc, argv); +	if (vm.count("info")) sysinfo_dump = true; +	if (vm.count("input-file") && vm.count("output-file")) { +		filename = vm["input-file"].as< vector<string> >().begin()->c_str(); +		outfilename = vm["output-file"].as< vector<string> >().begin()->c_str();  	} -	const char *filename = argv[1]; -	const char *outfilename = argv[2]; +	if (!filename || !outfilename || !sysinfo_dump) { +		cerr << "Usage: " << argv[0] << " <file.scad> <output.png>\n"; +		exit(1); +	}  	Builtins::instance()->initialize(); @@ -194,6 +238,7 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type)  		fprintf(stderr,"Can't create OpenGL OffscreenView. Code: %i. Exiting.\n", error);  		exit(1);  	} +	if (sysinfo_dump) cout << info_dump(csgInfo.glview);  	BoundingBox bbox = csgInfo.root_chain->getBoundingBox();  	Vector3d center = (bbox.min() + bbox.max()) / 2; diff --git a/tests/cakebaby.py b/tests/ctest_pretty_print.py index a58b6bc..a58b6bc 100755 --- a/tests/cakebaby.py +++ b/tests/ctest_pretty_print.py | 
