From 3eb466b5a9dcb7507045898efc7ad52226f54782 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sun, 13 Nov 2011 10:39:34 -0600 Subject: [PATCH] add pretty_print step to ctest run. add '-info' option to opencsgtest. --- tests/CMakeLists.txt | 49 +++++++++------ tests/OffscreenContext.cc | 11 ++-- tests/csgtestcore.cc | 65 +++++++++++++++++--- tests/{cakebaby.py => ctest_pretty_print.py} | 0 4 files changed, 90 insertions(+), 35 deletions(-) rename tests/{cakebaby.py => ctest_pretty_print.py} (100%) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 69664364..69e43a94 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 839eea9f..e2b28e5c 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 034084c7..a6e37475 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -25,8 +25,15 @@ #include #include #include -#include +#include +#include + +#include +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 highlight_terms; + vector highlight_terms; CSGChain *highlights_chain; - std::vector background_terms; + vector 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(); + highlight_terms = vector(); highlights_chain = NULL; - background_terms = std::vector(); + background_terms = vector(); 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 >(), "input file"); + ("output-file", po::value< vector >(), "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 \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 >().begin()->c_str(); + outfilename = vm["output-file"].as< vector >().begin()->c_str(); } - const char *filename = argv[1]; - const char *outfilename = argv[2]; + if (!filename || !outfilename || !sysinfo_dump) { + cerr << "Usage: " << argv[0] << " \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 similarity index 100% rename from tests/cakebaby.py rename to tests/ctest_pretty_print.py