From ab3a36e76b2a6cfacd418a0715d0bb709bd5793e Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 9 Nov 2011 00:46:39 -0600 Subject: first version of 'cakebaby' regression testing display program diff --git a/tests/cakebaby.py b/tests/cakebaby.py new file mode 100755 index 0000000..a58b6bc --- /dev/null +++ b/tests/cakebaby.py @@ -0,0 +1,202 @@ +#!/usr/bin/python +import string,platform,sys,re,os + +wiki_basepath = 'OpenSCAD' +platform = 'ubuntu linux i686'.replace(' ','_') + '_abcd' +logfilename = 'LastTest.log.tmp' +builddir = 'build' +logpath = os.path.join(builddir,'Testing','Temporary',logfilename) +NO_END = False +if logfilename.endswith('.tmp'): NO_END = True + +def readlog(): + try: + print 'reading',logpath + f = open(logpath) + except: + print 'couldnt open ',logpath + return None + + data = f.read() + return data + +class Test: + def __init__(self,fullname,time,passed,output,type,outputfile,expectedfile): + self.fullname,self.time,self.passed,self.output = \ + fullname, time, passed, output + self.type = type + self.outputfile = outputfile + self.expectedfile = expectedfile + + def __str__(self): + x = 'fullname: ' + self.fullname + x+= '\noutputfile: ' + self.outputfile + x+= '\nexpectedfile: ' + self.expectedfile + x+= '\ntesttime: ' + self.time + x+= '\ntesttype: ' + self.type + x+= '\npassfail: ' + self.passfail + x+= '\noutput: \n' + self.output + x+= '\n' + return x + +def gettest_strings(data): + chunks = data.split('----------------------------------------------------------') + print 'read',len(chunks), 'chunks' + if NO_END: + enddate = 'n/a (cancelled)' + chunks.pop() + else: + enddate = chunks.pop().replace('End testing: ','').strip() + chunks.reverse() + startdate = chunks.pop().replace('Start testing: ','').strip() + chunks.reverse() + tests=[] + chunksize = 3 + for i in range(0,len(chunks),chunksize): + testchunks = chunks[i:i+chunksize] + test = string.join(testchunks,'-----') + tests += [test] + #print '----------<<<<<<<<<<<<<<<<' + #print test + #print '----------<<<<<<<<<<<<<<<<' + test = '' + return startdate, tests, enddate, platform + +def parsetest(teststring): + s = teststring + def regex(pat,str): + x=re.search(pat,str,re.DOTALL|re.MULTILINE) + if x: + if len(x.groups())>0: + return x.group(1).strip() + return '' + testfullname = regex("Test:(.*?)\n",s) + testtime = regex("Test time =(.*?)\n",s).replace(' sec','') + passfail = regex("Test time.*?Test (Passed)",s) + command = regex("Command:(.*?)\n",s) + tmp = command.split(' "') + testtype = '' + try: + testtype = tmp[3].strip('"') + except: + print 'failed to parse log', teststring + goodimg = regex("expected image:(.*?)\n",s) + actualimg = regex("actual image:(.*?)\n",s) + if passfail=='Passed': passed = True + else: passed = False + output = regex("Output:(.*?)",s).replace('-----','') + test = Test(testfullname, testtime, passed, output, testtype, actualimg, goodimg ) + return test + +def parse(data): + startdate, test_strs, enddate, platform = gettest_strings(data) + print 'found', len(test_strs),'test results' + tests = [] + for i in range(len(test_strs)): + test = parsetest(test_strs[i]) + tests += [test] + return startdate, tests, enddate, platform + +def towiki(startdate, tests, enddate, platform): + def convert_path(fulltestname,platform,path): + # convert system path name (image file) to wiki path name + testprogram = fulltestname[0:fulltestname.find('_')] + testprogram = testprogram.replace('test','') + filename = os.path.basename(path) + filename = filename.replace('-actual','') + filename = filename.replace('-tests','') + filename = filename.replace('-expected','') + try: + platform = platform[0].upper() + platform[1:] + except: + platform = 'error' + newpath = testprogram + '_' + filename + # must use _ not / b/c of wikinet.org weird name mangling + newpath = wiki_basepath + '_' + platform + '_' + newpath + return newpath + + x=''' +

OpenSCAD test run

+ +platform: PLATFORM + +runtime: STARTDATE to ENDDATE + +Failed tests + +{|TABLESTYLE +! Testname !! expected output !! actual output +|- +| FTESTNAME || [[File:EXPECTEDIMG|thumb|250px]] || [[File:ACTUALIMG|thumb|250px]] +|} + +Passed tests + +{|TABLESTYLE +! Testname +|- +| PTESTNAME +|} + +''' + + repeat1=''' +|- +| FTESTNAME || [[File:EXPECTEDIMG|thumb|250px]] || [[File:ACTUALIMG|thumb|250px]] +''' + + repeat2=''' +|- +| PTESTNAME +''' + + x = x.replace('TABLESTYLE','border=1 cellspacing=0 cellpadding=1 align="center"') + x = x.replace('STARTDATE',startdate) + x = x.replace('ENDDATE',enddate) + x = x.replace('PLATFORM',platform) + + for t in tests: + if t.passed: + tmp = str(repeat2) + tmp = tmp.replace('PTESTNAME',t.fullname) + x = x.replace(repeat2,tmp + repeat2) + else: + tmp = str(repeat1) + tmp = tmp.replace('FTESTNAME',t.fullname) + wiki_imgpath1 = convert_path(t.fullname,'expected',t.expectedfile) + tmp = tmp.replace('EXPECTEDIMG',wiki_imgpath1) + wiki_imgpath2 = convert_path(t.fullname,platform,t.outputfile) + tmp = tmp.replace('ACTUALIMG',wiki_imgpath2) + x = x.replace(repeat1,tmp + repeat1) + + x = x.replace(repeat1,'') + x = x.replace(repeat2,'') + return x + +def testsort(tests): + passed = [] + failed = [] + for t in tests: + if t.passed: passed+=[t] + else: failed +=[t] + return failed+passed + +def save(data,filename): + try: + f=open(filename,'w') + except: + print 'couldnt open ',filename, 'for writing' + return None + print 'writing',len(data),'bytes to',filename + f.write(data) + f.close() + +def main(): + data = readlog() + startdate, tests, enddate, platform = parse(data) + tests = testsort(tests) + out = towiki(startdate, tests, enddate, platform) + save(out, platform+'.wiki') + +main() + diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index 688026e..485a821 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -73,7 +73,9 @@ def compare_png(resultfilename): if not resultfilename: print >> sys.stderr, "Error: OpenSCAD did not generate an image" return False - print >> sys.stderr, 'Yee image compare: ', expectedfilename, ' ', resultfilename + print >> sys.stderr, 'Yee image compare: ' + print >> sys.stderr, ' expected image: ', expectedfilename + print >> sys.stderr, ' actual image: ', resultfilename if execute_and_redirect("./yee_compare", [expectedfilename, resultfilename, "-downsample", "2", "-threshold", "300"], sys.stderr) != 0: return False return True -- cgit v0.10.1 From 3eb466b5a9dcb7507045898efc7ad52226f54782 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sun, 13 Nov 2011 10:39:34 -0600 Subject: add pretty_print step to ctest run. add '-info' option to opencsgtest. 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/cakebaby.py b/tests/cakebaby.py deleted file mode 100755 index a58b6bc..0000000 --- a/tests/cakebaby.py +++ /dev/null @@ -1,202 +0,0 @@ -#!/usr/bin/python -import string,platform,sys,re,os - -wiki_basepath = 'OpenSCAD' -platform = 'ubuntu linux i686'.replace(' ','_') + '_abcd' -logfilename = 'LastTest.log.tmp' -builddir = 'build' -logpath = os.path.join(builddir,'Testing','Temporary',logfilename) -NO_END = False -if logfilename.endswith('.tmp'): NO_END = True - -def readlog(): - try: - print 'reading',logpath - f = open(logpath) - except: - print 'couldnt open ',logpath - return None - - data = f.read() - return data - -class Test: - def __init__(self,fullname,time,passed,output,type,outputfile,expectedfile): - self.fullname,self.time,self.passed,self.output = \ - fullname, time, passed, output - self.type = type - self.outputfile = outputfile - self.expectedfile = expectedfile - - def __str__(self): - x = 'fullname: ' + self.fullname - x+= '\noutputfile: ' + self.outputfile - x+= '\nexpectedfile: ' + self.expectedfile - x+= '\ntesttime: ' + self.time - x+= '\ntesttype: ' + self.type - x+= '\npassfail: ' + self.passfail - x+= '\noutput: \n' + self.output - x+= '\n' - return x - -def gettest_strings(data): - chunks = data.split('----------------------------------------------------------') - print 'read',len(chunks), 'chunks' - if NO_END: - enddate = 'n/a (cancelled)' - chunks.pop() - else: - enddate = chunks.pop().replace('End testing: ','').strip() - chunks.reverse() - startdate = chunks.pop().replace('Start testing: ','').strip() - chunks.reverse() - tests=[] - chunksize = 3 - for i in range(0,len(chunks),chunksize): - testchunks = chunks[i:i+chunksize] - test = string.join(testchunks,'-----') - tests += [test] - #print '----------<<<<<<<<<<<<<<<<' - #print test - #print '----------<<<<<<<<<<<<<<<<' - test = '' - return startdate, tests, enddate, platform - -def parsetest(teststring): - s = teststring - def regex(pat,str): - x=re.search(pat,str,re.DOTALL|re.MULTILINE) - if x: - if len(x.groups())>0: - return x.group(1).strip() - return '' - testfullname = regex("Test:(.*?)\n",s) - testtime = regex("Test time =(.*?)\n",s).replace(' sec','') - passfail = regex("Test time.*?Test (Passed)",s) - command = regex("Command:(.*?)\n",s) - tmp = command.split(' "') - testtype = '' - try: - testtype = tmp[3].strip('"') - except: - print 'failed to parse log', teststring - goodimg = regex("expected image:(.*?)\n",s) - actualimg = regex("actual image:(.*?)\n",s) - if passfail=='Passed': passed = True - else: passed = False - output = regex("Output:(.*?)",s).replace('-----','') - test = Test(testfullname, testtime, passed, output, testtype, actualimg, goodimg ) - return test - -def parse(data): - startdate, test_strs, enddate, platform = gettest_strings(data) - print 'found', len(test_strs),'test results' - tests = [] - for i in range(len(test_strs)): - test = parsetest(test_strs[i]) - tests += [test] - return startdate, tests, enddate, platform - -def towiki(startdate, tests, enddate, platform): - def convert_path(fulltestname,platform,path): - # convert system path name (image file) to wiki path name - testprogram = fulltestname[0:fulltestname.find('_')] - testprogram = testprogram.replace('test','') - filename = os.path.basename(path) - filename = filename.replace('-actual','') - filename = filename.replace('-tests','') - filename = filename.replace('-expected','') - try: - platform = platform[0].upper() + platform[1:] - except: - platform = 'error' - newpath = testprogram + '_' + filename - # must use _ not / b/c of wikinet.org weird name mangling - newpath = wiki_basepath + '_' + platform + '_' + newpath - return newpath - - x=''' -

OpenSCAD test run

- -platform: PLATFORM - -runtime: STARTDATE to ENDDATE - -Failed tests - -{|TABLESTYLE -! Testname !! expected output !! actual output -|- -| FTESTNAME || [[File:EXPECTEDIMG|thumb|250px]] || [[File:ACTUALIMG|thumb|250px]] -|} - -Passed tests - -{|TABLESTYLE -! Testname -|- -| PTESTNAME -|} - -''' - - repeat1=''' -|- -| FTESTNAME || [[File:EXPECTEDIMG|thumb|250px]] || [[File:ACTUALIMG|thumb|250px]] -''' - - repeat2=''' -|- -| PTESTNAME -''' - - x = x.replace('TABLESTYLE','border=1 cellspacing=0 cellpadding=1 align="center"') - x = x.replace('STARTDATE',startdate) - x = x.replace('ENDDATE',enddate) - x = x.replace('PLATFORM',platform) - - for t in tests: - if t.passed: - tmp = str(repeat2) - tmp = tmp.replace('PTESTNAME',t.fullname) - x = x.replace(repeat2,tmp + repeat2) - else: - tmp = str(repeat1) - tmp = tmp.replace('FTESTNAME',t.fullname) - wiki_imgpath1 = convert_path(t.fullname,'expected',t.expectedfile) - tmp = tmp.replace('EXPECTEDIMG',wiki_imgpath1) - wiki_imgpath2 = convert_path(t.fullname,platform,t.outputfile) - tmp = tmp.replace('ACTUALIMG',wiki_imgpath2) - x = x.replace(repeat1,tmp + repeat1) - - x = x.replace(repeat1,'') - x = x.replace(repeat2,'') - return x - -def testsort(tests): - passed = [] - failed = [] - for t in tests: - if t.passed: passed+=[t] - else: failed +=[t] - return failed+passed - -def save(data,filename): - try: - f=open(filename,'w') - except: - print 'couldnt open ',filename, 'for writing' - return None - print 'writing',len(data),'bytes to',filename - f.write(data) - f.close() - -def main(): - data = readlog() - startdate, tests, enddate, platform = parse(data) - tests = testsort(tests) - out = towiki(startdate, tests, enddate, platform) - save(out, platform+'.wiki') - -main() - 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 #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/ctest_pretty_print.py b/tests/ctest_pretty_print.py new file mode 100755 index 0000000..a58b6bc --- /dev/null +++ b/tests/ctest_pretty_print.py @@ -0,0 +1,202 @@ +#!/usr/bin/python +import string,platform,sys,re,os + +wiki_basepath = 'OpenSCAD' +platform = 'ubuntu linux i686'.replace(' ','_') + '_abcd' +logfilename = 'LastTest.log.tmp' +builddir = 'build' +logpath = os.path.join(builddir,'Testing','Temporary',logfilename) +NO_END = False +if logfilename.endswith('.tmp'): NO_END = True + +def readlog(): + try: + print 'reading',logpath + f = open(logpath) + except: + print 'couldnt open ',logpath + return None + + data = f.read() + return data + +class Test: + def __init__(self,fullname,time,passed,output,type,outputfile,expectedfile): + self.fullname,self.time,self.passed,self.output = \ + fullname, time, passed, output + self.type = type + self.outputfile = outputfile + self.expectedfile = expectedfile + + def __str__(self): + x = 'fullname: ' + self.fullname + x+= '\noutputfile: ' + self.outputfile + x+= '\nexpectedfile: ' + self.expectedfile + x+= '\ntesttime: ' + self.time + x+= '\ntesttype: ' + self.type + x+= '\npassfail: ' + self.passfail + x+= '\noutput: \n' + self.output + x+= '\n' + return x + +def gettest_strings(data): + chunks = data.split('----------------------------------------------------------') + print 'read',len(chunks), 'chunks' + if NO_END: + enddate = 'n/a (cancelled)' + chunks.pop() + else: + enddate = chunks.pop().replace('End testing: ','').strip() + chunks.reverse() + startdate = chunks.pop().replace('Start testing: ','').strip() + chunks.reverse() + tests=[] + chunksize = 3 + for i in range(0,len(chunks),chunksize): + testchunks = chunks[i:i+chunksize] + test = string.join(testchunks,'-----') + tests += [test] + #print '----------<<<<<<<<<<<<<<<<' + #print test + #print '----------<<<<<<<<<<<<<<<<' + test = '' + return startdate, tests, enddate, platform + +def parsetest(teststring): + s = teststring + def regex(pat,str): + x=re.search(pat,str,re.DOTALL|re.MULTILINE) + if x: + if len(x.groups())>0: + return x.group(1).strip() + return '' + testfullname = regex("Test:(.*?)\n",s) + testtime = regex("Test time =(.*?)\n",s).replace(' sec','') + passfail = regex("Test time.*?Test (Passed)",s) + command = regex("Command:(.*?)\n",s) + tmp = command.split(' "') + testtype = '' + try: + testtype = tmp[3].strip('"') + except: + print 'failed to parse log', teststring + goodimg = regex("expected image:(.*?)\n",s) + actualimg = regex("actual image:(.*?)\n",s) + if passfail=='Passed': passed = True + else: passed = False + output = regex("Output:(.*?)",s).replace('-----','') + test = Test(testfullname, testtime, passed, output, testtype, actualimg, goodimg ) + return test + +def parse(data): + startdate, test_strs, enddate, platform = gettest_strings(data) + print 'found', len(test_strs),'test results' + tests = [] + for i in range(len(test_strs)): + test = parsetest(test_strs[i]) + tests += [test] + return startdate, tests, enddate, platform + +def towiki(startdate, tests, enddate, platform): + def convert_path(fulltestname,platform,path): + # convert system path name (image file) to wiki path name + testprogram = fulltestname[0:fulltestname.find('_')] + testprogram = testprogram.replace('test','') + filename = os.path.basename(path) + filename = filename.replace('-actual','') + filename = filename.replace('-tests','') + filename = filename.replace('-expected','') + try: + platform = platform[0].upper() + platform[1:] + except: + platform = 'error' + newpath = testprogram + '_' + filename + # must use _ not / b/c of wikinet.org weird name mangling + newpath = wiki_basepath + '_' + platform + '_' + newpath + return newpath + + x=''' +

OpenSCAD test run

+ +platform: PLATFORM + +runtime: STARTDATE to ENDDATE + +Failed tests + +{|TABLESTYLE +! Testname !! expected output !! actual output +|- +| FTESTNAME || [[File:EXPECTEDIMG|thumb|250px]] || [[File:ACTUALIMG|thumb|250px]] +|} + +Passed tests + +{|TABLESTYLE +! Testname +|- +| PTESTNAME +|} + +''' + + repeat1=''' +|- +| FTESTNAME || [[File:EXPECTEDIMG|thumb|250px]] || [[File:ACTUALIMG|thumb|250px]] +''' + + repeat2=''' +|- +| PTESTNAME +''' + + x = x.replace('TABLESTYLE','border=1 cellspacing=0 cellpadding=1 align="center"') + x = x.replace('STARTDATE',startdate) + x = x.replace('ENDDATE',enddate) + x = x.replace('PLATFORM',platform) + + for t in tests: + if t.passed: + tmp = str(repeat2) + tmp = tmp.replace('PTESTNAME',t.fullname) + x = x.replace(repeat2,tmp + repeat2) + else: + tmp = str(repeat1) + tmp = tmp.replace('FTESTNAME',t.fullname) + wiki_imgpath1 = convert_path(t.fullname,'expected',t.expectedfile) + tmp = tmp.replace('EXPECTEDIMG',wiki_imgpath1) + wiki_imgpath2 = convert_path(t.fullname,platform,t.outputfile) + tmp = tmp.replace('ACTUALIMG',wiki_imgpath2) + x = x.replace(repeat1,tmp + repeat1) + + x = x.replace(repeat1,'') + x = x.replace(repeat2,'') + return x + +def testsort(tests): + passed = [] + failed = [] + for t in tests: + if t.passed: passed+=[t] + else: failed +=[t] + return failed+passed + +def save(data,filename): + try: + f=open(filename,'w') + except: + print 'couldnt open ',filename, 'for writing' + return None + print 'writing',len(data),'bytes to',filename + f.write(data) + f.close() + +def main(): + data = readlog() + startdate, tests, enddate, platform = parse(data) + tests = testsort(tests) + out = towiki(startdate, tests, enddate, platform) + save(out, platform+'.wiki') + +main() + -- cgit v0.10.1 From c4231685f6cba5feec8bcec324a3fd884687d56e Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sun, 13 Nov 2011 14:34:01 -0600 Subject: option '--info' to opencsgtest for windows. also output html + wiki code. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 393055b..5723344 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -364,6 +364,7 @@ set(INFOCMD "execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/opencsgtest --i set(PRETTYCMD "\"${PYTHON_EXECUTABLE} ctest_pretty_print.py\"") 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 ") diff --git a/tests/OffscreenContext.cc b/tests/OffscreenContext.cc index e2b28e5..994a74d 100644 --- a/tests/OffscreenContext.cc +++ b/tests/OffscreenContext.cc @@ -44,10 +44,15 @@ See Also #include #include +#include +#include + +#include // for uname + using namespace std; struct OffscreenContext -{ + { GLXContext openGLContext; Display *xdisplay; Window xwindow; @@ -66,6 +71,42 @@ void offscreen_context_init(OffscreenContext &ctx, int width, int height) ctx.fbo = NULL; } +string get_unix_info() +{ + struct utsname u; + stringstream out; + + if (uname(&u) < 0) + out << "OS info: unknown, uname() error\n"; + else { + out << "OS info: " + << u.sysname << " " + << u.release << " " + << u.version << "\n"; + out << "Machine: " << u.machine; + } + return out.str(); +} + +string offscreen_context_getinfo(OffscreenContext *ctx) +{ + assert(ctx); + + if (!ctx->xdisplay) + return string("No GL Context initialized. No information to report\n"); + + int major, minor; + glXQueryVersion(ctx->xdisplay, &major, &minor); + + stringstream out; + out << "GLX version: " << major << "." << minor << "\n"; + out << glew_dump(false); + + out << get_unix_info(); + + return out.str(); +} + static XErrorHandler original_xlib_handler = (XErrorHandler) NULL; static bool XCreateWindow_failed = false; static int XCreateWindow_error(Display *dpy, XErrorEvent *event) @@ -228,7 +269,7 @@ OffscreenContext *create_offscreen_context(int w, int h) cerr << "Unable to init GLEW: " << glewGetErrorString(err) << endl; return NULL; } - glew_dump(); + // cerr << glew_dump(0); /* ctx->fbo = fbo_new(); if (!fbo_init(ctx->fbo, w, h)) { @@ -266,7 +307,7 @@ bool save_framebuffer(OffscreenContext *ctx, const char *filename) int rowBytes = samplesPerPixel * ctx->width; unsigned char *flippedBuffer = (unsigned char *)malloc(rowBytes * ctx->height); if (!flippedBuffer) { - std::cerr << "Unable to allocate flipped buffer for corrected image."; + cerr << "Unable to allocate flipped buffer for corrected image."; return 1; } flip_image(pixels, flippedBuffer, samplesPerPixel, ctx->width, ctx->height); diff --git a/tests/OffscreenContext.h b/tests/OffscreenContext.h index a079c3f..6eebcba 100644 --- a/tests/OffscreenContext.h +++ b/tests/OffscreenContext.h @@ -2,10 +2,12 @@ #define OFFSCREENCONTEXT_H_ #include // for error output +#include struct OffscreenContext *create_offscreen_context(int w, int h); void bind_offscreen_context(OffscreenContext *ctx); bool teardown_offscreen_context(OffscreenContext *ctx); bool save_framebuffer(OffscreenContext *ctx, const char *filename); +std::string offscreen_context_getinfo(OffscreenContext *ctx); #endif diff --git a/tests/OffscreenContext.mm b/tests/OffscreenContext.mm index 140516f..baa39e0 100644 --- a/tests/OffscreenContext.mm +++ b/tests/OffscreenContext.mm @@ -16,6 +16,13 @@ struct OffscreenContext fbo_t *fbo; }; +string offscreen_context_getinfo(OffscreenContext *ctx) +{ + sstream result; + result << "OS info: Mac OSX\n"; + result << "Machine: Apple(TM) Mac(TM)\n"; + return result.str(); +} OffscreenContext *create_offscreen_context(int w, int h) { @@ -94,6 +101,7 @@ bool teardown_offscreen_context(OffscreenContext *ctx) */ bool save_framebuffer(OffscreenContext *ctx, const char *filename) { + if (!ctx || !filename) return false; // Read pixels from OpenGL int samplesPerPixel = 4; // R, G, B and A int rowBytes = samplesPerPixel * ctx->width; diff --git a/tests/OffscreenContextWGL.cc b/tests/OffscreenContextWGL.cc index 3b966e2..1aa99dc 100644 --- a/tests/OffscreenContextWGL.cc +++ b/tests/OffscreenContextWGL.cc @@ -22,6 +22,9 @@ For more info: #include // must be included after glew.h +#include +#include + using namespace std; struct OffscreenContext @@ -44,6 +47,34 @@ void offscreen_context_init(OffscreenContext &ctx, int width, int height) ctx.fbo = NULL; } +string get_windows_info() +{ + OSVERSIONINFO osvi; + + ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osvi); + + SYSTEM_INFO si; + GetSystemInfo(&si); + + stringstream out; + out << "OS info: " + << "Microsoft(TM) Windows(TM) " << osvi.dwMajorVersion << " " + << osvi.dwMinorVersion << " " << osvi.dwBuildNumber << " " + << osvi.szCSDVersion << "\n"; + + out << "Machine: " << si.dwOemID << " " << si.dwProcessorType; +} + +string offscreen_context_getinfo(OffscreenContext *ctx) +{ + stringstream out; + out << glew_dump(false); + out << get_windows_info(); + return result; +} + LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { return DefWindowProc( hwnd, message, wparam, lparam ); @@ -142,7 +173,7 @@ OffscreenContext *create_offscreen_context(int w, int h) cerr << "Unable to init GLEW: " << glewGetErrorString(err) << "\n"; return NULL; } - glew_dump(); + //cerr << glew_dump(0); ctx->fbo = fbo_new(); if (!fbo_init(ctx->fbo, w, h)) { diff --git a/tests/OffscreenView.cc b/tests/OffscreenView.cc index 46951c1..2a4a27e 100644 --- a/tests/OffscreenView.cc +++ b/tests/OffscreenView.cc @@ -249,6 +249,11 @@ bool OffscreenView::save(const char *filename) return save_framebuffer(this->ctx, filename); } +std::string OffscreenView::getInfo() +{ + return offscreen_context_getinfo(this->ctx); +} + void OffscreenView::setCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d ¢er) { this->camera_eye = pos; diff --git a/tests/OffscreenView.h b/tests/OffscreenView.h index e3c8579..2e35921 100644 --- a/tests/OffscreenView.h +++ b/tests/OffscreenView.h @@ -4,6 +4,7 @@ #include "OffscreenContext.h" #include #include +#include #ifndef _MSC_VER #include #endif @@ -22,6 +23,7 @@ public: void setupOrtho(bool offset=false); void paintGL(); bool save(const char *filename); + std::string getInfo(); GLint shaderinfo[11]; OffscreenContext *ctx; diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index a6e3747..5866346 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -76,8 +76,27 @@ AbstractNode *find_root_tag(AbstractNode *n) string info_dump(OffscreenView *glview) { +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) +#ifdef __GNUG__ +#define compiler_info "GCC " << __VERSION__ +#elif defined(_MSC_VER) +#define compiler_info "MSVC " << _MSC_FULL_VER +#else +#define compiler_info "unknown compiler" +#endif + assert(glview); std::stringstream out; - out << "test"; + out << "OpenSCAD info dump:" + << "\nOpenSCAD Year/Month/Day: " << int(OPENSCAD_YEAR) << "." + << int(OPENSCAD_MONTH) << "." +#ifdef OPENSCAD_DAY + << int(OPENSCAD_DAY) +#endif + << "\nOpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION) + << "\nCompiled with: " << compiler_info + << "\nGL Context info: \n" << glview->getInfo() + << "\n"; return out.str(); } @@ -85,22 +104,23 @@ 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"); + ("help,h", "help message")//; + ("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"); +// 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); + p.add("input-file", 1).add("output-file", 1); po::options_description all_options; - all_options.add(desc).add(hidden); + 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); + po::notify(vm); return vm; } @@ -109,14 +129,19 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) { bool sysinfo_dump = false; const char *filename, *outfilename = NULL; - po::variables_map vm = parse_options(argc, argv); + po::variables_map vm; + try { + vm = parse_options(argc, argv); + } catch ( po::error e ) { + cerr << "error parsing options\n"; + } if (vm.count("info")) sysinfo_dump = true; - if (vm.count("input-file") && vm.count("output-file")) { + if (vm.count("input-file")) filename = vm["input-file"].as< vector >().begin()->c_str(); + if (vm.count("output-file")) outfilename = vm["output-file"].as< vector >().begin()->c_str(); - } - if (!filename || !outfilename || !sysinfo_dump) { + if ((!filename || !outfilename) && !sysinfo_dump) { cerr << "Usage: " << argv[0] << " \n"; exit(1); } @@ -154,7 +179,11 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) AbstractModule *root_module; ModuleInstantiation root_inst; - root_module = parsefile(filename); + if (sysinfo_dump) + root_module = parse("sphere();","",false); + else + root_module = parsefile(filename); + if (!root_module) { exit(1); } diff --git a/tests/ctest_pretty_print.py b/tests/ctest_pretty_print.py index a58b6bc..0b81f98 100755 --- a/tests/ctest_pretty_print.py +++ b/tests/ctest_pretty_print.py @@ -2,13 +2,31 @@ import string,platform,sys,re,os wiki_basepath = 'OpenSCAD' -platform = 'ubuntu linux i686'.replace(' ','_') + '_abcd' -logfilename = 'LastTest.log.tmp' -builddir = 'build' +logfilename = 'LastTest.log' +builddir = '.' logpath = os.path.join(builddir,'Testing','Temporary',logfilename) NO_END = False if logfilename.endswith('.tmp'): NO_END = True +def read_sysinfo(): + try: + f=open('sysinfo.txt') + except: + return '' + data=f.read() + machine_str, osplain_str, renderer_str = '','','' + machine = re.search('Machine:(.*?)\n',data) + osinfo = re.search('OS info:(.*?)\n',data) + renderer = re.search('GL Renderer:(.*?)\n',data) + if machine: machine_str = machine.group(1).strip() + if osinfo: osplain_str = osinfo.group(1).strip().split(' ')[0].strip() + if renderer: + tmp = renderer.group(1).strip().split(' ') + renderer_str = string.join(tmp[0:3],'-') + platform = osplain_str + '_' + machine_str + '_' + renderer_str + platform = platform.lower() + return data, platform + def readlog(): try: print 'reading',logpath @@ -60,7 +78,8 @@ def gettest_strings(data): #print test #print '----------<<<<<<<<<<<<<<<<' test = '' - return startdate, tests, enddate, platform + sysinfo, platform = read_sysinfo() + return startdate, tests, enddate, sysinfo, platform def parsetest(teststring): s = teststring @@ -89,15 +108,15 @@ def parsetest(teststring): return test def parse(data): - startdate, test_strs, enddate, platform = gettest_strings(data) + startdate, test_strs, enddate, sysinfo, platform = gettest_strings(data) print 'found', len(test_strs),'test results' tests = [] for i in range(len(test_strs)): test = parsetest(test_strs[i]) tests += [test] - return startdate, tests, enddate, platform + return startdate, tests, enddate, sysinfo, platform -def towiki(startdate, tests, enddate, platform): +def towiki(startdate, tests, enddate, sysinfo, platform): def convert_path(fulltestname,platform,path): # convert system path name (image file) to wiki path name testprogram = fulltestname[0:fulltestname.find('_')] @@ -120,6 +139,11 @@ def towiki(startdate, tests, enddate, platform): platform: PLATFORM +detailed system info: +
+SYSINFO
+
+ runtime: STARTDATE to ENDDATE Failed tests @@ -153,6 +177,7 @@ Passed tests x = x.replace('TABLESTYLE','border=1 cellspacing=0 cellpadding=1 align="center"') x = x.replace('STARTDATE',startdate) x = x.replace('ENDDATE',enddate) + x = x.replace('SYSINFO',sysinfo) x = x.replace('PLATFORM',platform) for t in tests: @@ -173,6 +198,19 @@ Passed tests x = x.replace(repeat2,'') return x +def wikitohtml(data): + # not pretty + data = data.replace('\n\n','\n

\n') + data = re.sub('\{\|.*?\n','\n',data) + data = re.sub('\n\! ','\n\n') + data = re.sub('\n\| ','\n
',data) + data = data.replace(' !! ','') + data = data.replace('|-','
',data) + data = data.replace(' || ','') + data = data.replace('|}','\n
') + data = re.sub('[[File:(.*?)|.*?]]','',data) + return data + def testsort(tests): passed = [] failed = [] @@ -193,10 +231,12 @@ def save(data,filename): def main(): data = readlog() - startdate, tests, enddate, platform = parse(data) + startdate, tests, enddate, sysinfo, platform = parse(data) tests = testsort(tests) - out = towiki(startdate, tests, enddate, platform) - save(out, platform+'.wiki') + wikidata = towiki(startdate, tests, enddate, sysinfo, platform) + htmldata = wikitohtml(wikidata) + save(wikidata, platform+'.wiki') + save(htmldata, platform+'.html') main() diff --git a/tests/system-gl.cc b/tests/system-gl.cc index f95a5ca..2e3f3bc 100644 --- a/tests/system-gl.cc +++ b/tests/system-gl.cc @@ -2,34 +2,40 @@ /* OpenGL helper functions */ #include +#include +#include #include "system-gl.h" #include using namespace std; using namespace boost; -void glew_dump() { - cerr << "GLEW version: " << glewGetString(GLEW_VERSION) << endl - << "Renderer: " << (const char *)glGetString(GL_RENDERER) << endl - << "Vendor: " << (const char *)glGetString(GL_VENDOR) << endl - << "OpenGL version: " << (const char *)glGetString(GL_VERSION) << endl; +string glew_dump(bool dumpall) +{ + stringstream out; + out << "GLEW version: " << glewGetString(GLEW_VERSION) << endl + << "GL Renderer: " << (const char *)glGetString(GL_RENDERER) << endl + << "GL Vendor: " << (const char *)glGetString(GL_VENDOR) << endl + << "OpenGL Version: " << (const char *)glGetString(GL_VERSION) << endl; - bool dumpall = false; + out << "GL Extensions: " << endl; if (dumpall) { string extensions((const char *)glGetString(GL_EXTENSIONS)); replace_all( extensions, " ", "\n " ); - cerr << "Extensions: " << endl << " " << extensions << endl; + out << " " << extensions << endl; } - cerr << " GL_ARB_framebuffer_object: " - << (glewIsSupported("GL_ARB_framebuffer_object") ? "yes" : "no") - << endl - << " GL_EXT_framebuffer_object: " - << (glewIsSupported("GL_EXT_framebuffer_object") ? "yes" : "no") - << endl - << " GL_EXT_packed_depth_stencil: " - << (glewIsSupported("GL_EXT_packed_depth_stencil") ? "yes" : "no") - << endl; + out << "GL_ARB_framebuffer_object: " + << (glewIsSupported("GL_ARB_framebuffer_object") ? "yes" : "no") + << endl + << "GL_EXT_framebuffer_object: " + << (glewIsSupported("GL_EXT_framebuffer_object") ? "yes" : "no") + << endl + << "GL_EXT_packed_depth_stencil: " + << (glewIsSupported("GL_EXT_packed_depth_stencil") ? "yes" : "no") + << endl; + + return out.str(); }; bool report_glerror(const char * function) diff --git a/tests/system-gl.h b/tests/system-gl.h index bb41be5..45d5130 100644 --- a/tests/system-gl.h +++ b/tests/system-gl.h @@ -2,8 +2,9 @@ #define SYSTEMGL_H_ #include +#include -void glew_dump(); +std::string glew_dump(bool dumpall); bool report_glerror(const char *task); #endif -- cgit v0.10.1 From bf564e80595030578e04c235ccdab94b85eca010 Mon Sep 17 00:00:00 2001 From: don bright Date: Sun, 13 Nov 2011 23:13:59 -0600 Subject: windows fixes for pretty printing test results. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5723344..85c4f21 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -75,9 +75,15 @@ if (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") set(BOOST_ROOT "$ENV{MACOSX_DEPLOY_DIR}") endif() +if (WIN32) + set(Boost_USE_STATIC_LIBS TRUE) + set(BOOST_STATIC TRUE) + set(BOOST_THREAD_USE_LIB TRUE) +endif() + #set(Boost_DEBUG TRUE) set(Boost_NO_SYSTEM_PATHS TRUE) -set(Boost_ADDITIONAL_VERSIONS "1.47.0") +set(Boost_ADDITIONAL_VERSIONS "1.47.0" "1.46.0") find_package( Boost 1.35.0 COMPONENTS thread program_options ) if(Boost_FOUND) message(STATUS "Boost includes found: " ${Boost_INCLUDE_DIRS}) diff --git a/tests/OffscreenContextWGL.cc b/tests/OffscreenContextWGL.cc index 1aa99dc..3756a82 100644 --- a/tests/OffscreenContextWGL.cc +++ b/tests/OffscreenContextWGL.cc @@ -22,6 +22,7 @@ For more info: #include // must be included after glew.h +#include #include #include @@ -57,14 +58,24 @@ string get_windows_info() SYSTEM_INFO si; GetSystemInfo(&si); + map archs; + archs[PROCESSOR_ARCHITECTURE_AMD64] = "amd64"; + archs[PROCESSOR_ARCHITECTURE_IA64] = "itanium"; + archs[PROCESSOR_ARCHITECTURE_INTEL] = "x86"; + archs[PROCESSOR_ARCHITECTURE_UNKNOWN] = "unknown"; stringstream out; out << "OS info: " - << "Microsoft(TM) Windows(TM) " << osvi.dwMajorVersion << " " - << osvi.dwMinorVersion << " " << osvi.dwBuildNumber << " " - << osvi.szCSDVersion << "\n"; + << "Microsoft(TM) Windows(TM) " << osvi.dwMajorVersion << " " + << osvi.dwMinorVersion << " " << osvi.dwBuildNumber << " " + << osvi.szCSDVersion; + if (archs.find(si.wProcessorArchitecture) != archs.end()) + out << " " << archs[si.wProcessorArchitecture]; + out << "\n"; - out << "Machine: " << si.dwOemID << " " << si.dwProcessorType; + out << "Machine: " << si.dwProcessorType; + + return out.str(); } string offscreen_context_getinfo(OffscreenContext *ctx) @@ -72,7 +83,7 @@ string offscreen_context_getinfo(OffscreenContext *ctx) stringstream out; out << glew_dump(false); out << get_windows_info(); - return result; + return out.str(); } LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) diff --git a/tests/ctest_pretty_print.py b/tests/ctest_pretty_print.py index 0b81f98..430f106 100755 --- a/tests/ctest_pretty_print.py +++ b/tests/ctest_pretty_print.py @@ -3,7 +3,7 @@ import string,platform,sys,re,os wiki_basepath = 'OpenSCAD' logfilename = 'LastTest.log' -builddir = '.' +builddir = os.getcwd() logpath = os.path.join(builddir,'Testing','Temporary',logfilename) NO_END = False if logfilename.endswith('.tmp'): NO_END = True @@ -18,11 +18,15 @@ def read_sysinfo(): machine = re.search('Machine:(.*?)\n',data) osinfo = re.search('OS info:(.*?)\n',data) renderer = re.search('GL Renderer:(.*?)\n',data) - if machine: machine_str = machine.group(1).strip() - if osinfo: osplain_str = osinfo.group(1).strip().split(' ')[0].strip() + if machine: machine_str = machine.group(1).strip().replace(' ','-').replace('/','-') + if osinfo: + osplain_str = osinfo.group(1).strip().split(' ')[0].strip().replace('/','-') + if 'windows' in osinfo.group(1).lower(): osplain_str = 'win' if renderer: tmp = renderer.group(1).strip().split(' ') - renderer_str = string.join(tmp[0:3],'-') + tmp = string.join(tmp[0:3],'-') + if '/' in tmp: tmp = tmp.split('/')[0] + renderer_str = tmp platform = osplain_str + '_' + machine_str + '_' + renderer_str platform = platform.lower() return data, platform @@ -119,12 +123,11 @@ def parse(data): def towiki(startdate, tests, enddate, sysinfo, platform): def convert_path(fulltestname,platform,path): # convert system path name (image file) to wiki path name - testprogram = fulltestname[0:fulltestname.find('_')] + testprogram = fulltestname[0:fulltestname.rfind('_')] testprogram = testprogram.replace('test','') filename = os.path.basename(path) - filename = filename.replace('-actual','') - filename = filename.replace('-tests','') - filename = filename.replace('-expected','') + filename = filename.replace('-tests-actual.png','.png') + filename = filename.replace('-tests-expected.png','.png') try: platform = platform[0].upper() + platform[1:] except: @@ -144,7 +147,8 @@ detailed system info: SYSINFO -runtime: STARTDATE to ENDDATE +start time: STARTDATE +end time : ENDDATE Failed tests @@ -181,17 +185,25 @@ Passed tests x = x.replace('PLATFORM',platform) for t in tests: + print t.type, t.fullname, t.expectedfile, t.outputfile if t.passed: tmp = str(repeat2) tmp = tmp.replace('PTESTNAME',t.fullname) x = x.replace(repeat2,tmp + repeat2) - else: + elif not t.passed and t.type=='png': tmp = str(repeat1) tmp = tmp.replace('FTESTNAME',t.fullname) + wiki_imgpath1 = convert_path(t.fullname,'expected',t.expectedfile) + if t.type!='png': wiki_imgpath1 = '' + if t.expectedfile=='': wiki_imgpath2 = '' tmp = tmp.replace('EXPECTEDIMG',wiki_imgpath1) + wiki_imgpath2 = convert_path(t.fullname,platform,t.outputfile) + if t.type!='png': wiki_imgpath2 = '' + if t.outputfile=='': wiki_imgpath2 = '' tmp = tmp.replace('ACTUALIMG',wiki_imgpath2) + x = x.replace(repeat1,tmp + repeat1) x = x.replace(repeat1,'') diff --git a/tests/fbo.cc b/tests/fbo.cc index 2a3342d..2f933d7 100644 --- a/tests/fbo.cc +++ b/tests/fbo.cc @@ -93,6 +93,7 @@ bool fbo_ext_init(fbo_t *fbo, size_t width, size_t height) glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, fbo->depthbuf_id); if (report_glerror("specifying depth render buffer EXT")) return false; + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, fbo->depthbuf_id); if (report_glerror("specifying stencil render buffer EXT")) return false; @@ -142,7 +143,8 @@ bool fbo_arb_init(fbo_t *fbo, size_t width, size_t height) return false; } - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, + //glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fbo->depthbuf_id); if (report_glerror("specifying depth stencil render buffer")) return false; @@ -181,21 +183,22 @@ bool fbo_resize(fbo_t *fbo, size_t width, size_t height) { if (use_ext()) { glBindRenderbufferEXT(GL_RENDERBUFFER, fbo->depthbuf_id); - if (glewIsSupported("GL_EXT_packed_depth_stencil")) { + if (0) { // glewIsSupported("GL_EXT_packed_depth_stencil")) { glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); - if (report_glerror("creating depth stencil render buffer")) return false; + if (report_glerror("creating EXT depth stencil render buffer")) return false; } else { glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height); - if (report_glerror("creating depth render buffer")) return false; + if (report_glerror("creating EXT depth render buffer")) return false; } glBindRenderbufferEXT(GL_RENDERBUFFER, fbo->renderbuf_id); glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_RGBA8, width, height); - if (report_glerror("creating color render buffer")) return false; + if (report_glerror("creating EXT color render buffer")) return false; } else { glBindRenderbuffer(GL_RENDERBUFFER, fbo->depthbuf_id); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); + //glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32, width, height); if (report_glerror("creating depth stencil render buffer")) return false; glBindRenderbuffer(GL_RENDERBUFFER, fbo->renderbuf_id); -- cgit v0.10.1 From b6b3e52543696c5d6efd85b4d86fc13abb327518 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 16 Nov 2011 05:58:07 -0600 Subject: add more info to --info dumps. improve wiki output diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 85c4f21..5315c01 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -265,7 +265,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 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" CACHE TYPE STRING) + set(OFFSCREEN_CTX_SOURCE "OffscreenContextGLX.cc" CACHE TYPE STRING) elseif(WIN32) message(STATUS "Offscreen OpenGL Context - using Microsoft WGL") set(OFFSCREEN_CTX_SOURCE "OffscreenContextWGL.cc" CACHE TYPE STRING) @@ -367,16 +367,20 @@ 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(PRETTYCMD "\"${PYTHON_EXECUTABLE} test_pretty_print.py\"") 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 + # set(CTEST_CUSTOM_POST_TEST ${PRETTYCMD})\n # doesn't work. log is written + # after all tests run. ") 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) + +foreach(FILE test_pretty_print.py) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILE} + ${CMAKE_CURRENT_BINARY_DIR}/${FILE} COPYONLY) +endforeach() # Find all scad files file(GLOB MINIMAL_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/minimal/*.scad) diff --git a/tests/OffscreenContext.cc b/tests/OffscreenContext.cc deleted file mode 100644 index 994a74d..0000000 --- a/tests/OffscreenContext.cc +++ /dev/null @@ -1,325 +0,0 @@ -/* - -Create an OpenGL context without creating an OpenGL Window. for Linux. - -See Also - - glxgears.c by Brian Paul from mesa-demos (mesa3d.org) - http://cgit.freedesktop.org/mesa/demos/tree/src/xdemos?id=mesa-demos-8.0.1 - http://www.opengl.org/sdk/docs/man/xhtml/glXIntro.xml - http://www.mesa3d.org/brianp/sig97/offscrn.htm - http://glprogramming.com/blue/ch07.html - OffscreenContext.mm (Mac OSX version) - -*/ - -/* - * Some portions of the code below are: - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "OffscreenContext.h" -#include "printutils.h" -#include "imageutils.h" -#include "system-gl.h" -#include "fbo.h" - -#include -#include - -#include -#include - -#include // for uname - -using namespace std; - -struct OffscreenContext - { - GLXContext openGLContext; - Display *xdisplay; - Window xwindow; - int width; - int height; - fbo_t *fbo; -}; - -void offscreen_context_init(OffscreenContext &ctx, int width, int height) -{ - ctx.width = width; - ctx.height = height; - ctx.openGLContext = NULL; - ctx.xdisplay = NULL; - ctx.xwindow = (Window)NULL; - ctx.fbo = NULL; -} - -string get_unix_info() -{ - struct utsname u; - stringstream out; - - if (uname(&u) < 0) - out << "OS info: unknown, uname() error\n"; - else { - out << "OS info: " - << u.sysname << " " - << u.release << " " - << u.version << "\n"; - out << "Machine: " << u.machine; - } - return out.str(); -} - -string offscreen_context_getinfo(OffscreenContext *ctx) -{ - assert(ctx); - - if (!ctx->xdisplay) - return string("No GL Context initialized. No information to report\n"); - - int major, minor; - glXQueryVersion(ctx->xdisplay, &major, &minor); - - stringstream out; - out << "GLX version: " << major << "." << minor << "\n"; - out << glew_dump(false); - - out << get_unix_info(); - - return out.str(); -} - -static XErrorHandler original_xlib_handler = (XErrorHandler) NULL; -static bool XCreateWindow_failed = false; -static int XCreateWindow_error(Display *dpy, XErrorEvent *event) -{ - cerr << "XCreateWindow failed: XID: " << event->resourceid - << " request: " << (int)event->request_code - << " minor: " << (int)event->minor_code << "\n"; - char description[1024]; - XGetErrorText( dpy, event->error_code, description, 1023 ); - cerr << " error message: " << description << "\n"; - XCreateWindow_failed = true; - return 0; -} - -bool create_glx_dummy_window(OffscreenContext &ctx) -{ - /* - create a dummy X window without showing it. (without 'mapping' it) - and save information to the ctx. - - This purposely does not use glxCreateWindow, to avoid crashes, - "failed to create drawable" errors, and Mesa "WARNING: Application calling - GLX 1.3 function when GLX 1.3 is not supported! This is an application bug!" - - This function will alter ctx.openGLContext and ctx.xwindow if successfull - */ - - int attributes[] = { - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_RED_SIZE, 1, - GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, - GLX_DEPTH_SIZE, 1, - None - }; - - Display *dpy = ctx.xdisplay; - - int num_returned = 0; - GLXFBConfig *fbconfigs = glXChooseFBConfig( dpy, DefaultScreen(dpy), attributes, &num_returned ); - if ( fbconfigs == NULL ) { - cerr << "glXChooseFBConfig failed\n"; - return false; - } - - XVisualInfo *visinfo = glXGetVisualFromFBConfig( dpy, fbconfigs[0] ); - if ( visinfo == NULL ) { - cerr << "glXGetVisualFromFBConfig failed\n"; - XFree( fbconfigs ); - return false; - } - - // can't depend on xWin==NULL at failure. use a custom Xlib error handler instead. - original_xlib_handler = XSetErrorHandler( XCreateWindow_error ); - - Window root = DefaultRootWindow( dpy ); - XSetWindowAttributes xwin_attr; - 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); - xwin_attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; - unsigned long int mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; - - Window xWin = XCreateWindow( dpy, root, 0, 0, width, height, - 0, visinfo->depth, InputOutput, - visinfo->visual, mask, &xwin_attr ); - - // Window xWin = XCreateSimpleWindow( dpy, DefaultRootWindow(dpy), 0,0,42,42, 0,0,0 ); - - - XSync( dpy, false ); - if ( XCreateWindow_failed ) { - XFree( visinfo ); - XFree( fbconfigs ); - return false; - } - XSetErrorHandler( original_xlib_handler ); - - // Most programs would call XMapWindow here. But we don't, to keep the window hidden - XMapWindow( dpy, xWin ); - - GLXContext context = glXCreateNewContext( dpy, fbconfigs[0], GLX_RGBA_TYPE, NULL, True ); - if ( context == NULL ) { - cerr << "glXCreateNewContext failed\n"; - XDestroyWindow( dpy, xWin ); - XFree( visinfo ); - XFree( fbconfigs ); - return false; - } - - //GLXWindow glxWin = glXCreateWindow( dpy, fbconfigs[0], xWin, NULL ); - - if (!glXMakeContextCurrent( dpy, xWin, xWin, context )) { - //if (!glXMakeContextCurrent( dpy, glxWin, glxWin, context )) { - cerr << "glXMakeContextCurrent failed\n"; - glXDestroyContext( dpy, context ); - XDestroyWindow( dpy, xWin ); - XFree( visinfo ); - XFree( fbconfigs ); - return false; - } - - ctx.openGLContext = context; - ctx.xwindow = xWin; - - XFree( visinfo ); - XFree( fbconfigs ); - - return true; -} - - -Bool create_glx_dummy_context(OffscreenContext &ctx) -{ - // This will alter ctx.openGLContext and ctx.xdisplay and ctx.xwindow if successfull - int major; - int minor; - Bool result = False; - - ctx.xdisplay = XOpenDisplay( NULL ); - if ( ctx.xdisplay == NULL ) { - cerr << "Unable to open a connection to the X server\n"; - return False; - } - - // glxQueryVersion is not always reliable. Use it, but then - // also check to see if GLX 1.3 functions exist - - glXQueryVersion(ctx.xdisplay, &major, &minor); - - if ( major==1 && minor<=2 && glXGetVisualFromFBConfig==NULL ) { - cerr << "Error: GLX version 1.3 functions missing. " - << "Your GLX version: " << major << "." << minor << endl; - } else { - result = create_glx_dummy_window(ctx); - } - - if (!result) XCloseDisplay( ctx.xdisplay ); - return result; -} - -OffscreenContext *create_offscreen_context(int w, int h) -{ - OffscreenContext *ctx = new OffscreenContext; - offscreen_context_init( *ctx, w, h ); - - // before an FBO can be setup, a GLX context must be created - // this call alters ctx->xDisplay and ctx->openGLContext - // and ctx->xwindow if successfull - if (!create_glx_dummy_context( *ctx )) { - return NULL; - } - - // glewInit must come after Context creation and before FBO calls. - GLenum err = glewInit(); - if (GLEW_OK != err) { - cerr << "Unable to init GLEW: " << glewGetErrorString(err) << endl; - return NULL; - } - // cerr << glew_dump(0); - -/* 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; -} - -bool teardown_offscreen_context(OffscreenContext *ctx) -{ - if (ctx) { - fbo_unbind(ctx->fbo); - fbo_delete(ctx->fbo); - XDestroyWindow( ctx->xdisplay, ctx->xwindow ); - glXDestroyContext( ctx->xdisplay, ctx->openGLContext ); - XCloseDisplay( ctx->xdisplay ); - return true; - } - return false; -} - -/*! - Capture framebuffer from OpenGL and write it to the given filename as PNG. -*/ -bool save_framebuffer(OffscreenContext *ctx, const char *filename) -{ - if (!ctx || !filename) return false; - int samplesPerPixel = 4; // R, G, B and A - GLubyte pixels[ctx->width * ctx->height * samplesPerPixel]; - glReadPixels(0, 0, ctx->width, ctx->height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); - - // Flip it vertically - images read from OpenGL buffers are upside-down - int rowBytes = samplesPerPixel * ctx->width; - unsigned char *flippedBuffer = (unsigned char *)malloc(rowBytes * ctx->height); - if (!flippedBuffer) { - cerr << "Unable to allocate flipped buffer for corrected image."; - return 1; - } - flip_image(pixels, flippedBuffer, samplesPerPixel, ctx->width, ctx->height); - - bool writeok = write_png(filename, flippedBuffer, ctx->width, ctx->height); - - free(flippedBuffer); - - return writeok; -} - -void bind_offscreen_context(OffscreenContext *ctx) -{ - if (ctx) fbo_bind(ctx->fbo); -} diff --git a/tests/OffscreenContext.mm b/tests/OffscreenContext.mm index baa39e0..7d95481 100644 --- a/tests/OffscreenContext.mm +++ b/tests/OffscreenContext.mm @@ -18,10 +18,11 @@ struct OffscreenContext string offscreen_context_getinfo(OffscreenContext *ctx) { - sstream result; - result << "OS info: Mac OSX\n"; - result << "Machine: Apple(TM) Mac(TM)\n"; - return result.str(); + stringstream out; + out << "GL context creator: Cocoa / CGL\n" + << "OS info: Mac OSX\n" + << "Machine: Apple(TM) Mac(TM)\n"; + return out.str(); } OffscreenContext *create_offscreen_context(int w, int h) diff --git a/tests/OffscreenContextGLX.cc b/tests/OffscreenContextGLX.cc new file mode 100644 index 0000000..ed9ef46 --- /dev/null +++ b/tests/OffscreenContextGLX.cc @@ -0,0 +1,324 @@ +/* + +Create an OpenGL context without creating an OpenGL Window. for Linux. + +See Also + + glxgears.c by Brian Paul from mesa-demos (mesa3d.org) + http://cgit.freedesktop.org/mesa/demos/tree/src/xdemos?id=mesa-demos-8.0.1 + http://www.opengl.org/sdk/docs/man/xhtml/glXIntro.xml + http://www.mesa3d.org/brianp/sig97/offscrn.htm + http://glprogramming.com/blue/ch07.html + OffscreenContext.mm (Mac OSX version) + +*/ + +/* + * Some portions of the code below are: + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "OffscreenContext.h" +#include "printutils.h" +#include "imageutils.h" +#include "system-gl.h" +#include "fbo.h" + +#include +#include + +#include +#include + +#include // for uname + +using namespace std; + +struct OffscreenContext +{ + GLXContext openGLContext; + Display *xdisplay; + Window xwindow; + int width; + int height; + fbo_t *fbo; +}; + +void offscreen_context_init(OffscreenContext &ctx, int width, int height) +{ + ctx.width = width; + ctx.height = height; + ctx.openGLContext = NULL; + ctx.xdisplay = NULL; + ctx.xwindow = (Window)NULL; + ctx.fbo = NULL; +} + +string get_os_info() +{ + struct utsname u; + stringstream out; + + if (uname(&u) < 0) + out << "OS info: unknown, uname() error\n"; + else { + out << "OS info: " + << u.sysname << " " + << u.release << " " + << u.version << "\n"; + out << "Machine: " << u.machine; + } + return out.str(); +} + +string offscreen_context_getinfo(OffscreenContext *ctx) +{ + assert(ctx); + + if (!ctx->xdisplay) + return string("No GL Context initialized. No information to report\n"); + + int major, minor; + glXQueryVersion(ctx->xdisplay, &major, &minor); + + stringstream out; + out << "GL context creator: GLX\n" + << "GLX version: " << major << "." << minor << "\n" + << get_os_info(); + + return out.str(); +} + +static XErrorHandler original_xlib_handler = (XErrorHandler) NULL; +static bool XCreateWindow_failed = false; +static int XCreateWindow_error(Display *dpy, XErrorEvent *event) +{ + cerr << "XCreateWindow failed: XID: " << event->resourceid + << " request: " << (int)event->request_code + << " minor: " << (int)event->minor_code << "\n"; + char description[1024]; + XGetErrorText( dpy, event->error_code, description, 1023 ); + cerr << " error message: " << description << "\n"; + XCreateWindow_failed = true; + return 0; +} + +bool create_glx_dummy_window(OffscreenContext &ctx) +{ + /* + create a dummy X window without showing it. (without 'mapping' it) + and save information to the ctx. + + This purposely does not use glxCreateWindow, to avoid crashes, + "failed to create drawable" errors, and Mesa "WARNING: Application calling + GLX 1.3 function when GLX 1.3 is not supported! This is an application bug!" + + This function will alter ctx.openGLContext and ctx.xwindow if successfull + */ + + int attributes[] = { + GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_DEPTH_SIZE, 1, + None + }; + + Display *dpy = ctx.xdisplay; + + int num_returned = 0; + GLXFBConfig *fbconfigs = glXChooseFBConfig( dpy, DefaultScreen(dpy), attributes, &num_returned ); + if ( fbconfigs == NULL ) { + cerr << "glXChooseFBConfig failed\n"; + return false; + } + + XVisualInfo *visinfo = glXGetVisualFromFBConfig( dpy, fbconfigs[0] ); + if ( visinfo == NULL ) { + cerr << "glXGetVisualFromFBConfig failed\n"; + XFree( fbconfigs ); + return false; + } + + // can't depend on xWin==NULL at failure. use a custom Xlib error handler instead. + original_xlib_handler = XSetErrorHandler( XCreateWindow_error ); + + Window root = DefaultRootWindow( dpy ); + XSetWindowAttributes xwin_attr; + 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); + xwin_attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + unsigned long int mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + + Window xWin = XCreateWindow( dpy, root, 0, 0, width, height, + 0, visinfo->depth, InputOutput, + visinfo->visual, mask, &xwin_attr ); + + // Window xWin = XCreateSimpleWindow( dpy, DefaultRootWindow(dpy), 0,0,42,42, 0,0,0 ); + + + XSync( dpy, false ); + if ( XCreateWindow_failed ) { + XFree( visinfo ); + XFree( fbconfigs ); + return false; + } + XSetErrorHandler( original_xlib_handler ); + + // Most programs would call XMapWindow here. But we don't, to keep the window hidden + XMapWindow( dpy, xWin ); + + GLXContext context = glXCreateNewContext( dpy, fbconfigs[0], GLX_RGBA_TYPE, NULL, True ); + if ( context == NULL ) { + cerr << "glXCreateNewContext failed\n"; + XDestroyWindow( dpy, xWin ); + XFree( visinfo ); + XFree( fbconfigs ); + return false; + } + + //GLXWindow glxWin = glXCreateWindow( dpy, fbconfigs[0], xWin, NULL ); + + if (!glXMakeContextCurrent( dpy, xWin, xWin, context )) { + //if (!glXMakeContextCurrent( dpy, glxWin, glxWin, context )) { + cerr << "glXMakeContextCurrent failed\n"; + glXDestroyContext( dpy, context ); + XDestroyWindow( dpy, xWin ); + XFree( visinfo ); + XFree( fbconfigs ); + return false; + } + + ctx.openGLContext = context; + ctx.xwindow = xWin; + + XFree( visinfo ); + XFree( fbconfigs ); + + return true; +} + + +Bool create_glx_dummy_context(OffscreenContext &ctx) +{ + // This will alter ctx.openGLContext and ctx.xdisplay and ctx.xwindow if successfull + int major; + int minor; + Bool result = False; + + ctx.xdisplay = XOpenDisplay( NULL ); + if ( ctx.xdisplay == NULL ) { + cerr << "Unable to open a connection to the X server\n"; + return False; + } + + // glxQueryVersion is not always reliable. Use it, but then + // also check to see if GLX 1.3 functions exist + + glXQueryVersion(ctx.xdisplay, &major, &minor); + + if ( major==1 && minor<=2 && glXGetVisualFromFBConfig==NULL ) { + cerr << "Error: GLX version 1.3 functions missing. " + << "Your GLX version: " << major << "." << minor << endl; + } else { + result = create_glx_dummy_window(ctx); + } + + if (!result) XCloseDisplay( ctx.xdisplay ); + return result; +} + +OffscreenContext *create_offscreen_context(int w, int h) +{ + OffscreenContext *ctx = new OffscreenContext; + offscreen_context_init( *ctx, w, h ); + + // before an FBO can be setup, a GLX context must be created + // this call alters ctx->xDisplay and ctx->openGLContext + // and ctx->xwindow if successfull + if (!create_glx_dummy_context( *ctx )) { + return NULL; + } + + // glewInit must come after Context creation and before FBO calls. + GLenum err = glewInit(); + if (GLEW_OK != err) { + cerr << "Unable to init GLEW: " << glewGetErrorString(err) << endl; + return NULL; + } + // cerr << glew_dump(0); + +/* 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; +} + +bool teardown_offscreen_context(OffscreenContext *ctx) +{ + if (ctx) { + fbo_unbind(ctx->fbo); + fbo_delete(ctx->fbo); + XDestroyWindow( ctx->xdisplay, ctx->xwindow ); + glXDestroyContext( ctx->xdisplay, ctx->openGLContext ); + XCloseDisplay( ctx->xdisplay ); + return true; + } + return false; +} + +/*! + Capture framebuffer from OpenGL and write it to the given filename as PNG. +*/ +bool save_framebuffer(OffscreenContext *ctx, const char *filename) +{ + if (!ctx || !filename) return false; + int samplesPerPixel = 4; // R, G, B and A + GLubyte pixels[ctx->width * ctx->height * samplesPerPixel]; + glReadPixels(0, 0, ctx->width, ctx->height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + + // Flip it vertically - images read from OpenGL buffers are upside-down + int rowBytes = samplesPerPixel * ctx->width; + unsigned char *flippedBuffer = (unsigned char *)malloc(rowBytes * ctx->height); + if (!flippedBuffer) { + cerr << "Unable to allocate flipped buffer for corrected image."; + return 1; + } + flip_image(pixels, flippedBuffer, samplesPerPixel, ctx->width, ctx->height); + + bool writeok = write_png(filename, flippedBuffer, ctx->width, ctx->height); + + free(flippedBuffer); + + return writeok; +} + +void bind_offscreen_context(OffscreenContext *ctx) +{ + if (ctx) fbo_bind(ctx->fbo); +} diff --git a/tests/OffscreenContextWGL.cc b/tests/OffscreenContextWGL.cc index 3756a82..4deaf2a 100644 --- a/tests/OffscreenContextWGL.cc +++ b/tests/OffscreenContextWGL.cc @@ -48,7 +48,7 @@ void offscreen_context_init(OffscreenContext &ctx, int width, int height) ctx.fbo = NULL; } -string get_windows_info() +string get_os_info() { OSVERSIONINFO osvi; @@ -81,8 +81,8 @@ string get_windows_info() string offscreen_context_getinfo(OffscreenContext *ctx) { stringstream out; - out << glew_dump(false); - out << get_windows_info(); + out << "GL context creator: WGL\n" + << get_windows_info(); return out.str(); } diff --git a/tests/OffscreenView.cc b/tests/OffscreenView.cc index 2a4a27e..9c8964c 100644 --- a/tests/OffscreenView.cc +++ b/tests/OffscreenView.cc @@ -1,11 +1,13 @@ #include #include "OffscreenView.h" +#include "system-gl.h" #include #include "renderer.h" #include #include #include #include +#include #define FAR_FAR_AWAY 100000.0 @@ -17,19 +19,6 @@ OffscreenView::OffscreenView(size_t width, size_t height) this->ctx = create_offscreen_context(width, height); if ( this->ctx == NULL ) throw -1; -#ifdef DEBUG - GLint rbits, gbits, bbits, abits, dbits, sbits; - glGetIntegerv(GL_RED_BITS, &rbits); - glGetIntegerv(GL_GREEN_BITS, &gbits); - glGetIntegerv(GL_BLUE_BITS, &bbits); - glGetIntegerv(GL_ALPHA_BITS, &abits); - glGetIntegerv(GL_DEPTH_BITS, &dbits); - glGetIntegerv(GL_STENCIL_BITS, &sbits); - - fprintf(stderr, "FBO: RGBA(%d%d%d%d), depth(%d), stencil(%d)\n", - rbits, gbits, bbits, abits, dbits, sbits); -#endif - initializeGL(); resizeGL(width, height); } @@ -251,7 +240,22 @@ bool OffscreenView::save(const char *filename) std::string OffscreenView::getInfo() { - return offscreen_context_getinfo(this->ctx); + std::stringstream out; + GLint rbits, gbits, bbits, abits, dbits, sbits; + glGetIntegerv(GL_RED_BITS, &rbits); + glGetIntegerv(GL_GREEN_BITS, &gbits); + glGetIntegerv(GL_BLUE_BITS, &bbits); + glGetIntegerv(GL_ALPHA_BITS, &abits); + glGetIntegerv(GL_DEPTH_BITS, &dbits); + glGetIntegerv(GL_STENCIL_BITS, &sbits); + + out << glew_dump(false) + << "FBO: RGBA(" << rbits << gbits << bbits << abits + << "), depth(" << dbits + << "), stencil(" << sbits << ")\n" + << offscreen_context_getinfo(this->ctx); + + return out.str(); } void OffscreenView::setCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d ¢er) diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 5866346..9511688 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -76,8 +76,8 @@ AbstractNode *find_root_tag(AbstractNode *n) string info_dump(OffscreenView *glview) { -#define STRINGIFY(x) #x -#define TOSTRING(x) STRINGIFY(x) + assert(glview); + #ifdef __GNUG__ #define compiler_info "GCC " << __VERSION__ #elif defined(_MSC_VER) @@ -85,18 +85,26 @@ string info_dump(OffscreenView *glview) #else #define compiler_info "unknown compiler" #endif - assert(glview); + std::stringstream out; out << "OpenSCAD info dump:" - << "\nOpenSCAD Year/Month/Day: " << int(OPENSCAD_YEAR) << "." - << int(OPENSCAD_MONTH) << "." + << "\nOpenSCAD Year/Month/Day: " << int(OPENSCAD_YEAR) << "." + << int(OPENSCAD_MONTH) << "." #ifdef OPENSCAD_DAY - << int(OPENSCAD_DAY) + << int(OPENSCAD_DAY); #endif - << "\nOpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION) - << "\nCompiled with: " << compiler_info - << "\nGL Context info: \n" << glview->getInfo() - << "\n"; +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + << "\nOpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION) + << "\nCompiled by: " << compiler_info + << "\nBoost version: " << BOOST_LIB_VERSION + << "\nEigen version: " << EIGEN_WORLD_VERSION << "." + << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION + // << "\nCGAL version: " << CGAL_VERSION ??? + // << "\nOpenCSG" << ??? + << "\n" << glview->getInfo() + << "\n"; + return out.str(); } diff --git a/tests/ctest_pretty_print.py b/tests/ctest_pretty_print.py deleted file mode 100755 index 430f106..0000000 --- a/tests/ctest_pretty_print.py +++ /dev/null @@ -1,254 +0,0 @@ -#!/usr/bin/python -import string,platform,sys,re,os - -wiki_basepath = 'OpenSCAD' -logfilename = 'LastTest.log' -builddir = os.getcwd() -logpath = os.path.join(builddir,'Testing','Temporary',logfilename) -NO_END = False -if logfilename.endswith('.tmp'): NO_END = True - -def read_sysinfo(): - try: - f=open('sysinfo.txt') - except: - return '' - data=f.read() - machine_str, osplain_str, renderer_str = '','','' - machine = re.search('Machine:(.*?)\n',data) - osinfo = re.search('OS info:(.*?)\n',data) - renderer = re.search('GL Renderer:(.*?)\n',data) - if machine: machine_str = machine.group(1).strip().replace(' ','-').replace('/','-') - if osinfo: - osplain_str = osinfo.group(1).strip().split(' ')[0].strip().replace('/','-') - if 'windows' in osinfo.group(1).lower(): osplain_str = 'win' - if renderer: - tmp = renderer.group(1).strip().split(' ') - tmp = string.join(tmp[0:3],'-') - if '/' in tmp: tmp = tmp.split('/')[0] - renderer_str = tmp - platform = osplain_str + '_' + machine_str + '_' + renderer_str - platform = platform.lower() - return data, platform - -def readlog(): - try: - print 'reading',logpath - f = open(logpath) - except: - print 'couldnt open ',logpath - return None - - data = f.read() - return data - -class Test: - def __init__(self,fullname,time,passed,output,type,outputfile,expectedfile): - self.fullname,self.time,self.passed,self.output = \ - fullname, time, passed, output - self.type = type - self.outputfile = outputfile - self.expectedfile = expectedfile - - def __str__(self): - x = 'fullname: ' + self.fullname - x+= '\noutputfile: ' + self.outputfile - x+= '\nexpectedfile: ' + self.expectedfile - x+= '\ntesttime: ' + self.time - x+= '\ntesttype: ' + self.type - x+= '\npassfail: ' + self.passfail - x+= '\noutput: \n' + self.output - x+= '\n' - return x - -def gettest_strings(data): - chunks = data.split('----------------------------------------------------------') - print 'read',len(chunks), 'chunks' - if NO_END: - enddate = 'n/a (cancelled)' - chunks.pop() - else: - enddate = chunks.pop().replace('End testing: ','').strip() - chunks.reverse() - startdate = chunks.pop().replace('Start testing: ','').strip() - chunks.reverse() - tests=[] - chunksize = 3 - for i in range(0,len(chunks),chunksize): - testchunks = chunks[i:i+chunksize] - test = string.join(testchunks,'-----') - tests += [test] - #print '----------<<<<<<<<<<<<<<<<' - #print test - #print '----------<<<<<<<<<<<<<<<<' - test = '' - sysinfo, platform = read_sysinfo() - return startdate, tests, enddate, sysinfo, platform - -def parsetest(teststring): - s = teststring - def regex(pat,str): - x=re.search(pat,str,re.DOTALL|re.MULTILINE) - if x: - if len(x.groups())>0: - return x.group(1).strip() - return '' - testfullname = regex("Test:(.*?)\n",s) - testtime = regex("Test time =(.*?)\n",s).replace(' sec','') - passfail = regex("Test time.*?Test (Passed)",s) - command = regex("Command:(.*?)\n",s) - tmp = command.split(' "') - testtype = '' - try: - testtype = tmp[3].strip('"') - except: - print 'failed to parse log', teststring - goodimg = regex("expected image:(.*?)\n",s) - actualimg = regex("actual image:(.*?)\n",s) - if passfail=='Passed': passed = True - else: passed = False - output = regex("Output:(.*?)",s).replace('-----','') - test = Test(testfullname, testtime, passed, output, testtype, actualimg, goodimg ) - return test - -def parse(data): - startdate, test_strs, enddate, sysinfo, platform = gettest_strings(data) - print 'found', len(test_strs),'test results' - tests = [] - for i in range(len(test_strs)): - test = parsetest(test_strs[i]) - tests += [test] - return startdate, tests, enddate, sysinfo, platform - -def towiki(startdate, tests, enddate, sysinfo, platform): - def convert_path(fulltestname,platform,path): - # convert system path name (image file) to wiki path name - testprogram = fulltestname[0:fulltestname.rfind('_')] - testprogram = testprogram.replace('test','') - filename = os.path.basename(path) - filename = filename.replace('-tests-actual.png','.png') - filename = filename.replace('-tests-expected.png','.png') - try: - platform = platform[0].upper() + platform[1:] - except: - platform = 'error' - newpath = testprogram + '_' + filename - # must use _ not / b/c of wikinet.org weird name mangling - newpath = wiki_basepath + '_' + platform + '_' + newpath - return newpath - - x=''' -

OpenSCAD test run

- -platform: PLATFORM - -detailed system info: -
-SYSINFO
-
- -start time: STARTDATE -end time : ENDDATE - -Failed tests - -{|TABLESTYLE -! Testname !! expected output !! actual output -|- -| FTESTNAME || [[File:EXPECTEDIMG|thumb|250px]] || [[File:ACTUALIMG|thumb|250px]] -|} - -Passed tests - -{|TABLESTYLE -! Testname -|- -| PTESTNAME -|} - -''' - - repeat1=''' -|- -| FTESTNAME || [[File:EXPECTEDIMG|thumb|250px]] || [[File:ACTUALIMG|thumb|250px]] -''' - - repeat2=''' -|- -| PTESTNAME -''' - - x = x.replace('TABLESTYLE','border=1 cellspacing=0 cellpadding=1 align="center"') - x = x.replace('STARTDATE',startdate) - x = x.replace('ENDDATE',enddate) - x = x.replace('SYSINFO',sysinfo) - x = x.replace('PLATFORM',platform) - - for t in tests: - print t.type, t.fullname, t.expectedfile, t.outputfile - if t.passed: - tmp = str(repeat2) - tmp = tmp.replace('PTESTNAME',t.fullname) - x = x.replace(repeat2,tmp + repeat2) - elif not t.passed and t.type=='png': - tmp = str(repeat1) - tmp = tmp.replace('FTESTNAME',t.fullname) - - wiki_imgpath1 = convert_path(t.fullname,'expected',t.expectedfile) - if t.type!='png': wiki_imgpath1 = '' - if t.expectedfile=='': wiki_imgpath2 = '' - tmp = tmp.replace('EXPECTEDIMG',wiki_imgpath1) - - wiki_imgpath2 = convert_path(t.fullname,platform,t.outputfile) - if t.type!='png': wiki_imgpath2 = '' - if t.outputfile=='': wiki_imgpath2 = '' - tmp = tmp.replace('ACTUALIMG',wiki_imgpath2) - - x = x.replace(repeat1,tmp + repeat1) - - x = x.replace(repeat1,'') - x = x.replace(repeat2,'') - return x - -def wikitohtml(data): - # not pretty - data = data.replace('\n\n','\n

\n') - data = re.sub('\{\|.*?\n','\n',data) - data = re.sub('\n\! ','\n\n') - data = re.sub('\n\| ','\n
',data) - data = data.replace(' !! ','') - data = data.replace('|-','
',data) - data = data.replace(' || ','') - data = data.replace('|}','\n
') - data = re.sub('[[File:(.*?)|.*?]]','',data) - return data - -def testsort(tests): - passed = [] - failed = [] - for t in tests: - if t.passed: passed+=[t] - else: failed +=[t] - return failed+passed - -def save(data,filename): - try: - f=open(filename,'w') - except: - print 'couldnt open ',filename, 'for writing' - return None - print 'writing',len(data),'bytes to',filename - f.write(data) - f.close() - -def main(): - data = readlog() - startdate, tests, enddate, sysinfo, platform = parse(data) - tests = testsort(tests) - wikidata = towiki(startdate, tests, enddate, sysinfo, platform) - htmldata = wikitohtml(wikidata) - save(wikidata, platform+'.wiki') - save(htmldata, platform+'.html') - -main() - diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index 485a821..3e9f45a 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -64,17 +64,20 @@ def compare_text(expected, actual): return get_normalized_text(expected) == get_normalized_text(actual) def compare_default(resultfilename): + print >> sys.stderr, 'diff text compare: ' + print >> sys.stderr, ' expected textfile: ', expectedfilename + print >> sys.stderr, ' actual textfile: ', resultfilename if not compare_text(expectedfilename, resultfilename): execute_and_redirect("diff", [expectedfilename, resultfilename], sys.stderr) return False return True def compare_png(resultfilename): + print >> sys.stderr, 'Yee image compare:' + print >> sys.stderr, ' expected image: ', expectedfilename if not resultfilename: - print >> sys.stderr, "Error: OpenSCAD did not generate an image" + print >> sys.stderr, "Error: OpenSCAD did not generate an image to test" return False - print >> sys.stderr, 'Yee image compare: ' - print >> sys.stderr, ' expected image: ', expectedfilename print >> sys.stderr, ' actual image: ', resultfilename if execute_and_redirect("./yee_compare", [expectedfilename, resultfilename, "-downsample", "2", "-threshold", "300"], sys.stderr) != 0: return False diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py new file mode 100755 index 0000000..6bc3f54 --- /dev/null +++ b/tests/test_pretty_print.py @@ -0,0 +1,266 @@ +#!/usr/bin/python +# +# this program reads the ctest logfiles from builddir/Testing/Temporary +# and generates two 'pretty printed' outputs in that directory: +# +# 1. mediawiki format, for uploading to a wiki. +# automated uploading is available by following these steps: +# +# download mwclient +# python ctest_pretty_print.py --upload +# +# 2. html format, for easy local viewing +# +# sysinfo.txt: +# sysinfo.txt should have been created by ctest by the main test run. +# it is the output of opencsgtest --info + + +# todo +# 1. add sysinfo about ... git branch +# 2. consolidate image flip +# 3. uploading, can it be done in one file +# 4. consolidate pretty print + +import string,sys,re,os,hashlib,subprocess + +def tryread(filename): + data = None + try: + print 'reading', filename + f = open(filename) + data = f.read() + f.close() + except: + print 'couldn\'t open ',filename + return data + +def trysave(data,filename): + try: + f=open(filename,'w') + print 'writing',len(data),'bytes to',filename + f.write(data) + f.close() + except: + print 'problem writing to',filename + return None + return True + +def ezsearch(pattern,str): + x = re.search(pattern,str,re.DOTALL|re.MULTILINE) + if x and len(x.groups())>0: return x.group(1).strip() + return '' + +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' + return out + +def read_sysinfo(filename): + data = tryread(filename) + if not data: return 'sysinfo: unknown' + + machine = ezsearch('Machine:(.*?)\n',data) + machine = machine.replace(' ','-').replace('/','-') + + osinfo = ezsearch('OS info:(.*?)\n',data) + osplain = osinfo.split(' ')[0].strip().replace('/','-') + if 'windows' in osinfo.lower(): osplain = 'win' + + renderer = ezsearch('GL Renderer:(.*?)\n',data) + tmp = renderer.split(' ') + tmp = string.join(tmp[0:3],'-') + tmp = tmp.split('/')[0] + renderer = tmp + + hasher = hashlib.md5() + hasher.update(data) + hexhash = hasher.hexdigest()[-4:].upper() + # make all letters for aesthetic reasons + hash = '' + for c in hexhash: hash += chr(ord(c)+97-48) + + sysid = osplain + '_' + machine + '_' + renderer + '_' + hash + sysid = sysid.lower() + + data += read_gitinfo() + + return data, sysid + +class Test: + def __init__(self,fullname,time,passed,output,type,actualfile,expectedfile,scadfile): + self.fullname,self.time,self.passed,self.output = \ + fullname, time, passed, output + self.type, self.actualfile, self.expectedfile, self.scadfile = \ + type, actualfile, expectedfile, scadfile + + def __str__(self): + x = 'fullname: ' + self.fullname + x+= '\nactualfile: ' + self.actualfile + x+= '\nexpectedfile: ' + self.expectedfile + x+= '\ntesttime: ' + self.time + x+= '\ntesttype: ' + self.type + x+= '\npassed: ' + str(self.passed) + x+= '\nscadfile: ' + self.scadfile + x+= '\noutput bytes: ' + str(len(self.output)) + x+= '\n' + return x + +def parsetest(teststring): + patterns = ["Test:(.*?)\n", # fullname + "Test time =(.*?) sec\n", + "Test time.*?Test (Passed)", + "Output:(.*?)", + 'Command:.*?-s" "(.*?)"', # type + "actual .*?:(.*?)\n", + "expected .*?:(.*?)\n", + 'Command:.*?(testdata.*?)"' # scadfile + ] + hits = map( lambda pattern: ezsearch(pattern,teststring), patterns ) + test = Test(hits[0],hits[1],hits[2]=='Passed',hits[3],hits[4],hits[5],hits[6],hits[7]) + return test + +def parselog(data): + startdate = ezsearch('Start testing: (.*?)\n',data) + enddate = ezsearch('End testing: (.*?)\n',data) + pattern = '([0-9]*/[0-9]* Testing:.*?time elapsed.*?\n)' + test_chunks = re.findall(pattern,data,re.S) + tests = map( parsetest, test_chunks ) + print 'found', len(tests),'test results' + return startdate, tests, enddate + +def wikify_filename(testname,filename,sysid): + # translate from local system to wiki style filename. + result = wiki_rootpath+'_'+testname+'_' + expected = ezsearch('(expected....$)',filename) + if expected!='': result += expected + actual = ezsearch(os.sep+'.*?-output.*?(actual.*)',filename) + if actual!='': + result += sysid+'_'+actual + return result.replace('/','_') + + +def towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog): + wiki_template = ''' +

OpenSCAD test run

+ +sysid: SYSID + +detailed system info: +
+SYSINFO
+
+ +start time: STARTDATE +end time : ENDDATE + +Failed image tests + +{|border=1 cellspacing=0 cellpadding=1 align="center" +! Testname !! expected output !! actual output + +|- +| FTESTNAME || [[File:EXPECTEDFILE|thumb|250px]] || ACTUALFILE_WIKI + +|} + +Failed text tests (see test log, below, for diff output) + +{|border=1 cellspacing=0 cellpadding=1 align="center" + +|- +| FTESTNAME + +|} + +Passed tests + +{|border=1 cellspacing=0 cellpadding=1 align="center" +! Testname + +|- +| PTESTNAME + +|} + +LastTest.log + +
+LASTTESTLOG
+
+ +''' + manifest = {} + s = wiki_template + repeat1 = ezsearch('(.*?)',s) + repeat2 = ezsearch('(.*?)',s) + repeat3 = ezsearch('(.*?)',s) + dic = { 'STARTDATE': startdate, 'ENDDATE': enddate, + 'SYSINFO': sysinfo, 'SYSID':sysid, 'LASTTESTLOG':testlog } + for key in dic.keys(): + s = re.sub(key,dic[key],s) + for t in tests: + print t.passed, t.type, t.fullname, t.expectedfile, t.actualfile + manifest[t.actualfile] = wikify_filename(t.fullname,t.actualfile,sysid) + manifest[t.expectedfile] = wikify_filename(t.fullname,t.expectedfile,sysid) + if t.passed: + newchunk = re.sub('PTESTNAME',t.fullname,repeat3) + s = s.replace(repeat3, newchunk+repeat3) + elif not t.passed and t.type=='txt': + newchunk = re.sub('FTEST_OUTPUTFILE',t.fullname,repeat2) + newchunk = re.sub('FTESTNAME',t.fullname,repeat2) + s = s.replace(repeat2, newchunk+repeat2) + elif not t.passed and t.type=='png': + if t.actualfile: + actualfile_wiki = '[[File:'+manifest[t.actualfile]+'|thumb|250px]]' + else: + actualfile_wiki = 'No file generated. See test output for more info' + newchunk = re.sub('FTESTNAME',t.fullname,repeat1) + newchunk = newchunk.replace('ACTUALFILE_WIKI',actualfile_wiki) + newchunk = newchunk.replace('EXPECTEDFILE',manifest[t.expectedfile]) + s = s.replace(repeat1, newchunk+repeat1) + s = s.replace(repeat1,'') + s = s.replace(repeat2,'') + s = s.replace(repeat3,'') + s = re.sub('\n','',s) + s = re.sub('','',s) + return manifest, s + +def wikitohtml(data): + # not pretty + data = data.replace('\n\n','\n

\n') + data = re.sub('\{\|.*?\n','\n',data) + data = re.sub('\n\! ','\n\n') + data = re.sub('\n\| ','\n
',data) + data = data.replace(' !! ','') + data = data.replace('|-','
',data) + data = data.replace(' || ','') + data = data.replace('|}','\n
') + data = re.sub('[[File:(.*?)|.*?]]','',data) + return data + +wiki_rootpath = 'OpenSCAD' +builddir = os.getcwd() +logpath = os.path.join(builddir,'Testing','Temporary') +logfilename = os.path.join(logpath,'LastTest.log') + +def main(): + testlog = tryread(logfilename) + startdate, tests, enddate = parselog(testlog) + tests = sorted(tests, key = lambda t:t.passed) + sysinfo, sysid = read_sysinfo('sysinfo.txt') + manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog) + htmldata = wikitohtml(wikidata) + #save(wikidata, os.path.join(logpath,sysid+'.wiki')) + #save(htmldata, os.path.join(logpath,sysid+'.html')) + trysave(wikidata, sysid+'.wiki') + trysave(htmldata, sysid+'.html') + +main() + -- cgit v0.10.1 From 1aa73df3b86a853469e8938fdc51388011bab961 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 16 Nov 2011 21:36:58 -0600 Subject: improve info report. add auto-uploading ability for wiki data/images diff --git a/tests/OffscreenContext.mm b/tests/OffscreenContext.mm index 7d95481..5a6a8ec 100644 --- a/tests/OffscreenContext.mm +++ b/tests/OffscreenContext.mm @@ -20,6 +20,7 @@ string offscreen_context_getinfo(OffscreenContext *ctx) { stringstream out; out << "GL context creator: Cocoa / CGL\n" + << "PNG generator: Core Foundation\n" << "OS info: Mac OSX\n" << "Machine: Apple(TM) Mac(TM)\n"; return out.str(); diff --git a/tests/OffscreenContextGLX.cc b/tests/OffscreenContextGLX.cc index ed9ef46..0817ce2 100644 --- a/tests/OffscreenContextGLX.cc +++ b/tests/OffscreenContextGLX.cc @@ -100,6 +100,7 @@ string offscreen_context_getinfo(OffscreenContext *ctx) stringstream out; out << "GL context creator: GLX\n" + << "PNG generator: lodepng\n" << "GLX version: " << major << "." << minor << "\n" << get_os_info(); @@ -139,7 +140,8 @@ bool create_glx_dummy_window(OffscreenContext &ctx) GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, - GLX_DEPTH_SIZE, 1, + GLX_ALPHA_SIZE, 1, // extra stuff for fbo-disbaled on-screen testing. + GLX_DEPTH_SIZE, 24, None }; @@ -178,7 +180,6 @@ bool create_glx_dummy_window(OffscreenContext &ctx) // Window xWin = XCreateSimpleWindow( dpy, DefaultRootWindow(dpy), 0,0,42,42, 0,0,0 ); - XSync( dpy, false ); if ( XCreateWindow_failed ) { XFree( visinfo ); diff --git a/tests/OffscreenContextWGL.cc b/tests/OffscreenContextWGL.cc index 4deaf2a..ba12a4f 100644 --- a/tests/OffscreenContextWGL.cc +++ b/tests/OffscreenContextWGL.cc @@ -82,6 +82,7 @@ string offscreen_context_getinfo(OffscreenContext *ctx) { stringstream out; out << "GL context creator: WGL\n" + out << "PNG generator: lodepng\n" << get_windows_info(); return out.str(); } diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 9511688..a3d5097 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -87,16 +87,11 @@ string info_dump(OffscreenView *glview) #endif std::stringstream out; - out << "OpenSCAD info dump:" - << "\nOpenSCAD Year/Month/Day: " << int(OPENSCAD_YEAR) << "." - << int(OPENSCAD_MONTH) << "." -#ifdef OPENSCAD_DAY - << int(OPENSCAD_DAY); -#endif #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) - << "\nOpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION) + out << "\nOpenSCAD Version: " << TOSTRING(OPENSCAD_VERSION) << "\nCompiled by: " << compiler_info + << "\nCompile date: " << __DATE__ << "\nBoost version: " << BOOST_LIB_VERSION << "\nEigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 6bc3f54..c4b5c6c 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -1,26 +1,14 @@ #!/usr/bin/python # -# this program reads the ctest logfiles from builddir/Testing/Temporary -# and generates two 'pretty printed' outputs in that directory: -# -# 1. mediawiki format, for uploading to a wiki. -# automated uploading is available by following these steps: +# This program 'pretty prints' the ctest output, namely +# files from builddir/Testing/Temporary. +# html & wiki output are produced +# wiki uploading is available by running # -# download mwclient -# python ctest_pretty_print.py --upload -# -# 2. html format, for easy local viewing -# -# sysinfo.txt: -# sysinfo.txt should have been created by ctest by the main test run. -# it is the output of opencsgtest --info - +# python test_pretty_print.py --upload # todo -# 1. add sysinfo about ... git branch -# 2. consolidate image flip -# 3. uploading, can it be done in one file -# 4. consolidate pretty print +# ban opencsg<2.0 from opencsgtest import string,sys,re,os,hashlib,subprocess @@ -79,10 +67,9 @@ def read_sysinfo(filename): tmp = tmp.split('/')[0] renderer = tmp - hasher = hashlib.md5() - hasher.update(data) - hexhash = hasher.hexdigest()[-4:].upper() - # make all letters for aesthetic reasons + hexhash = hashlib.md5() + hexhash.update(data) + hexhash = hexhash.hexdigest()[-4:].upper() hash = '' for c in hexhash: hash += chr(ord(c)+97-48) @@ -91,14 +78,16 @@ def read_sysinfo(filename): data += read_gitinfo() + data += 'Image comparison: PerceptualDiff' return data, sysid class Test: - def __init__(self,fullname,time,passed,output,type,actualfile,expectedfile,scadfile): + def __init__(self,fullname,time,passed,output,type,actualfile,expectedfile,scadfile,log): self.fullname,self.time,self.passed,self.output = \ fullname, time, passed, output self.type, self.actualfile, self.expectedfile, self.scadfile = \ type, actualfile, expectedfile, scadfile + self.fulltestlog = log def __str__(self): x = 'fullname: ' + self.fullname @@ -109,6 +98,7 @@ class Test: x+= '\npassed: ' + str(self.passed) x+= '\nscadfile: ' + self.scadfile x+= '\noutput bytes: ' + str(len(self.output)) + x+= '\ntestlog bytes: ' + str(len(self.fulltestlog)) x+= '\n' return x @@ -123,7 +113,7 @@ def parsetest(teststring): 'Command:.*?(testdata.*?)"' # scadfile ] hits = map( lambda pattern: ezsearch(pattern,teststring), patterns ) - test = Test(hits[0],hits[1],hits[2]=='Passed',hits[3],hits[4],hits[5],hits[6],hits[7]) + test = Test(hits[0],hits[1],hits[2]=='Passed',hits[3],hits[4],hits[5],hits[6],hits[7],teststring) return test def parselog(data): @@ -147,22 +137,24 @@ def wikify_filename(testname,filename,sysid): def towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog): - wiki_template = ''' -

OpenSCAD test run

+ wiki_template = """ +

[[WIKI_ROOTPATH]] test run report

-sysid: SYSID +'''Sysid''': SYSID -detailed system info: +'''Result summary''': NUMPASSED / NUMTESTS tests passed ( PERCENTPASSED % )
+ +'''System info''':
 SYSINFO
 
-start time: STARTDATE -end time : ENDDATE +start time: STARTDATE
+end time : ENDDATE
-Failed image tests +'''Failed image tests''' -{|border=1 cellspacing=0 cellpadding=1 align="center" +{| border=1 cellspacing=0 cellpadding=1 ! Testname !! expected output !! actual output |- @@ -170,81 +162,134 @@ Failed image tests |} -Failed text tests (see test log, below, for diff output) +'''Failed text tests''' -{|border=1 cellspacing=0 cellpadding=1 align="center" +{|border=1 cellspacing=0 cellpadding=1 +! Testname |- | FTESTNAME |} -Passed tests +'''Test logs''' -{|border=1 cellspacing=0 cellpadding=1 align="center" -! Testname - -|- -| PTESTNAME - -|} - -LastTest.log +(excerpted from Testing/Temporary/LastTest.Log)
-LASTTESTLOG
+FAILED_TESTLOGS
 
-''' +""" + numpassed = len(filter(lambda x: x.passed, tests)) + percent = str(int(100.0*numpassed / len(tests))) manifest = {} s = wiki_template repeat1 = ezsearch('(.*?)',s) repeat2 = ezsearch('(.*?)',s) - repeat3 = ezsearch('(.*?)',s) - dic = { 'STARTDATE': startdate, 'ENDDATE': enddate, - 'SYSINFO': sysinfo, 'SYSID':sysid, 'LASTTESTLOG':testlog } + dic = { 'STARTDATE': startdate, 'ENDDATE': enddate, 'WIKI_ROOTPATH': wiki_rootpath, + 'SYSINFO': sysinfo, 'SYSID':sysid, 'LASTTESTLOG':testlog, + 'NUMTESTS':len(tests), 'NUMPASSED':numpassed, 'PERCENTPASSED':percent } for key in dic.keys(): - s = re.sub(key,dic[key],s) + s = re.sub(key,str(dic[key]),s) + testlogs = '' for t in tests: - print t.passed, t.type, t.fullname, t.expectedfile, t.actualfile - manifest[t.actualfile] = wikify_filename(t.fullname,t.actualfile,sysid) - manifest[t.expectedfile] = wikify_filename(t.fullname,t.expectedfile,sysid) - if t.passed: - newchunk = re.sub('PTESTNAME',t.fullname,repeat3) - s = s.replace(repeat3, newchunk+repeat3) - elif not t.passed and t.type=='txt': - newchunk = re.sub('FTEST_OUTPUTFILE',t.fullname,repeat2) - newchunk = re.sub('FTESTNAME',t.fullname,repeat2) - s = s.replace(repeat2, newchunk+repeat2) - elif not t.passed and t.type=='png': - if t.actualfile: - actualfile_wiki = '[[File:'+manifest[t.actualfile]+'|thumb|250px]]' - else: - actualfile_wiki = 'No file generated. See test output for more info' - newchunk = re.sub('FTESTNAME',t.fullname,repeat1) - newchunk = newchunk.replace('ACTUALFILE_WIKI',actualfile_wiki) - newchunk = newchunk.replace('EXPECTEDFILE',manifest[t.expectedfile]) - s = s.replace(repeat1, newchunk+repeat1) + # if t.passed: noop + if not t.passed: + testlogs += '\n\n'+t.fulltestlog + if t.type=='txt': + newchunk = re.sub('FTEST_OUTPUTFILE',t.fullname,repeat2) + newchunk = re.sub('FTESTNAME',t.fullname,repeat2) + s = s.replace(repeat2, newchunk+repeat2) + elif t.type=='png': + manifest[t.actualfile] = wikify_filename(t.fullname,t.actualfile,sysid) + manifest[t.expectedfile] = wikify_filename(t.fullname,t.expectedfile,sysid) + if t.actualfile: + actualfile_wiki = '[[File:'+manifest[t.actualfile]+'|thumb|250px]]' + else: + actualfile_wiki = 'No file generated.
See log for details' + newchunk = re.sub('FTESTNAME',t.fullname,repeat1) + newchunk = newchunk.replace('ACTUALFILE_WIKI',actualfile_wiki) + newchunk = newchunk.replace('EXPECTEDFILE',manifest[t.expectedfile]) + s = s.replace(repeat1, newchunk+repeat1) + s = s.replace('FAILED_TESTLOGS',testlogs) s = s.replace(repeat1,'') s = s.replace(repeat2,'') - s = s.replace(repeat3,'') s = re.sub('\n','',s) s = re.sub('','',s) return manifest, s -def wikitohtml(data): - # not pretty - data = data.replace('\n\n','\n

\n') - data = re.sub('\{\|.*?\n','\n',data) - data = re.sub('\n\! ','\n\n') - data = re.sub('\n\| ','\n
',data) - data = data.replace(' !! ','') - data = data.replace('|-','
',data) - data = data.replace(' || ','') - data = data.replace('|}','\n
') - data = re.sub('[[File:(.*?)|.*?]]','',data) - return data +def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): + head = ''+wiki_rootpath+' test run for '+sysid +'' + revmanifest = dict((val,key) for key, val in manifest.iteritems()) + x=re.sub('\{\|(.*?)\n','\n',wikidata) + x=re.sub("'''(.*?)'''","\\1",x) + filestrs=re.findall('\[\[File\:(.*?)\|.*?\]\]',x) + for f in filestrs: + newfile_html='' + x=re.sub('\[\[File\:'+f+'\|.*?\]\]',newfile_html,x) + dic = { '|}':'
', '|-':'', '||':'', '|':'', + '!!':'', '!':'', '\n\n':'\n

\n'} #order matters + for key in dic: x=x.replace(key,dic[key]) + x=re.sub("\[\[(.*?)\]\]","\\1",x) + return head + x + '' + +def upload_dryrun(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass): + print 'dry run. no files to be uploaded' + print 'log in', wikiurl, api_php_path, botname, botpass + print 'save ' + '*[['+wiki_rootpath+sysid+']]' + ' to page ' + wiki_rootpath + print 'save ', len(wikidata), ' bytes to page ',wiki_rootpath+sysid + for localfile in manifest.keys(): + if localfile: + localf=open(localfile) + wikifile = manifest[localfile] + print 'upload',localfile,wikifile + +def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass,dryrun=True): + if dryrun: + upload_dryrun(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass) + return None + try: + import mwclient + except: + print 'please download mwclient and unpack here:', os.cwd() + print 'open site',wikiurl + if not api_php_path == '': + site = mwclient.Site(wikiurl,api_php_path) + else: + site = mwclient.Site(wikiurl) + + print 'bot login' + site.login(botname,botpass) + + print 'edit ',wiki_rootpath + page = site.Pages[wiki_rootpath] + text = page.edit() + rootpage = wiki_rootpath + sysid + if not '[['+rootpage+']]' in text: + page.save(text +'\n*[['+rootpage+']]\n') + + print 'upload wiki data to',rootpage + page = site.Pages[rootpage] + text = page.edit() + page.save(wikidata) + + print 'upload images' + for localfile in sorted(manifest.keys()): + if localfile: + localf=open(localfile) + wikifile = manifest[localfile] + skip=False + if 'expected.png' in wikifile.lower(): + image = site.Images[wikifile] + if image.exists: + print 'skipping ',wikifile, '(expected image, already on wiki)' + skip=True + if not skip: + print wikifile,'...' + site.upload(localf,wikifile,wiki_rootpath + ' test') +wikisite = 'cakebaby.referata.com' wiki_rootpath = 'OpenSCAD' builddir = os.getcwd() logpath = os.path.join(builddir,'Testing','Temporary') @@ -256,11 +301,10 @@ def main(): tests = sorted(tests, key = lambda t:t.passed) sysinfo, sysid = read_sysinfo('sysinfo.txt') manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog) - htmldata = wikitohtml(wikidata) - #save(wikidata, os.path.join(logpath,sysid+'.wiki')) - #save(htmldata, os.path.join(logpath,sysid+'.html')) - trysave(wikidata, sysid+'.wiki') - trysave(htmldata, sysid+'.html') - + trysave(wikidata, os.path.join(logpath,sysid+'.wiki')) + htmldata = wikitohtml(wiki_rootpath, sysid, wikidata, manifest) + trysave(htmldata, os.path.join(logpath,sysid+'.html')) + if '--upload' in sys.argv: + upload(wikisite,'',wikidata,manifest,wiki_rootpath,sysid,'openscadbot','tobdacsnepo',dryrun=False) main() -- cgit v0.10.1 From e31bb0f60312e692f5ef57fd3823e413cc8a669c Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 16 Nov 2011 21:42:08 -0600 Subject: make use FBO without stencil buffer diff --git a/tests/OffscreenContextGLX.cc b/tests/OffscreenContextGLX.cc index 0817ce2..3523021 100644 --- a/tests/OffscreenContextGLX.cc +++ b/tests/OffscreenContextGLX.cc @@ -189,7 +189,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 ) { -- cgit v0.10.1 From 03442e31241a859701c9efaf7525c9752444fa9f Mon Sep 17 00:00:00 2001 From: Don Bright Date: Mon, 21 Nov 2011 20:28:35 -0600 Subject: fixing GLX setup diff --git a/tests/OffscreenContextGLX.cc b/tests/OffscreenContextGLX.cc index 3523021..41f01f7 100644 --- a/tests/OffscreenContextGLX.cc +++ b/tests/OffscreenContextGLX.cc @@ -137,11 +137,12 @@ bool create_glx_dummy_window(OffscreenContext &ctx) int attributes[] = { GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_RED_SIZE, 1, - GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, - GLX_ALPHA_SIZE, 1, // extra stuff for fbo-disbaled on-screen testing. + GLX_RED_SIZE, 8, + GLX_GREEN_SIZE, 8, + GLX_BLUE_SIZE, 8, + GLX_ALPHA_SIZE, 8, // extra stuff for fbo-disbaled on-screen testing. GLX_DEPTH_SIZE, 24, + GLX_STENCIL_SIZE, 8, None }; @@ -271,11 +272,11 @@ OffscreenContext *create_offscreen_context(int w, int h) } // cerr << glew_dump(0); -/* 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/cgalpngtest.cc b/tests/cgalpngtest.cc index bfa92da..cc747fb 100644 --- a/tests/cgalpngtest.cc +++ b/tests/cgalpngtest.cc @@ -190,16 +190,19 @@ int main(int argc, char **argv) BoundingBox bbox; if (cgalRenderer.polyhedron) { + std::cout << "polyhedron\n" ; CGAL::Bbox_3 cgalbbox = cgalRenderer.polyhedron->bbox(); bbox = BoundingBox(Vector3d(cgalbbox.xmin(), cgalbbox.ymin(), cgalbbox.zmin()), Vector3d(cgalbbox.xmax(), cgalbbox.ymax(), cgalbbox.zmax())); } else if (cgalRenderer.polyset) { + std::cout << "polyset\n" ; bbox = cgalRenderer.polyset->getBoundingBox(); } Vector3d center = getBoundingCenter(bbox); double radius = getBoundingRadius(bbox); + std::cout << "radius: " << radius << "\n"; Vector3d cameradir(1, 1, -0.5); Vector3d camerapos = center - radius*2*cameradir; diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index c4b5c6c..fce17f5 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -9,6 +9,11 @@ # todo # ban opencsg<2.0 from opencsgtest +# copy all images, sysinfo.txt to bundle for html/upload (images +# can be altered by subsequent runs) +# figure out hwo to make the thing run after the test +# figure out how CTEST treats the logfiles. +# why is hash differing import string,sys,re,os,hashlib,subprocess -- cgit v0.10.1 From cea502f9a3531888dbbb55099421fb1ab565f2c1 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 22 Nov 2011 20:31:57 -0600 Subject: tweak and fix Stencilbuffer setup. diff --git a/tests/OffscreenContextGLX.cc b/tests/OffscreenContextGLX.cc index 41f01f7..e607593 100644 --- a/tests/OffscreenContextGLX.cc +++ b/tests/OffscreenContextGLX.cc @@ -135,14 +135,15 @@ bool create_glx_dummy_window(OffscreenContext &ctx) */ int attributes[] = { - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, + GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT, //support all 3, for OpenCSG GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, - GLX_ALPHA_SIZE, 8, // extra stuff for fbo-disbaled on-screen testing. - GLX_DEPTH_SIZE, 24, + GLX_ALPHA_SIZE, 8, + GLX_DEPTH_SIZE, 24, // depth-stencil for OpenCSG GLX_STENCIL_SIZE, 8, + GLX_DOUBLEBUFFER, True, None }; @@ -169,6 +170,7 @@ bool create_glx_dummy_window(OffscreenContext &ctx) XSetWindowAttributes xwin_attr; int width = ctx.width; int height = ctx.height; + xwin_attr.background_pixmap = None; xwin_attr.background_pixel = 0; xwin_attr.border_pixel = 0; xwin_attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); @@ -270,7 +272,6 @@ OffscreenContext *create_offscreen_context(int w, int h) cerr << "Unable to init GLEW: " << glewGetErrorString(err) << endl; return NULL; } - // cerr << glew_dump(0); ctx->fbo = fbo_new(); if (!fbo_init(ctx->fbo, w, h)) { @@ -299,6 +300,7 @@ bool teardown_offscreen_context(OffscreenContext *ctx) */ bool save_framebuffer(OffscreenContext *ctx, const char *filename) { + glXSwapBuffers(ctx->xdisplay, ctx->xwindow); if (!ctx || !filename) return false; int samplesPerPixel = 4; // R, G, B and A GLubyte pixels[ctx->width * ctx->height * samplesPerPixel]; diff --git a/tests/fbo.cc b/tests/fbo.cc index 2f933d7..a6677c1 100644 --- a/tests/fbo.cc +++ b/tests/fbo.cc @@ -144,7 +144,11 @@ bool fbo_arb_init(fbo_t *fbo, size_t width, size_t height) } //glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, + // to prevent Mesa's software renderer from crashing, do this in two stages. + // ie. instead of using GL_DEPTH_STENCIL_ATTACHMENT, do DEPTH then STENCIL. + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, + GL_RENDERBUFFER, fbo->depthbuf_id); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fbo->depthbuf_id); if (report_glerror("specifying depth stencil render buffer")) return false; @@ -183,7 +187,7 @@ bool fbo_resize(fbo_t *fbo, size_t width, size_t height) { if (use_ext()) { glBindRenderbufferEXT(GL_RENDERBUFFER, fbo->depthbuf_id); - if (0) { // glewIsSupported("GL_EXT_packed_depth_stencil")) { + if (glewIsSupported("GL_EXT_packed_depth_stencil")) { glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); if (report_glerror("creating EXT depth stencil render buffer")) return false; } @@ -196,14 +200,14 @@ bool fbo_resize(fbo_t *fbo, size_t width, size_t height) glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_RGBA8, width, height); if (report_glerror("creating EXT color render buffer")) return false; } else { - glBindRenderbuffer(GL_RENDERBUFFER, fbo->depthbuf_id); - //glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT32, width, height); - if (report_glerror("creating depth stencil render buffer")) return false; - glBindRenderbuffer(GL_RENDERBUFFER, fbo->renderbuf_id); glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, width, height); if (report_glerror("creating color render buffer")) return false; + + glBindRenderbuffer(GL_RENDERBUFFER, fbo->depthbuf_id); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); + if (report_glerror("creating depth stencil render buffer")) return false; + } return true; diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index fce17f5..897f7b8 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -14,6 +14,10 @@ # figure out hwo to make the thing run after the test # figure out how CTEST treats the logfiles. # why is hash differing +# instead of having special '-info' prerun, put it as yet-another-test +# and parse the log +# provide option to replace 'expected' images on wiki +# (yes sometimes you do need to change/update them) import string,sys,re,os,hashlib,subprocess @@ -83,7 +87,7 @@ def read_sysinfo(filename): data += read_gitinfo() - data += 'Image comparison: PerceptualDiff' + data += 'Image comparison: PerceptualDiff by H. Yee' return data, sysid class Test: @@ -293,7 +297,8 @@ def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,bo skip=True if not skip: print wikifile,'...' - site.upload(localf,wikifile,wiki_rootpath + ' test') + site.upload(localf,wikifile,wiki_rootpath + ' test', ignore=True) + wikisite = 'cakebaby.referata.com' wiki_rootpath = 'OpenSCAD' builddir = os.getcwd() @@ -305,6 +310,7 @@ def main(): startdate, tests, enddate = parselog(testlog) tests = sorted(tests, key = lambda t:t.passed) sysinfo, sysid = read_sysinfo('sysinfo.txt') + if '--hack' in sys.argv: sysid+='_hack' manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog) trysave(wikidata, os.path.join(logpath,sysid+'.wiki')) htmldata = wikitohtml(wiki_rootpath, sysid, wikidata, manifest) -- cgit v0.10.1 From aa8d53614a1a8aa16d076a3346d781cb3dc797e2 Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 22 Nov 2011 22:45:37 -0600 Subject: fix stencil code for windows. tweak pretty printer for windows diff --git a/doc/testing.txt b/doc/testing.txt index b2974fc..f90aca8 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -25,12 +25,11 @@ cmake .. nmake -f Makefile nmake -f Makefile test -Running on headless (no X) servers: +Running on headless (no X) unix servers: Xvnc :5 -screen 0 800x600x24 & DISPLAY=:5 make test - Adding a new regression test: ------------------------------ diff --git a/tests/OffscreenContextWGL.cc b/tests/OffscreenContextWGL.cc index ba12a4f..f36671c 100644 --- a/tests/OffscreenContextWGL.cc +++ b/tests/OffscreenContextWGL.cc @@ -82,8 +82,8 @@ string offscreen_context_getinfo(OffscreenContext *ctx) { stringstream out; out << "GL context creator: WGL\n" - out << "PNG generator: lodepng\n" - << get_windows_info(); + << "PNG generator: lodepng\n" + << get_os_info(); return out.str(); } @@ -130,11 +130,15 @@ bool create_wgl_dummy_context(OffscreenContext &ctx) ZeroMemory( &pixformat, sizeof( pixformat ) ); pixformat.nSize = sizeof( pixformat ); pixformat.nVersion = 1; - pixformat.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; + pixformat.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pixformat.iPixelType = PFD_TYPE_RGBA; - pixformat.cColorBits = 24; - pixformat.cDepthBits = 16; - pixformat.iLayerType = PFD_MAIN_PLANE; + pixformat.cGreenBits = 8; + pixformat.cRedBits = 8; + pixformat.cBlueBits = 8; + pixformat.cAlphaBits = 8; + pixformat.cDepthBits = 24; + pixformat.cStencilBits = 8; + chosenformat = ChoosePixelFormat( dev_context, &pixformat ); if (chosenformat==0) { cerr << "MS GDI - ChoosePixelFormat failed\n"; @@ -215,6 +219,7 @@ bool teardown_offscreen_context(OffscreenContext *ctx) */ bool save_framebuffer(OffscreenContext *ctx, const char *filename) { + wglSwapLayerBuffers( ctx->dev_context, WGL_SWAP_MAIN_PLANE ); if (!ctx || !filename) return false; int samplesPerPixel = 4; // R, G, B and A vector pixels(ctx->width * ctx->height * samplesPerPixel); diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index 3e9f45a..40aa4d6 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -35,6 +35,7 @@ def init_expected_filename(testname, cmd): global expecteddir, expectedfilename expecteddir = os.path.join(options.regressiondir, os.path.split(cmd)[1]) expectedfilename = os.path.join(expecteddir, testname + "-expected." + options.suffix) + expectedfilename = os.path.normpath( expectedfilename ) def verify_test(testname, cmd): global expectedfilename diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 897f7b8..8ba0512 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -196,11 +196,11 @@ FAILED_TESTLOGS s = wiki_template repeat1 = ezsearch('(.*?)',s) repeat2 = ezsearch('(.*?)',s) - dic = { 'STARTDATE': startdate, 'ENDDATE': enddate, 'WIKI_ROOTPATH': wiki_rootpath, - 'SYSINFO': sysinfo, 'SYSID':sysid, 'LASTTESTLOG':testlog, - 'NUMTESTS':len(tests), 'NUMPASSED':numpassed, 'PERCENTPASSED':percent } + dic = { 'STARTDATE': str(startdate), 'ENDDATE': str(enddate), 'WIKI_ROOTPATH': str(wiki_rootpath), + 'SYSINFO': str(sysinfo), 'SYSID':str(sysid), 'LASTTESTLOG':str(testlog), + 'NUMTESTS':str(len(tests)), 'NUMPASSED':str(numpassed), 'PERCENTPASSED':str(percent) } for key in dic.keys(): - s = re.sub(key,str(dic[key]),s) + s = s.replace(key,dic[key]) testlogs = '' for t in tests: # if t.passed: noop @@ -236,7 +236,7 @@ def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): x=re.sub("'''(.*?)'''","\\1",x) filestrs=re.findall('\[\[File\:(.*?)\|.*?\]\]',x) for f in filestrs: - newfile_html='' + newfile_html='' x=re.sub('\[\[File\:'+f+'\|.*?\]\]',newfile_html,x) dic = { '|}':'', '|-':'', '||':'', '|':'', '!!':'', '!':'', '\n\n':'\n

\n'} #order matters @@ -262,7 +262,7 @@ def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,bo try: import mwclient except: - print 'please download mwclient and unpack here:', os.cwd() + print 'please download mwclient and unpack here:', os.getcwd() print 'open site',wikiurl if not api_php_path == '': site = mwclient.Site(wikiurl,api_php_path) @@ -287,7 +287,7 @@ def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,bo print 'upload images' for localfile in sorted(manifest.keys()): if localfile: - localf=open(localfile) + localf = open(localfile,'rb') wikifile = manifest[localfile] skip=False if 'expected.png' in wikifile.lower(): -- cgit v0.10.1 From 29783dc4aa6e44221c9a584c2651624a93dfcf9a Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 23 Nov 2011 21:47:33 -0600 Subject: patch for opencsg1.3.1 and add --forceupload option to pretty printer diff --git a/patches/OpenCSG-1.3.1-FBO.patch b/patches/OpenCSG-1.3.1-FBO.patch new file mode 100644 index 0000000..234992d --- /dev/null +++ b/patches/OpenCSG-1.3.1-FBO.patch @@ -0,0 +1,117 @@ +Only in OpenCSG-1.3.1-fbo-patch/: lib +diff -ur OpenCSG-1.3.1/src/frameBufferObject.cpp OpenCSG-1.3.1-fbo-patch/src/frameBufferObject.cpp +--- OpenCSG-1.3.1/src/frameBufferObject.cpp 2010-06-09 14:39:58.000000000 -0500 ++++ OpenCSG-1.3.1-fbo-patch/src/frameBufferObject.cpp 2011-11-23 21:42:42.709641637 -0600 +@@ -3,8 +3,8 @@ + // + // This library is free software; you can redistribute it and/or + // modify it under the terms of the GNU General Public License, +-// Version 2, as published by the Free Software Foundation. +-// As a special exception, you have permission to link this library ++// Version 2, as published by the Free Software Foundation. ++// As a special exception, you have permission to link this library + // with the CGAL library and distribute executables. + // + // This library is distributed in the hope that it will be useful, +@@ -59,6 +59,7 @@ + glGenRenderbuffers(1, &depthID); + glGenTextures(1, &textureID); + ++ glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFramebufferID); + glBindFramebuffer(GL_FRAMEBUFFER, framebufferID); + glBindTexture(GL_TEXTURE_2D, textureID); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_INT, 0); +@@ -78,7 +79,7 @@ + return false; + } + +- glBindFramebuffer(GL_FRAMEBUFFER, 0); ++ glBindFramebuffer(GL_FRAMEBUFFER, oldFramebufferID); + glBindTexture(GL_TEXTURE_2D, 0); + + textureTarget = GL_TEXTURE_2D; +Only in OpenCSG-1.3.1-fbo-patch/src: frameBufferObject.cpp~ +diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.cpp OpenCSG-1.3.1-fbo-patch/src/frameBufferObjectExt.cpp +--- OpenCSG-1.3.1/src/frameBufferObjectExt.cpp 2010-06-09 14:39:58.000000000 -0500 ++++ OpenCSG-1.3.1-fbo-patch/src/frameBufferObjectExt.cpp 2011-11-23 21:07:00.073641732 -0600 +@@ -3,8 +3,8 @@ + // + // This library is free software; you can redistribute it and/or + // modify it under the terms of the GNU General Public License, +-// Version 2, as published by the Free Software Foundation. +-// As a special exception, you have permission to link this library ++// Version 2, as published by the Free Software Foundation. ++// As a special exception, you have permission to link this library + // with the CGAL library and distribute executables. + // + // This library is distributed in the hope that it will be useful, +@@ -60,6 +60,7 @@ + glGenRenderbuffersEXT(1, &depthID); + glGenTextures(1, &textureID); + ++ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &oldFramebufferID); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebufferID); + glBindTexture(GL_TEXTURE_2D, textureID); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_INT, 0); +@@ -79,7 +80,7 @@ + return false; + } + +- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); ++ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, oldFramebufferID); + glBindTexture(GL_TEXTURE_2D, 0); + + textureTarget = GL_TEXTURE_2D; +@@ -136,7 +137,7 @@ + // Unbinds frame buffer texture. + bool FrameBufferObjectExt::EndCapture() + { +- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); ++ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, oldFramebufferID); + return true; + } + +diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.h OpenCSG-1.3.1-fbo-patch/src/frameBufferObjectExt.h +--- OpenCSG-1.3.1/src/frameBufferObjectExt.h 2010-06-09 14:39:58.000000000 -0500 ++++ OpenCSG-1.3.1-fbo-patch/src/frameBufferObjectExt.h 2011-11-23 21:07:15.529642039 -0600 +@@ -3,8 +3,8 @@ + // + // This library is free software; you can redistribute it and/or + // modify it under the terms of the GNU General Public License, +-// Version 2, as published by the Free Software Foundation. +-// As a special exception, you have permission to link this library ++// Version 2, as published by the Free Software Foundation. ++// As a special exception, you have permission to link this library + // with the CGAL library and distribute executables. + // + // This library is distributed in the hope that it will be useful, +@@ -85,6 +85,7 @@ + unsigned int depthID; + + unsigned int framebufferID; ++ int oldFramebufferID; + + bool initialized; + }; +diff -ur OpenCSG-1.3.1/src/frameBufferObject.h OpenCSG-1.3.1-fbo-patch/src/frameBufferObject.h +--- OpenCSG-1.3.1/src/frameBufferObject.h 2010-06-09 14:39:58.000000000 -0500 ++++ OpenCSG-1.3.1-fbo-patch/src/frameBufferObject.h 2011-11-23 21:37:07.565641308 -0600 +@@ -3,8 +3,8 @@ + // + // This library is free software; you can redistribute it and/or + // modify it under the terms of the GNU General Public License, +-// Version 2, as published by the Free Software Foundation. +-// As a special exception, you have permission to link this library ++// Version 2, as published by the Free Software Foundation. ++// As a special exception, you have permission to link this library + // with the CGAL library and distribute executables. + // + // This library is distributed in the hope that it will be useful, +@@ -85,6 +85,7 @@ + unsigned int depthID; + + unsigned int framebufferID; ++ int oldFramebufferID; + + bool initialized; + }; diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 8ba0512..ffc74eb 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -10,14 +10,12 @@ # todo # ban opencsg<2.0 from opencsgtest # copy all images, sysinfo.txt to bundle for html/upload (images -# can be altered by subsequent runs) +# can be altered by subsequent runs) # figure out hwo to make the thing run after the test # figure out how CTEST treats the logfiles. # why is hash differing # instead of having special '-info' prerun, put it as yet-another-test # and parse the log -# provide option to replace 'expected' images on wiki -# (yes sometimes you do need to change/update them) import string,sys,re,os,hashlib,subprocess @@ -196,11 +194,11 @@ FAILED_TESTLOGS s = wiki_template repeat1 = ezsearch('(.*?)',s) repeat2 = ezsearch('(.*?)',s) - dic = { 'STARTDATE': str(startdate), 'ENDDATE': str(enddate), 'WIKI_ROOTPATH': str(wiki_rootpath), - 'SYSINFO': str(sysinfo), 'SYSID':str(sysid), 'LASTTESTLOG':str(testlog), - 'NUMTESTS':str(len(tests)), 'NUMPASSED':str(numpassed), 'PERCENTPASSED':str(percent) } + dic = { 'STARTDATE': startdate, 'ENDDATE': enddate, 'WIKI_ROOTPATH': wiki_rootpath, + 'SYSINFO': sysinfo, 'SYSID':sysid, 'LASTTESTLOG':testlog, + 'NUMTESTS':len(tests), 'NUMPASSED':numpassed, 'PERCENTPASSED':percent } for key in dic.keys(): - s = s.replace(key,dic[key]) + s = re.sub(key,str(dic[key]),s) testlogs = '' for t in tests: # if t.passed: noop @@ -236,7 +234,7 @@ def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): x=re.sub("'''(.*?)'''","\\1",x) filestrs=re.findall('\[\[File\:(.*?)\|.*?\]\]',x) for f in filestrs: - newfile_html='' + newfile_html='' x=re.sub('\[\[File\:'+f+'\|.*?\]\]',newfile_html,x) dic = { '|}':'', '|-':'', '||':'', '|':'', '!!':'', '!':'', '\n\n':'\n

\n'} #order matters @@ -255,14 +253,14 @@ def upload_dryrun(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,bot wikifile = manifest[localfile] print 'upload',localfile,wikifile -def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass,dryrun=True): +def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass,dryrun=True,forceupload=False): if dryrun: upload_dryrun(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass) return None try: import mwclient except: - print 'please download mwclient and unpack here:', os.getcwd() + print 'please download mwclient and unpack here:', os.cwd() print 'open site',wikiurl if not api_php_path == '': site = mwclient.Site(wikiurl,api_php_path) @@ -287,16 +285,16 @@ def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,bo print 'upload images' for localfile in sorted(manifest.keys()): if localfile: - localf = open(localfile,'rb') + localf = open(localfile) wikifile = manifest[localfile] skip=False if 'expected.png' in wikifile.lower(): image = site.Images[wikifile] - if image.exists: - print 'skipping ',wikifile, '(expected image, already on wiki)' + if image.exists and forceupload==False: + print 'skipping ',wikifile, '(image with same name and size ',localsize,'already on wiki)' skip=True if not skip: - print wikifile,'...' + print 'uploading',wikifile,'...' site.upload(localf,wikifile,wiki_rootpath + ' test', ignore=True) wikisite = 'cakebaby.referata.com' @@ -310,8 +308,9 @@ def main(): startdate, tests, enddate = parselog(testlog) tests = sorted(tests, key = lambda t:t.passed) sysinfo, sysid = read_sysinfo('sysinfo.txt') - if '--hack' in sys.argv: sysid+='_hack' - manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog) + if '--forceupload' in sys.argv: forceupload=True + else: forceupload=False + manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog, forceupload) trysave(wikidata, os.path.join(logpath,sysid+'.wiki')) htmldata = wikitohtml(wiki_rootpath, sysid, wikidata, manifest) trysave(htmldata, os.path.join(logpath,sysid+'.html')) -- cgit v0.10.1 From 6c4b5bd3668467a9a65b6476440ba27d871d3037 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 23 Nov 2011 22:22:33 -0600 Subject: tweak patch, tweak pretty print diff --git a/patches/OpenCSG-1.3.1-FBO.patch b/patches/OpenCSG-1.3.1-FBO.patch index 234992d..f4b3fcc 100644 --- a/patches/OpenCSG-1.3.1-FBO.patch +++ b/patches/OpenCSG-1.3.1-FBO.patch @@ -1,7 +1,20 @@ -Only in OpenCSG-1.3.1-fbo-patch/: lib -diff -ur OpenCSG-1.3.1/src/frameBufferObject.cpp OpenCSG-1.3.1-fbo-patch/src/frameBufferObject.cpp +Only in OpenCSG-1.3.1-fbopatch/: lib +diff -ur OpenCSG-1.3.1/Makefile OpenCSG-1.3.1-fbopatch/Makefile +--- OpenCSG-1.3.1/Makefile 2010-06-09 14:39:58.000000000 -0500 ++++ OpenCSG-1.3.1-fbopatch/Makefile 2011-11-23 21:44:21.285641445 -0600 +@@ -1,4 +1,4 @@ +-SUBDIRS = glew src example ++SUBDIRS = src + + all: + for X in $(SUBDIRS); do make -C $$X ; done +Only in OpenCSG-1.3.1-fbopatch/src: area.o +Only in OpenCSG-1.3.1-fbopatch/src: batch.o +Only in OpenCSG-1.3.1-fbopatch/src: channelManager.o +Only in OpenCSG-1.3.1-fbopatch/src: context.o +diff -ur OpenCSG-1.3.1/src/frameBufferObject.cpp OpenCSG-1.3.1-fbopatch/src/frameBufferObject.cpp --- OpenCSG-1.3.1/src/frameBufferObject.cpp 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbo-patch/src/frameBufferObject.cpp 2011-11-23 21:42:42.709641637 -0600 ++++ OpenCSG-1.3.1-fbopatch/src/frameBufferObject.cpp 2011-11-23 22:19:33.545641258 -0600 @@ -3,8 +3,8 @@ // // This library is free software; you can redistribute it and/or @@ -30,10 +43,18 @@ diff -ur OpenCSG-1.3.1/src/frameBufferObject.cpp OpenCSG-1.3.1-fbo-patch/src/fra glBindTexture(GL_TEXTURE_2D, 0); textureTarget = GL_TEXTURE_2D; -Only in OpenCSG-1.3.1-fbo-patch/src: frameBufferObject.cpp~ -diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.cpp OpenCSG-1.3.1-fbo-patch/src/frameBufferObjectExt.cpp +@@ -135,7 +136,7 @@ + // Unbinds frame buffer texture. + bool FrameBufferObject::EndCapture() + { +- glBindFramebuffer(GL_FRAMEBUFFER, 0); ++ glBindFramebuffer(GL_FRAMEBUFFER, oldFramebufferID); + return true; + } + +diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.cpp OpenCSG-1.3.1-fbopatch/src/frameBufferObjectExt.cpp --- OpenCSG-1.3.1/src/frameBufferObjectExt.cpp 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbo-patch/src/frameBufferObjectExt.cpp 2011-11-23 21:07:00.073641732 -0600 ++++ OpenCSG-1.3.1-fbopatch/src/frameBufferObjectExt.cpp 2011-11-23 21:43:17.701638949 -0600 @@ -3,8 +3,8 @@ // // This library is free software; you can redistribute it and/or @@ -71,9 +92,9 @@ diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.cpp OpenCSG-1.3.1-fbo-patch/src/ return true; } -diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.h OpenCSG-1.3.1-fbo-patch/src/frameBufferObjectExt.h +diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.h OpenCSG-1.3.1-fbopatch/src/frameBufferObjectExt.h --- OpenCSG-1.3.1/src/frameBufferObjectExt.h 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbo-patch/src/frameBufferObjectExt.h 2011-11-23 21:07:15.529642039 -0600 ++++ OpenCSG-1.3.1-fbopatch/src/frameBufferObjectExt.h 2011-11-23 21:43:17.701638949 -0600 @@ -3,8 +3,8 @@ // // This library is free software; you can redistribute it and/or @@ -93,9 +114,10 @@ diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.h OpenCSG-1.3.1-fbo-patch/src/fr bool initialized; }; -diff -ur OpenCSG-1.3.1/src/frameBufferObject.h OpenCSG-1.3.1-fbo-patch/src/frameBufferObject.h +Only in OpenCSG-1.3.1-fbopatch/src: frameBufferObjectExt.o +diff -ur OpenCSG-1.3.1/src/frameBufferObject.h OpenCSG-1.3.1-fbopatch/src/frameBufferObject.h --- OpenCSG-1.3.1/src/frameBufferObject.h 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbo-patch/src/frameBufferObject.h 2011-11-23 21:37:07.565641308 -0600 ++++ OpenCSG-1.3.1-fbopatch/src/frameBufferObject.h 2011-11-23 21:43:17.701638949 -0600 @@ -3,8 +3,8 @@ // // This library is free software; you can redistribute it and/or @@ -115,3 +137,17 @@ diff -ur OpenCSG-1.3.1/src/frameBufferObject.h OpenCSG-1.3.1-fbo-patch/src/frame bool initialized; }; +Only in OpenCSG-1.3.1-fbopatch/src: frameBufferObject.o +Only in OpenCSG-1.3.1-fbopatch/src: occlusionQuery.o +Only in OpenCSG-1.3.1-fbopatch/src: offscreenBuffer.o +Only in OpenCSG-1.3.1-fbopatch/src: opencsgRender.o +Only in OpenCSG-1.3.1-fbopatch/src: openglHelper.o +Only in OpenCSG-1.3.1-fbopatch/src: pBufferTexture.o +Only in OpenCSG-1.3.1-fbopatch/src: primitiveHelper.o +Only in OpenCSG-1.3.1-fbopatch/src: primitive.o +Only in OpenCSG-1.3.1-fbopatch/src: renderGoldfeather.o +Only in OpenCSG-1.3.1-fbopatch/src: renderSCS.o +Only in OpenCSG-1.3.1-fbopatch/src: RenderTexture.o +Only in OpenCSG-1.3.1-fbopatch/src: scissorMemo.o +Only in OpenCSG-1.3.1-fbopatch/src: settings.o +Only in OpenCSG-1.3.1-fbopatch/src: stencilManager.o diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index ffc74eb..6377929 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -74,18 +74,20 @@ def read_sysinfo(filename): tmp = tmp.split('/')[0] renderer = tmp + data += read_gitinfo() + + data += 'Image comparison: PerceptualDiff by H. Yee' + + data = data.strip() + hexhash = hashlib.md5() hexhash.update(data) hexhash = hexhash.hexdigest()[-4:].upper() hash = '' for c in hexhash: hash += chr(ord(c)+97-48) - sysid = osplain + '_' + machine + '_' + renderer + '_' + hash sysid = sysid.lower() - - data += read_gitinfo() - data += 'Image comparison: PerceptualDiff by H. Yee' return data, sysid class Test: @@ -234,7 +236,7 @@ def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): x=re.sub("'''(.*?)'''","\\1",x) filestrs=re.findall('\[\[File\:(.*?)\|.*?\]\]',x) for f in filestrs: - newfile_html='' + newfile_html='' x=re.sub('\[\[File\:'+f+'\|.*?\]\]',newfile_html,x) dic = { '|}':'', '|-':'', '||':'', '|':'', '!!':'', '!':'', '\n\n':'\n

\n'} #order matters -- cgit v0.10.1 From 062244a3b15356defac5d3eee969e330a9447781 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 23 Nov 2011 22:27:11 -0600 Subject: fix pretty print sysid hash diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 6377929..97e99d5 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -80,8 +80,10 @@ def read_sysinfo(filename): data = data.strip() + # create 4 letter hash and stick on end of sysid + nondate_data = re.sub("\n.*?ompile date.*?\n","",data) hexhash = hashlib.md5() - hexhash.update(data) + hexhash.update(nondate_data) hexhash = hexhash.hexdigest()[-4:].upper() hash = '' for c in hexhash: hash += chr(ord(c)+97-48) -- cgit v0.10.1 From c2fb5d3650ffaa42c68e02891168c711d3b5f079 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 23 Nov 2011 22:40:06 -0600 Subject: fix pretty printer diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 97e99d5..fb88c2f 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -295,7 +295,7 @@ def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,bo if 'expected.png' in wikifile.lower(): image = site.Images[wikifile] if image.exists and forceupload==False: - print 'skipping ',wikifile, '(image with same name and size ',localsize,'already on wiki)' + print 'skipping',wikifile, '(already on wiki)' skip=True if not skip: print 'uploading',wikifile,'...' @@ -312,13 +312,13 @@ def main(): startdate, tests, enddate = parselog(testlog) tests = sorted(tests, key = lambda t:t.passed) sysinfo, sysid = read_sysinfo('sysinfo.txt') - if '--forceupload' in sys.argv: forceupload=True - else: forceupload=False - manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog, forceupload) + if '--forceupload' in sys.argv: forceupl=True + else: forceupl=False + manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, testlog) trysave(wikidata, os.path.join(logpath,sysid+'.wiki')) htmldata = wikitohtml(wiki_rootpath, sysid, wikidata, manifest) trysave(htmldata, os.path.join(logpath,sysid+'.html')) if '--upload' in sys.argv: - upload(wikisite,'',wikidata,manifest,wiki_rootpath,sysid,'openscadbot','tobdacsnepo',dryrun=False) + upload(wikisite,'',wikidata,manifest,wiki_rootpath,sysid,'openscadbot','tobdacsnepo',dryrun=False,forceupload=forceupl) main() -- cgit v0.10.1 From 2bd48629ef8482a957f7db0921a3b3c7fdc458e1 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sat, 26 Nov 2011 11:24:38 -0600 Subject: add CGAL version to info diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5e93680..f57e40e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -192,6 +192,7 @@ if (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") set(CMAKE_MODULE_PATH "${CGAL_DIR}") endif() find_package(CGAL REQUIRED) +message(STATUS "CGAL found in ${CGAL_USE_FILE} ${CGAL_INCLUDE_DIRS} ${CGAL_LIBRARIES_DIR}") include_directories(${CGAL_INCLUDE_DIRS}) # Internal includes diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index a3d5097..c962023 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -95,7 +95,7 @@ string info_dump(OffscreenView *glview) << "\nBoost version: " << BOOST_LIB_VERSION << "\nEigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION - // << "\nCGAL version: " << CGAL_VERSION ??? + << "\nCGAL version: " << TOSTRING(CGAL_VERSION) // << "\nOpenCSG" << ??? << "\n" << glview->getInfo() << "\n"; -- cgit v0.10.1 From 2454c85348b5d1c645d8fbe777cfe611dbb49131 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sat, 26 Nov 2011 13:43:40 -0600 Subject: improve html output, logging diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 4dd614b..2f533ab 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -240,6 +240,7 @@ def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): head = ''+wiki_rootpath+' test run for '+sysid +'' revmanifest = dict((val,key) for key, val in manifest.iteritems()) x=re.sub('\{\|(.*?)\n','\n',wikidata) + x=re.sub('\|(.*?colspan.*?)\|','', '||':'
',x) x=re.sub("'''(.*?)'''","\\1",x) filestrs=re.findall('\[\[File\:(.*?)\|.*?\]\]',x) for f in filestrs: @@ -270,28 +271,28 @@ def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,bo import mwclient except: print 'please download mwclient and unpack here:', os.cwd() - print 'open site',wikiurl + print 'opening site:',wikiurl if not api_php_path == '': site = mwclient.Site(wikiurl,api_php_path) else: site = mwclient.Site(wikiurl) - print 'bot login' + print 'bot login:', botname site.login(botname,botpass) - print 'edit ',wiki_rootpath + print 'edit page:',wiki_rootpath page = site.Pages[wiki_rootpath] text = page.edit() rootpage = wiki_rootpath + sysid if not '[['+rootpage+']]' in text: page.save(text +'\n*[['+rootpage+']]\n') - print 'upload wiki data to',rootpage + print 'upload wiki page:',rootpage page = site.Pages[rootpage] text = page.edit() page.save(wikidata) - print 'upload images' + print 'upload images:' for localfile in sorted(manifest.keys()): if localfile: localf = open(localfile,'rb') -- cgit v0.10.1 From 2376814f2c4dd6e34a765ca37275b136785b26fd Mon Sep 17 00:00:00 2001 From: Don Bright Date: Sat, 26 Nov 2011 21:35:53 -0600 Subject: make opencsg use framebuffer not pbuffer diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f604f73..5605f6a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -303,6 +303,7 @@ target_link_libraries(tests-cgal tests-common) add_library(tests-nocgal STATIC ${NOCGAL_SOURCES}) target_link_libraries(tests-nocgal tests-common) add_library(tests-offscreen STATIC ${OFFSCREEN_SOURCES}) +# set_target_properties(tests-offscreen PROPERTIES COMPILE_FLAGS "-DENABLE_OPENCSG -DENABLE_CGAL ${CGAL_CXX_FLAGS_INIT}") # # echotest diff --git a/tests/OffscreenView.cc b/tests/OffscreenView.cc index 9c8964c..61d5818 100644 --- a/tests/OffscreenView.cc +++ b/tests/OffscreenView.cc @@ -1,7 +1,6 @@ #include #include "OffscreenView.h" #include "system-gl.h" -#include #include "renderer.h" #include #include @@ -57,105 +56,13 @@ void OffscreenView::initializeGL() glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); -#ifdef ENABLE_OPENCSG - const char *openscad_disable_gl20_env = getenv("OPENSCAD_DISABLE_GL20"); - if (openscad_disable_gl20_env && !strcmp(openscad_disable_gl20_env, "0")) - openscad_disable_gl20_env = NULL; - if (glewIsSupported("GL_VERSION_2_0") && openscad_disable_gl20_env == NULL) - { - const char *vs_source = - "uniform float xscale, yscale;\n" - "attribute vec3 pos_b, pos_c;\n" - "attribute vec3 trig, mask;\n" - "varying vec3 tp, tr;\n" - "varying float shading;\n" - "void main() {\n" - " vec4 p0 = gl_ModelViewProjectionMatrix * gl_Vertex;\n" - " vec4 p1 = gl_ModelViewProjectionMatrix * vec4(pos_b, 1.0);\n" - " vec4 p2 = gl_ModelViewProjectionMatrix * vec4(pos_c, 1.0);\n" - " float a = distance(vec2(xscale*p1.x/p1.w, yscale*p1.y/p1.w), vec2(xscale*p2.x/p2.w, yscale*p2.y/p2.w));\n" - " float b = distance(vec2(xscale*p0.x/p0.w, yscale*p0.y/p0.w), vec2(xscale*p1.x/p1.w, yscale*p1.y/p1.w));\n" - " float c = distance(vec2(xscale*p0.x/p0.w, yscale*p0.y/p0.w), vec2(xscale*p2.x/p2.w, yscale*p2.y/p2.w));\n" - " float s = (a + b + c) / 2.0;\n" - " float A = sqrt(s*(s-a)*(s-b)*(s-c));\n" - " float ha = 2.0*A/a;\n" - " gl_Position = p0;\n" - " tp = mask * ha;\n" - " tr = trig;\n" - " vec3 normal, lightDir;\n" - " normal = normalize(gl_NormalMatrix * gl_Normal);\n" - " lightDir = normalize(vec3(gl_LightSource[0].position));\n" - " shading = abs(dot(normal, lightDir));\n" - "}\n"; - - const char *fs_source = - "uniform vec4 color1, color2;\n" - "varying vec3 tp, tr, tmp;\n" - "varying float shading;\n" - "void main() {\n" - " gl_FragColor = vec4(color1.r * shading, color1.g * shading, color1.b * shading, color1.a);\n" - " if (tp.x < tr.x || tp.y < tr.y || tp.z < tr.z)\n" - " gl_FragColor = color2;\n" - "}\n"; - - GLuint vs = glCreateShader(GL_VERTEX_SHADER); - glShaderSource(vs, 1, (const GLchar**)&vs_source, NULL); - glCompileShader(vs); - - GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); - glShaderSource(fs, 1, (const GLchar**)&fs_source, NULL); - glCompileShader(fs); - - GLuint edgeshader_prog = glCreateProgram(); - glAttachShader(edgeshader_prog, vs); - glAttachShader(edgeshader_prog, fs); - glLinkProgram(edgeshader_prog); - - shaderinfo[0] = edgeshader_prog; - shaderinfo[1] = glGetUniformLocation(edgeshader_prog, "color1"); - shaderinfo[2] = glGetUniformLocation(edgeshader_prog, "color2"); - shaderinfo[3] = glGetAttribLocation(edgeshader_prog, "trig"); - shaderinfo[4] = glGetAttribLocation(edgeshader_prog, "pos_b"); - shaderinfo[5] = glGetAttribLocation(edgeshader_prog, "pos_c"); - shaderinfo[6] = glGetAttribLocation(edgeshader_prog, "mask"); - shaderinfo[7] = glGetUniformLocation(edgeshader_prog, "xscale"); - shaderinfo[8] = glGetUniformLocation(edgeshader_prog, "yscale"); - - GLenum err = glGetError(); - if (err != GL_NO_ERROR) { - fprintf(stderr, "OpenGL Error: %s\n", gluErrorString(err)); - } - - GLint status; - glGetProgramiv(edgeshader_prog, GL_LINK_STATUS, &status); - if (status == GL_FALSE) { - int loglen; - char logbuffer[1000]; - glGetProgramInfoLog(edgeshader_prog, sizeof(logbuffer), &loglen, logbuffer); - fprintf(stderr, "OpenGL Program Linker Error:\n%.*s", loglen, logbuffer); - } else { - int loglen; - char logbuffer[1000]; - glGetProgramInfoLog(edgeshader_prog, sizeof(logbuffer), &loglen, logbuffer); - if (loglen > 0) { - fprintf(stderr, "OpenGL Program Link OK:\n%.*s", loglen, logbuffer); - } - glValidateProgram(edgeshader_prog); - glGetProgramInfoLog(edgeshader_prog, sizeof(logbuffer), &loglen, logbuffer); - if (loglen > 0) { - fprintf(stderr, "OpenGL Program Validation results:\n%.*s", loglen, logbuffer); - } - } - } -#endif /* ENABLE_OPENCSG */ + } void OffscreenView::resizeGL(int w, int h) { -#ifdef ENABLE_OPENCSG - shaderinfo[9] = w; - shaderinfo[10] = h; -#endif + this->width = w; + this->height = h; glViewport(0, 0, w, h); w_h_ratio = sqrt((double)w / (double)h); } @@ -226,9 +133,6 @@ void OffscreenView::paintGL() glColor3d(1.0, 0.0, 0.0); if (this->renderer) { -#ifdef ENABLE_OPENCSG - OpenCSG::setContext(0); -#endif this->renderer->draw(showfaces, showedges); } } diff --git a/tests/OffscreenView.h b/tests/OffscreenView.h index 2e35921..8b98b29 100644 --- a/tests/OffscreenView.h +++ b/tests/OffscreenView.h @@ -27,6 +27,8 @@ public: GLint shaderinfo[11]; OffscreenContext *ctx; + size_t width; + size_t height; private: Renderer *renderer; double w_h_ratio; diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index c962023..418738d 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -14,6 +14,7 @@ #include "CGALEvaluator.h" #include "PolySetCGALEvaluator.h" +#include #include "OpenCSGRenderer.h" #include "ThrownTogetherRenderer.h" @@ -128,6 +129,102 @@ po::variables_map parse_options(int argc, char *argv[]) return vm; } +void enable_opencsg_shaders( OffscreenView *glview ) +{ + bool ignore_gl_version = true; + const char *openscad_disable_gl20_env = getenv("OPENSCAD_DISABLE_GL20"); + if (openscad_disable_gl20_env && !strcmp(openscad_disable_gl20_env, "0")) + openscad_disable_gl20_env = NULL; + if (glewIsSupported("GL_VERSION_2_0") && openscad_disable_gl20_env == NULL ) + { + const char *vs_source = + "uniform float xscale, yscale;\n" + "attribute vec3 pos_b, pos_c;\n" + "attribute vec3 trig, mask;\n" + "varying vec3 tp, tr;\n" + "varying float shading;\n" + "void main() {\n" + " vec4 p0 = gl_ModelViewProjectionMatrix * gl_Vertex;\n" + " vec4 p1 = gl_ModelViewProjectionMatrix * vec4(pos_b, 1.0);\n" + " vec4 p2 = gl_ModelViewProjectionMatrix * vec4(pos_c, 1.0);\n" + " float a = distance(vec2(xscale*p1.x/p1.w, yscale*p1.y/p1.w), vec2(xscale*p2.x/p2.w, yscale*p2.y/p2.w));\n" + " float b = distance(vec2(xscale*p0.x/p0.w, yscale*p0.y/p0.w), vec2(xscale*p1.x/p1.w, yscale*p1.y/p1.w));\n" + " float c = distance(vec2(xscale*p0.x/p0.w, yscale*p0.y/p0.w), vec2(xscale*p2.x/p2.w, yscale*p2.y/p2.w));\n" + " float s = (a + b + c) / 2.0;\n" + " float A = sqrt(s*(s-a)*(s-b)*(s-c));\n" + " float ha = 2.0*A/a;\n" + " gl_Position = p0;\n" + " tp = mask * ha;\n" + " tr = trig;\n" + " vec3 normal, lightDir;\n" + " normal = normalize(gl_NormalMatrix * gl_Normal);\n" + " lightDir = normalize(vec3(gl_LightSource[0].position));\n" + " shading = abs(dot(normal, lightDir));\n" + "}\n"; + + const char *fs_source = + "uniform vec4 color1, color2;\n" + "varying vec3 tp, tr, tmp;\n" + "varying float shading;\n" + "void main() {\n" + " gl_FragColor = vec4(color1.r * shading, color1.g * shading, color1.b * shading, color1.a);\n" + " if (tp.x < tr.x || tp.y < tr.y || tp.z < tr.z)\n" + " gl_FragColor = color2;\n" + "}\n"; + + GLuint vs = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vs, 1, (const GLchar**)&vs_source, NULL); + glCompileShader(vs); + + GLuint fs = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fs, 1, (const GLchar**)&fs_source, NULL); + glCompileShader(fs); + + GLuint edgeshader_prog = glCreateProgram(); + glAttachShader(edgeshader_prog, vs); + glAttachShader(edgeshader_prog, fs); + glLinkProgram(edgeshader_prog); + + glview->shaderinfo[0] = edgeshader_prog; + glview->shaderinfo[1] = glGetUniformLocation(edgeshader_prog, "color1"); + glview->shaderinfo[2] = glGetUniformLocation(edgeshader_prog, "color2"); + glview->shaderinfo[3] = glGetAttribLocation(edgeshader_prog, "trig"); + glview->shaderinfo[4] = glGetAttribLocation(edgeshader_prog, "pos_b"); + glview->shaderinfo[5] = glGetAttribLocation(edgeshader_prog, "pos_c"); + glview->shaderinfo[6] = glGetAttribLocation(edgeshader_prog, "mask"); + glview->shaderinfo[7] = glGetUniformLocation(edgeshader_prog, "xscale"); + glview->shaderinfo[8] = glGetUniformLocation(edgeshader_prog, "yscale"); + + GLenum err = glGetError(); + if (err != GL_NO_ERROR) { + fprintf(stderr, "OpenGL Error: %s\n", gluErrorString(err)); + } + + GLint status; + glGetProgramiv(edgeshader_prog, GL_LINK_STATUS, &status); + if (status == GL_FALSE) { + int loglen; + char logbuffer[1000]; + glGetProgramInfoLog(edgeshader_prog, sizeof(logbuffer), &loglen, logbuffer); + fprintf(stderr, "OpenGL Program Linker Error:\n%.*s", loglen, logbuffer); + } else { + int loglen; + char logbuffer[1000]; + glGetProgramInfoLog(edgeshader_prog, sizeof(logbuffer), &loglen, logbuffer); + if (loglen > 0) { + fprintf(stderr, "OpenGL Program Link OK:\n%.*s", loglen, logbuffer); + } + glValidateProgram(edgeshader_prog); + glGetProgramInfoLog(edgeshader_prog, sizeof(logbuffer), &loglen, logbuffer); + if (loglen > 0) { + fprintf(stderr, "OpenGL Program Validation results:\n%.*s", loglen, logbuffer); + } + } + } + glview->shaderinfo[9] = glview->width; + glview->shaderinfo[10] = glview->height; +} + int csgtestcore(int argc, char *argv[], test_type_e test_type) { bool sysinfo_dump = false; @@ -270,6 +367,8 @@ 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); } + enable_opencsg_shaders(csgInfo.glview); + if (sysinfo_dump) cout << info_dump(csgInfo.glview); BoundingBox bbox = csgInfo.root_chain->getBoundingBox(); @@ -289,8 +388,11 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) else csgInfo.glview->setRenderer(&opencsgRenderer); - csgInfo.glview->paintGL(); + OpenCSG::setContext(0); + OpenCSG::setOption(OpenCSG::OffscreenSetting, OpenCSG::FrameBufferObject); + csgInfo.glview->paintGL(); + csgInfo.glview->save(outfilename); Builtins::instance(true); -- cgit v0.10.1 From e077b31865bb15866e07928d505e563186116b0a Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 29 Nov 2011 22:15:07 -0600 Subject: enable uploading of build.make and flags.make files to wiki diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 2f533ab..82ece3d 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -8,7 +8,7 @@ # python test_pretty_print.py --upload # todo -# ban opencsg<2.0 from opencsgtest +# do something if tests for opencsg extensions fail (fail, no image production) # copy all images, sysinfo.txt to bundle for html/upload (images # can be altered by subsequent runs) # figure out hwo to make the thing run after the test @@ -17,7 +17,7 @@ # instead of having special '-info' prerun, put it as yet-another-test # and parse the log -import string,sys,re,os,hashlib,subprocess +import string,sys,re,os,hashlib,subprocess,textwrap def tryread(filename): data = None @@ -81,7 +81,7 @@ def read_sysinfo(filename): data = data.strip() # create 4 letter hash and stick on end of sysid - nondate_data = re.sub("\n.*?ompile date.*?\n","",data) + nondate_data = re.sub("\n.*?ompile date.*?\n","\n",data).strip() hexhash = hashlib.md5() hexhash.update(nondate_data) hexhash = hexhash.hexdigest()[-4:].upper() @@ -144,8 +144,22 @@ def wikify_filename(testname,filename,sysid): actual = ezsearch(os.sep+'.*?-output.*?(actual.*)',filename) if actual!='': result += sysid+'_'+actual - return result.replace('/','_') - + return result.replace('/','_').replace('\\','_') + +def parsemakes_towiki(wiki_rootpath, sysid): + filelist = [] + for root, dirs, files in os.walk('.'): + for fname in files: filelist += [ os.path.join(root, fname) ] + files = filter(lambda x: 'build.make' in os.path.basename(x), filelist) + files += filter(lambda x: 'flags.make' in os.path.basename(x), filelist) + manifest = {} + for fname in files: + wikifname = fname.replace('/','_').replace('\\','_').strip('.') + wikifname = wikifname.replace('CMakeFiles','').replace('.dir','') + manifest[fname] = wiki_rootpath + '_' + sysid + '_' + wikifname + wikicode = "\n'''build.make and flags.make'''\n\n\n" + for key in sorted(manifest.keys()): wikicode += '*[[' + manifest[key] + ']]\n' + return manifest, wikicode def towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid): @@ -252,60 +266,67 @@ def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): x=re.sub("\[\[(.*?)\]\]","\\1",x) return head + x + '' -def upload_dryrun(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass): - print 'dry run. no files to be uploaded' - print 'log in', wikiurl, api_php_path, botname, botpass - print 'save ' + '*[['+wiki_rootpath+sysid+']]' + ' to page ' + wiki_rootpath - print 'save ', len(wikidata), ' bytes to page ',wiki_rootpath+sysid - for localfile in manifest.keys(): - if localfile: - localf=open(localfile,'rb') - wikifile = manifest[localfile] - print 'upload',localfile,wikifile - def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass,dryrun=True,forceupload=False): - if dryrun: - upload_dryrun(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass) - return None + if dryrun: print 'dry run' try: import mwclient except: print 'please download mwclient and unpack here:', os.cwd() print 'opening site:',wikiurl - if not api_php_path == '': - site = mwclient.Site(wikiurl,api_php_path) - else: - site = mwclient.Site(wikiurl) + if not dryrun: + if not api_php_path == '': + site = mwclient.Site(wikiurl,api_php_path) + else: + site = mwclient.Site(wikiurl) print 'bot login:', botname - site.login(botname,botpass) + if not dryrun: site.login(botname,botpass) print 'edit page:',wiki_rootpath - page = site.Pages[wiki_rootpath] - text = page.edit() rootpage = wiki_rootpath + sysid - if not '[['+rootpage+']]' in text: - page.save(text +'\n*[['+rootpage+']]\n') + if not dryrun: + page = site.Pages[wiki_rootpath] + text = page.edit() + if not '[['+rootpage+']]' in text: + page.save(text +'\n*[['+rootpage+']]\n') print 'upload wiki page:',rootpage - page = site.Pages[rootpage] - text = page.edit() - page.save(wikidata) + if not dryrun: + page = site.Pages[rootpage] + text = page.edit() + page.save(wikidata) print 'upload images:' - for localfile in sorted(manifest.keys()): + imagekeys = filter(lambda x: x.endswith('.png'), manifest.keys()) + for localfile in sorted(imagekeys): if localfile: localf = open(localfile,'rb') wikifile = manifest[localfile] skip=False if 'expected.png' in wikifile.lower(): - image = site.Images[wikifile] - if image.exists and forceupload==False: - print 'skipping',wikifile, '(already on wiki)' - skip=True + if not dryrun: + image = site.Images[wikifile] + if image.exists and forceupload==False: + print 'skipping',wikifile, '(already on wiki)' + skip=True if not skip: print 'uploading',wikifile,'...' - site.upload(localf,wikifile,wiki_rootpath + ' test', ignore=True) + if not dryrun: + site.upload(localf,wikifile,wiki_rootpath + ' test', ignore=True) + + print 'upload makefiles:' + makekeys = filter(lambda x: x.endswith('.make'), manifest.keys()) + for localfile in sorted(makekeys): + if localfile: + localf = open(localfile,'rb') + wikifile = manifest[localfile] + print 'uploading',wikifile,'...' + if not dryrun: + page = site.Pages[wikifile] + text = page.edit() + page.save('
\n'+localf.read()+'\n
') + + #wikisite = 'cakebaby.referata.com' #wiki_api_path = '' @@ -323,11 +344,19 @@ def main(): sysinfo, sysid = read_sysinfo('sysinfo.txt') if '--forceupload' in sys.argv: forceupl=True else: forceupl=False + if '--dryrun' in sys.argv: dry=True + else: dry=False + + manifest_makes, wiki_makes = parsemakes_towiki(wiki_rootpath, sysid) manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid) + manifest.update(manifest_makes) + wikidata += wiki_makes trysave(wikidata, os.path.join(logpath,sysid+'.wiki')) htmldata = wikitohtml(wiki_rootpath, sysid, wikidata, manifest) trysave(htmldata, os.path.join(logpath,sysid+'.html')) if '--upload' in sys.argv: - upload(wikisite,wiki_api_path,wikidata,manifest,wiki_rootpath,sysid,'openscadbot','tobdacsnepo',dryrun=False,forceupload=forceupl) + upload(wikisite,wiki_api_path,wikidata,manifest,wiki_rootpath,sysid,'openscadbot','tobdacsnepo',dryrun=dry,forceupload=forceupl) + + main() -- cgit v0.10.1 From 988a88a64f0ee44426605c2b522588921f2a1890 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 29 Nov 2011 20:41:28 -0600 Subject: simplify test_pretty_print to work better with multiple page uploads diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 82ece3d..3f5041d 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -22,18 +22,19 @@ import string,sys,re,os,hashlib,subprocess,textwrap def tryread(filename): data = None try: - print 'reading', filename - f = open(filename) + f = open(filename,'rb') data = f.read() f.close() except: print 'couldn\'t open ',filename return data -def trysave(data,filename): +def trysave(filename,data): try: - f=open(filename,'w') - print 'writing',len(data),'bytes to',filename + if not os.path.isdir(os.path.dirname(filename)): + print 'creating',os.path.dirname(filename) + os.mkdir(os.path.dirname(filename)) + f=open(filename,'wb') f.write(data) f.close() except: @@ -125,6 +126,8 @@ def parsetest(teststring): ] hits = map( lambda pattern: ezsearch(pattern,teststring), patterns ) test = Test(hits[0],hits[1],hits[2]=='Passed',hits[3],hits[4],hits[5],hits[6],hits[7],teststring) + test.actualfile_data = tryread(test.actualfile) + test.expectedfile_data = tryread(test.expectedfile) return test def parselog(data): @@ -133,35 +136,26 @@ def parselog(data): pattern = '([0-9]*/[0-9]* Testing:.*?time elapsed.*?\n)' test_chunks = re.findall(pattern,data,re.S) tests = map( parsetest, test_chunks ) - print 'found', len(tests),'test results' + tests = sorted(tests, key = lambda t:t.passed) return startdate, tests, enddate -def wikify_filename(testname,filename,sysid): - # translate from local system to wiki style filename. - result = wiki_rootpath+'_'+testname+'_' - expected = ezsearch('(expected....$)',filename) - if expected!='': result += expected - actual = ezsearch(os.sep+'.*?-output.*?(actual.*)',filename) - if actual!='': - result += sysid+'_'+actual - return result.replace('/','_').replace('\\','_') - -def parsemakes_towiki(wiki_rootpath, sysid): +def load_makefiles(builddir): filelist = [] - for root, dirs, files in os.walk('.'): + for root, dirs, files in os.walk(builddir): for fname in files: filelist += [ os.path.join(root, fname) ] files = filter(lambda x: 'build.make' in os.path.basename(x), filelist) files += filter(lambda x: 'flags.make' in os.path.basename(x), filelist) - manifest = {} + files = filter(lambda x: 'esting' not in x and 'emporary' not in x, files) + result = {} for fname in files: - wikifname = fname.replace('/','_').replace('\\','_').strip('.') - wikifname = wikifname.replace('CMakeFiles','').replace('.dir','') - manifest[fname] = wiki_rootpath + '_' + sysid + '_' + wikifname - wikicode = "\n'''build.make and flags.make'''\n\n\n" - for key in sorted(manifest.keys()): wikicode += '*[[' + manifest[key] + ']]\n' - return manifest, wikicode + result[fname.replace(builddir,'')] = open(fname,'rb').read() + return result + +def wikify_filename(fname, wiki_rootpath, sysid): + wikifname = fname.replace('/','_').replace('\\','_').strip('.') + return wiki_rootpath + '_' + sysid + '_' + wikifname -def towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid): +def towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles): wiki_template = """

[[WIKI_ROOTPATH]] test run report

@@ -209,8 +203,13 @@ TESTLOG |} - +'''build.make and flags.make''' + +*[[MAKEFILE_NAME]] + """ + txtpages = {} + imgs = {} passed_tests = filter(lambda x: x.passed, tests) failed_tests = filter(lambda x: not x.passed, tests) percent = str(int(100.0*len(passed_tests) / len(tests))) @@ -218,6 +217,7 @@ TESTLOG s = wiki_template repeat1 = ezsearch('(.*?)',s) repeat2 = ezsearch('(.*?)',s) + repeat3 = ezsearch('(.*?)',s) dic = { 'STARTDATE': startdate, 'ENDDATE': enddate, 'WIKI_ROOTPATH': wiki_rootpath, 'SYSINFO': sysinfo, 'SYSID':sysid, 'NUMTESTS':len(tests), 'NUMPASSED':len(passed_tests), 'PERCENTPASSED':percent } @@ -231,24 +231,43 @@ TESTLOG newchunk = re.sub('FTESTNAME',t.fullname,repeat2) s = s.replace(repeat2, newchunk+repeat2) elif t.type=='png': - manifest[t.actualfile] = wikify_filename(t.fullname,t.actualfile,sysid) - manifest[t.expectedfile] = wikify_filename(t.fullname,t.expectedfile,sysid) + tmp = t.actualfile.replace(builddir,'') + wikiname_a = wikify_filename(tmp,wiki_rootpath,sysid) + # erase /home/whatever/openscad/tests/regression + tmp = t.expectedfile.replace(os.path.dirname(builddir),'') + wikiname_e = wikify_filename(tmp,wiki_rootpath,sysid) + imgs[wikiname_e] = t.expectedfile_data if t.actualfile: - actualfile_wiki = '[[File:'+manifest[t.actualfile]+'|250px]]' + actualfile_wiki = '[[File:'+wikiname_a+'|250px]]' + imgs[wikiname_a] = t.actualfile_data else: actualfile_wiki = 'No image generated.' newchunk = re.sub('FTESTNAME',t.fullname,repeat1) newchunk = newchunk.replace('ACTUALFILE_WIKI',actualfile_wiki) - newchunk = newchunk.replace('EXPECTEDFILE',manifest[t.expectedfile]) + newchunk = newchunk.replace('EXPECTEDFILE',wikiname_e) newchunk = newchunk.replace('TESTLOG',t.fulltestlog) s = s.replace(repeat1, newchunk+repeat1) + makefiles_wikinames = {} + for mf in sorted(makefiles.keys()): + tmp = mf.replace('CMakeFiles','').replace('.dir','') + wikiname = wikify_filename(tmp,wiki_rootpath,sysid) + newchunk = re.sub('MAKEFILE_NAME',wikiname,repeat3) + s = s.replace(repeat3, newchunk+repeat3) + makefiles_wikinames[mf] = wikiname + s = s.replace(repeat1,'') s = s.replace(repeat2,'') + s = s.replace(repeat3,'') s = re.sub('\n','',s) s = re.sub('','',s) - return manifest, s + mainpage_wikiname = wiki_rootpath + '_' + sysid + '_test_report' + txtpages[ mainpage_wikiname ] = s + for mf in sorted(makefiles.keys()): + txtpages[ makefiles_wikinames[ mf ] ] = '
\n'+makefiles[mf]+'\n
' + + return imgs, txtpages def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): head = ''+wiki_rootpath+' test run for '+sysid +'' @@ -266,97 +285,89 @@ def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): x=re.sub("\[\[(.*?)\]\]","\\1",x) return head + x + '' -def upload(wikiurl,api_php_path,wikidata,manifest,wiki_rootpath,sysid,botname,botpass,dryrun=True,forceupload=False): +def upload(wikiurl,api_php_path='/',wiki_rootpath='test', sysid='null', botname='cakebaby',botpass='anniew',wikidir='.',dryrun=True): + wetrun = not dryrun if dryrun: print 'dry run' try: import mwclient except: - print 'please download mwclient and unpack here:', os.cwd() + print 'please download mwclient and unpack here:', os.getcwd() + sys.exit() print 'opening site:',wikiurl - if not dryrun: - if not api_php_path == '': - site = mwclient.Site(wikiurl,api_php_path) - else: - site = mwclient.Site(wikiurl) + if wetrun: + site = mwclient.Site(wikiurl,api_php_path) print 'bot login:', botname - if not dryrun: site.login(botname,botpass) - - print 'edit page:',wiki_rootpath - rootpage = wiki_rootpath + sysid - if not dryrun: + if wetrun: site.login(botname,botpass) + + wikifiles = os.listdir(wikidir) + testreport_page = filter( lambda x: 'test_report' in x, wikifiles ) + if (len(testreport_page)>1): + print 'multiple test reports found, please clean dir',wikidir + sys.exit() + rootpage = testreport_page[0] + print 'add',rootpage,' to main report page ',wiki_rootpath + if wetrun: page = site.Pages[wiki_rootpath] text = page.edit() if not '[['+rootpage+']]' in text: page.save(text +'\n*[['+rootpage+']]\n') - print 'upload wiki page:',rootpage - if not dryrun: - page = site.Pages[rootpage] - text = page.edit() - page.save(wikidata) - - print 'upload images:' - imagekeys = filter(lambda x: x.endswith('.png'), manifest.keys()) - for localfile in sorted(imagekeys): - if localfile: - localf = open(localfile,'rb') - wikifile = manifest[localfile] - skip=False - if 'expected.png' in wikifile.lower(): - if not dryrun: - image = site.Images[wikifile] - if image.exists and forceupload==False: - print 'skipping',wikifile, '(already on wiki)' - skip=True - if not skip: - print 'uploading',wikifile,'...' - if not dryrun: - site.upload(localf,wikifile,wiki_rootpath + ' test', ignore=True) - - print 'upload makefiles:' - makekeys = filter(lambda x: x.endswith('.make'), manifest.keys()) - for localfile in sorted(makekeys): - if localfile: - localf = open(localfile,'rb') - wikifile = manifest[localfile] - print 'uploading',wikifile,'...' - if not dryrun: - page = site.Pages[wikifile] + wikifiles = os.listdir(wikidir) + print 'upload wiki pages:' + for wikiname in wikifiles: + filename = os.path.join(wikidir,wikiname) + filedata = tryread(filename) + print 'upload',len(filedata),'bytes from',wikiname,'...', + sys.stdout.flush() + if wikiname.endswith('.png'): + localf = open(filename,'rb') # mwclient needs file handle + descrip = wiki_rootpath + ' test' + if wetrun: + site.upload(localf,wikiname,descrip,ignore=True) + print 'image uploaded' + else: # textpage + if wetrun: + page = site.Pages[wikiname] text = page.edit() - page.save('
\n'+localf.read()+'\n
') + page.save(filedata) + print 'text page uploaded' + +def findlogfile(builddir): + logpath = os.path.join(builddir,'Testing','Temporary') + logfilename = os.path.join(logpath,'LastTest.log') + return logpath, logfilename + +def main(): + dry = False + if '--dryrun' in sys.argv: dry=True + print 'build dir set to', builddir + + sysinfo, sysid = read_sysinfo(os.path.join(builddir,'sysinfo.txt')) + makefiles = load_makefiles(builddir) + logpath, logfilename = findlogfile(builddir) + testlog = tryread(logfilename) + startdate, tests, enddate = parselog(testlog) + print 'found sysinfo.txt' + print 'found', len(makefiles),'makefiles' + print 'found', len(tests),'test results' + imgs, txtpages = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles) + wikidir = os.path.join(logpath,'wiki') + print 'writing',len(imgs),'images and',len(txtpages),'wiki pages to:\n ', wikidir + for k in sorted(imgs): trysave( os.path.join(wikidir,k), imgs[k]) + for k in sorted(txtpages): trysave( os.path.join(wikidir,k), txtpages[k]) + if '--upload' in sys.argv: + upload(wikisite,wiki_api_path,wiki_rootpath,sysid,'openscadbot', + 'tobdacsnepo',wikidir,dryrun=dry) + #wikisite = 'cakebaby.referata.com' #wiki_api_path = '' wikisite = 'cakebaby.wikia.com' wiki_api_path = '/' wiki_rootpath = 'OpenSCAD' -builddir = os.getcwd() -logpath = os.path.join(builddir,'Testing','Temporary') -logfilename = os.path.join(logpath,'LastTest.log') - -def main(): - testlog = tryread(logfilename) - startdate, tests, enddate = parselog(testlog) - tests = sorted(tests, key = lambda t:t.passed) - sysinfo, sysid = read_sysinfo('sysinfo.txt') - if '--forceupload' in sys.argv: forceupl=True - else: forceupl=False - if '--dryrun' in sys.argv: dry=True - else: dry=False - - manifest_makes, wiki_makes = parsemakes_towiki(wiki_rootpath, sysid) - manifest, wikidata = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid) - manifest.update(manifest_makes) - wikidata += wiki_makes - trysave(wikidata, os.path.join(logpath,sysid+'.wiki')) - htmldata = wikitohtml(wiki_rootpath, sysid, wikidata, manifest) - trysave(htmldata, os.path.join(logpath,sysid+'.html')) - if '--upload' in sys.argv: - upload(wikisite,wiki_api_path,wikidata,manifest,wiki_rootpath,sysid,'openscadbot','tobdacsnepo',dryrun=dry,forceupload=forceupl) - +builddir = os.getcwd() # os.getcwd()+'/build' main() - -- cgit v0.10.1 From bcc6120f9b7ce4187c56e0f83dd021674ccdec80 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 29 Nov 2011 20:57:44 -0600 Subject: tweak pretty print diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 3f5041d..6931c35 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -2,7 +2,7 @@ # # This program 'pretty prints' the ctest output, namely # files from builddir/Testing/Temporary. -# html & wiki output are produced +# html & wiki output are produced in Testing/Temporary/wiki # wiki uploading is available by running # # python test_pretty_print.py --upload @@ -17,6 +17,7 @@ # instead of having special '-info' prerun, put it as yet-another-test # and parse the log + import string,sys,re,os,hashlib,subprocess,textwrap def tryread(filename): @@ -88,6 +89,7 @@ def read_sysinfo(filename): hexhash = hexhash.hexdigest()[-4:].upper() hash = '' for c in hexhash: hash += chr(ord(c)+97-48) + sysid = osplain + '_' + machine + '_' + renderer + '_' + hash sysid = sysid.lower() @@ -233,7 +235,6 @@ TESTLOG elif t.type=='png': tmp = t.actualfile.replace(builddir,'') wikiname_a = wikify_filename(tmp,wiki_rootpath,sysid) - # erase /home/whatever/openscad/tests/regression tmp = t.expectedfile.replace(os.path.dirname(builddir),'') wikiname_e = wikify_filename(tmp,wiki_rootpath,sysid) imgs[wikiname_e] = t.expectedfile_data @@ -265,7 +266,7 @@ TESTLOG mainpage_wikiname = wiki_rootpath + '_' + sysid + '_test_report' txtpages[ mainpage_wikiname ] = s for mf in sorted(makefiles.keys()): - txtpages[ makefiles_wikinames[ mf ] ] = '
\n'+makefiles[mf]+'\n
' + txtpages[ makefiles_wikinames[ mf ] ] = '\n*Subreport from [['+mainpage_wikiname+']]\n\n\n
\n'+makefiles[mf]+'\n
' return imgs, txtpages -- cgit v0.10.1 From 40815157a49892078905d3e55ca70722cbb89ac5 Mon Sep 17 00:00:00 2001 From: don bright Date: Wed, 30 Nov 2011 05:15:57 -0600 Subject: add 'finis' diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 6931c35..62ed062 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -8,7 +8,8 @@ # python test_pretty_print.py --upload # todo -# do something if tests for opencsg extensions fail (fail, no image production) +# repair html output +# do something if tests for GL extensions for OpenCSG fail (test fail, no image production) # copy all images, sysinfo.txt to bundle for html/upload (images # can be altered by subsequent runs) # figure out hwo to make the thing run after the test @@ -16,7 +17,9 @@ # why is hash differing # instead of having special '-info' prerun, put it as yet-another-test # and parse the log - +# fix windows so that it won't keep asking 'this program crashed' over and over. +# (you can set this in the registry to never happen, but itd be better if the program +# itself was able to disable that temporarily in it's own process) import string,sys,re,os,hashlib,subprocess,textwrap @@ -215,7 +218,6 @@ TESTLOG passed_tests = filter(lambda x: x.passed, tests) failed_tests = filter(lambda x: not x.passed, tests) percent = str(int(100.0*len(passed_tests) / len(tests))) - manifest = {} s = wiki_template repeat1 = ezsearch('(.*?)',s) repeat2 = ezsearch('(.*?)',s) @@ -271,6 +273,7 @@ TESTLOG return imgs, txtpages def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): + # temporarily defunct/broken head = ''+wiki_rootpath+' test run for '+sysid +'' revmanifest = dict((val,key) for key, val in manifest.iteritems()) x=re.sub('\{\|(.*?)\n','\n',wikidata) @@ -364,6 +367,8 @@ def main(): upload(wikisite,wiki_api_path,wiki_rootpath,sysid,'openscadbot', 'tobdacsnepo',wikidir,dryrun=dry) + print 'test_pretty_print complete' + #wikisite = 'cakebaby.referata.com' #wiki_api_path = '' wikisite = 'cakebaby.wikia.com' -- cgit v0.10.1 From b1b46e80707e0ca79f1dfb6aad67f44c7a8d719e Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 30 Nov 2011 22:24:14 -0600 Subject: fix up testing, add opencsg version info diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ac021e5..58df471 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -27,11 +27,7 @@ endif() if(WIN32_STATIC_BUILD) if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") - set(EMSG "\nTo build Win32 STATIC OpenSCAD tests you must run") - set(EMSG "${EMSG} \ncmake .. -DCMAKE_BUILD_TYPE=Release") - set(EMSG "${EMSG} \nthen replace /MD with /MT in CMakeCache.txt") - set(EMSG "${EMSG} \ni.e. sed -i s/\\/MD/\\/MT/ CMakeCache.txt") - set(EMSG "${EMSG} \nthen re-run cmake ..") + set(EMSG "\nTo build Win32 STATIC OpenSCAD please see doc/testing.txt") message(FATAL_ERROR ${EMSG}) endif() endif() @@ -158,7 +154,9 @@ include_directories(${OPENCSG_INCLUDE_DIR}) # GLEW -if (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") +if (NOT $ENV{GLEW_DIR} STREQUAL "") + set(GLEW_DIR "$ENV{GLEW_DIR}") +elseif (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") set(GLEW_DIR "$ENV{MACOSX_DEPLOY_DIR}") endif() @@ -195,8 +193,13 @@ elseif (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") set(CGAL_DIR "$ENV{MACOSX_DEPLOY_DIR}/lib/CGAL") set(CMAKE_MODULE_PATH "${CGAL_DIR}") endif() +message(STATUS "CGAL_DIR: " ${CGAL_DIR}) find_package(CGAL REQUIRED) -message(STATUS "CGAL found in ${CGAL_USE_FILE} ${CGAL_INCLUDE_DIRS} ${CGAL_LIBRARIES_DIR}") +message(STATUS "CGAL config found in " ${CGAL_USE_FILE} ) +foreach(cgal_incdir ${CGAL_INCLUDE_DIRS}) + message(STATUS "CGAL include found in " ${cgal_incdir} ) +endforeach() +message(STATUS "CGAL libraries found in " ${CGAL_LIBRARIES_DIR} ) if("${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}" VERSION_LESS 3.6) message(FATAL_ERROR "CGAL >= 3.6 required") endif() @@ -255,7 +258,7 @@ set(NOCGAL_SOURCES set(CGAL_SOURCES ${NOCGAL_SOURCES} - ../src/CSGTermEvaluator.cc + ../src/CSGTermEvaluator.cc ../src/CGAL_Nef_polyhedron.cc ../src/cgalutils.cc ../src/CGALEvaluator.cc @@ -459,13 +462,12 @@ 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} test_pretty_print.py\"") +set(PRETTYCMD "\"${PYTHON_EXECUTABLE} 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 # doesn't work. log is written - # after all tests run. + set(CTEST_CUSTOM_POST_TEST ${PRETTYCMD})\n ") file(WRITE ${CTEST_CUSTOM_FILE} ${CTEST_CUSTOM_TXT}) @@ -476,6 +478,7 @@ endforeach() set_directory_properties(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_SOURCE_DIR}/EnforceConfig.cmake") + # 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) @@ -523,6 +526,9 @@ disable_tests(dumptest_transform-tests # Reenable it when this is improved disable_tests(opencsgtest_child-background) +# FIXME: This single test takes over an hour to run on a 2.7 GHz P4 +disable_tests(opencsgtest_example006) + # These tests only makes sense in OpenCSG mode disable_tests(cgalpngtest_child-background cgalpngtest_highlight-and-background-modifier diff --git a/tests/FindGLEW.cmake b/tests/FindGLEW.cmake index 32c2d6e..8093ed3 100644 --- a/tests/FindGLEW.cmake +++ b/tests/FindGLEW.cmake @@ -44,7 +44,8 @@ ENDIF (WIN32) IF (GLEW_INCLUDE_PATH) SET( GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") - MESSAGE(STATUS "GLEW found in " ${GLEW_INCLUDE_PATH} " " ${GLEW_LIBRARY}) + MESSAGE(STATUS "GLEW include found in " ${GLEW_INCLUDE_PATH} ) + MESSAGE(STATUS "GLEW library found in " ${GLEW_LIBRARY} ) ELSE (GLEW_INCLUDE_PATH) SET( GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") ENDIF (GLEW_INCLUDE_PATH) diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 354c197..cd4d4b4 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -87,6 +87,10 @@ string info_dump(OffscreenView *glview) #define compiler_info "unknown compiler" #endif +#ifndef OPENCSG_VERSION_STRING +#define OPENCSG_VERSION_STRING "unknown, <1.3.2" +#endif + std::stringstream out; #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) @@ -97,7 +101,7 @@ string info_dump(OffscreenView *glview) << "\nEigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION << "\nCGAL version: " << TOSTRING(CGAL_VERSION) - // << "\nOpenCSG" << ??? + << "\nOpenCSG version: " << OPENCSG_VERSION_STRING << "\n" << glview->getInfo() << "\n"; diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 6931c35..df29fe7 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -1,4 +1,21 @@ #!/usr/bin/python + +# Copyright (C) 2011 Don Bright +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + # # This program 'pretty prints' the ctest output, namely # files from builddir/Testing/Temporary. @@ -6,6 +23,12 @@ # wiki uploading is available by running # # python test_pretty_print.py --upload +# +# Design philosophy +# +# 1. parse the data (images, logs) into easy-to-use data structures +# 2. wikifiy the data +# 3. save the wikified data to disk # todo # do something if tests for opencsg extensions fail (fail, no image production) @@ -197,14 +220,18 @@ TESTLOG '''Failed text tests''' -{|border=1 cellspacing=0 cellpadding=1 -! Testname +{|border=1 cellspacing=0 cellpadding=1 |- | FTESTNAME - |} +
+TESTLOG
+
+ + + '''build.make and flags.make''' *[[MAKEFILE_NAME]] @@ -225,12 +252,10 @@ TESTLOG 'NUMTESTS':len(tests), 'NUMPASSED':len(passed_tests), 'PERCENTPASSED':percent } for key in dic.keys(): s = s.replace(key,str(dic[key])) - testlogs = '' for t in failed_tests: - testlogs += '\n\n'+t.fulltestlog if t.type=='txt': - newchunk = re.sub('FTEST_OUTPUTFILE',t.fullname,repeat2) newchunk = re.sub('FTESTNAME',t.fullname,repeat2) + newchunk = newchunk.replace('TESTLOG',t.fulltestlog) s = s.replace(repeat2, newchunk+repeat2) elif t.type=='png': tmp = t.actualfile.replace(builddir,'') @@ -336,12 +361,21 @@ def upload(wikiurl,api_php_path='/',wiki_rootpath='test', sysid='null', botname= def findlogfile(builddir): logpath = os.path.join(builddir,'Testing','Temporary') - logfilename = os.path.join(logpath,'LastTest.log') + logfilename = os.path.join(logpath,'LastTest.log.tmp') + if not os.path.isfile(logfilename): + logfilename = os.path.join(logpath,'LastTest.log') + if not os.path.isfile(logfilename): + print 'cant find and/or open logfile',logfilename + sys.exit() return logpath, logfilename def main(): dry = False + print 'running test_pretty_print' if '--dryrun' in sys.argv: dry=True + suffix = ezsearch('--suffix=(.*?) ',string.join(sys.argv)+' ') + builddir = ezsearch('--builddir=(.*?) ',string.join(sys.argv)+' ') + if builddir=='': builddir=os.getcwd() print 'build dir set to', builddir sysinfo, sysid = read_sysinfo(os.path.join(builddir,'sysinfo.txt')) @@ -355,7 +389,7 @@ def main(): imgs, txtpages = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles) - wikidir = os.path.join(logpath,'wiki') + wikidir = os.path.join(logpath,sysid+'_wiki') print 'writing',len(imgs),'images and',len(txtpages),'wiki pages to:\n ', wikidir for k in sorted(imgs): trysave( os.path.join(wikidir,k), imgs[k]) for k in sorted(txtpages): trysave( os.path.join(wikidir,k), txtpages[k]) -- cgit v0.10.1 From 750f3c8fc94744d6cc4c62de6ac86595cb2b38b6 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 6 Dec 2011 18:56:58 -0600 Subject: cleanup diff --git a/doc/testing.txt b/doc/testing.txt index 61f6d75..9391832 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -1,7 +1,7 @@ Running regression tests: ------------------------- -Prerequisites: cmake, python, OpenCSG with FBO patch from ../patches applied +Prerequisites: cmake, python, ImageMagick 6.5.9.3 or newer A) Building test environment @@ -16,25 +16,14 @@ First, get a normal build working by following instructions at http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Building_on_Windows Then, from the QT command prompt: -$ cd tests -$ cmake . -DCMAKE_BUILD_TYPE=Release -$ sed -i s/\/MD/\/MT/ CMakeCache.txt -$ cmake . -$ nmake -f Makefile +> cd tests +> cmake . -DCMAKE_BUILD_TYPE=Release +> sed -i s/\/MD/\/MT/ CMakeCache.txt +> cmake . +> nmake -f Makefile B) Running tests -Easy version: -$ make test - -Windows: -$ nmake -f Makefile test - -Headless unix servers (no X11): -$ Xvfb :5 -screen 0 800x600x24 & -$ DISPLAY=:5 make test - -Partial or extended test runs: $ ctest Runs tests enabled by default $ ctest -R Runs only matching tests, e.g. ctest -R dxf $ ctest -C Adds extended tests belonging to configs. @@ -44,6 +33,10 @@ $ ctest -C Adds extended tests belonging to configs. Examples - test all examples All - test everything +Headless unix servers (no X11): +$ Xvfb :5 -screen 0 800x600x24 & +$ DISPLAY=:5 ctest + Adding a new regression test: ------------------------------ @@ -58,13 +51,16 @@ Adding a new regression test: 7) run the test normally and verify that it passes: $ ctest -R mytest -Troubleshooting a failed test: +Troubleshooting: ------------------------------ +To helping CMAKE find eigen2, OpenCSG, CGAL, Boost, and GLEW, you can use the +-D option. Here are some examples: + + cmake . -DOPENCSG_DIR=~/OpenCSG-1.3.2 + cmake . -DCGAL_DIR=c:\CGAL-3.7 -DBOOST_ROOT=c:\boost_1_46_0 + Logs of test runs are found in tests/build/Testing/Temporary +Pretty-printed html output is in a subdir of tests/build/Testing/Temporary Expected results are found in tests/regression/* Actual results are found in tests/build/testname-output/* - -You can also compile a single test program: - - $ make cgalpngtest diff --git a/patches/OpenCSG-1.3.1-FBO.patch b/patches/OpenCSG-1.3.1-FBO.patch deleted file mode 100644 index f4b3fcc..0000000 --- a/patches/OpenCSG-1.3.1-FBO.patch +++ /dev/null @@ -1,153 +0,0 @@ -Only in OpenCSG-1.3.1-fbopatch/: lib -diff -ur OpenCSG-1.3.1/Makefile OpenCSG-1.3.1-fbopatch/Makefile ---- OpenCSG-1.3.1/Makefile 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbopatch/Makefile 2011-11-23 21:44:21.285641445 -0600 -@@ -1,4 +1,4 @@ --SUBDIRS = glew src example -+SUBDIRS = src - - all: - for X in $(SUBDIRS); do make -C $$X ; done -Only in OpenCSG-1.3.1-fbopatch/src: area.o -Only in OpenCSG-1.3.1-fbopatch/src: batch.o -Only in OpenCSG-1.3.1-fbopatch/src: channelManager.o -Only in OpenCSG-1.3.1-fbopatch/src: context.o -diff -ur OpenCSG-1.3.1/src/frameBufferObject.cpp OpenCSG-1.3.1-fbopatch/src/frameBufferObject.cpp ---- OpenCSG-1.3.1/src/frameBufferObject.cpp 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbopatch/src/frameBufferObject.cpp 2011-11-23 22:19:33.545641258 -0600 -@@ -3,8 +3,8 @@ - // - // This library is free software; you can redistribute it and/or - // modify it under the terms of the GNU General Public License, --// Version 2, as published by the Free Software Foundation. --// As a special exception, you have permission to link this library -+// Version 2, as published by the Free Software Foundation. -+// As a special exception, you have permission to link this library - // with the CGAL library and distribute executables. - // - // This library is distributed in the hope that it will be useful, -@@ -59,6 +59,7 @@ - glGenRenderbuffers(1, &depthID); - glGenTextures(1, &textureID); - -+ glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFramebufferID); - glBindFramebuffer(GL_FRAMEBUFFER, framebufferID); - glBindTexture(GL_TEXTURE_2D, textureID); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_INT, 0); -@@ -78,7 +79,7 @@ - return false; - } - -- glBindFramebuffer(GL_FRAMEBUFFER, 0); -+ glBindFramebuffer(GL_FRAMEBUFFER, oldFramebufferID); - glBindTexture(GL_TEXTURE_2D, 0); - - textureTarget = GL_TEXTURE_2D; -@@ -135,7 +136,7 @@ - // Unbinds frame buffer texture. - bool FrameBufferObject::EndCapture() - { -- glBindFramebuffer(GL_FRAMEBUFFER, 0); -+ glBindFramebuffer(GL_FRAMEBUFFER, oldFramebufferID); - return true; - } - -diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.cpp OpenCSG-1.3.1-fbopatch/src/frameBufferObjectExt.cpp ---- OpenCSG-1.3.1/src/frameBufferObjectExt.cpp 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbopatch/src/frameBufferObjectExt.cpp 2011-11-23 21:43:17.701638949 -0600 -@@ -3,8 +3,8 @@ - // - // This library is free software; you can redistribute it and/or - // modify it under the terms of the GNU General Public License, --// Version 2, as published by the Free Software Foundation. --// As a special exception, you have permission to link this library -+// Version 2, as published by the Free Software Foundation. -+// As a special exception, you have permission to link this library - // with the CGAL library and distribute executables. - // - // This library is distributed in the hope that it will be useful, -@@ -60,6 +60,7 @@ - glGenRenderbuffersEXT(1, &depthID); - glGenTextures(1, &textureID); - -+ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &oldFramebufferID); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebufferID); - glBindTexture(GL_TEXTURE_2D, textureID); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_INT, 0); -@@ -79,7 +80,7 @@ - return false; - } - -- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); -+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, oldFramebufferID); - glBindTexture(GL_TEXTURE_2D, 0); - - textureTarget = GL_TEXTURE_2D; -@@ -136,7 +137,7 @@ - // Unbinds frame buffer texture. - bool FrameBufferObjectExt::EndCapture() - { -- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); -+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, oldFramebufferID); - return true; - } - -diff -ur OpenCSG-1.3.1/src/frameBufferObjectExt.h OpenCSG-1.3.1-fbopatch/src/frameBufferObjectExt.h ---- OpenCSG-1.3.1/src/frameBufferObjectExt.h 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbopatch/src/frameBufferObjectExt.h 2011-11-23 21:43:17.701638949 -0600 -@@ -3,8 +3,8 @@ - // - // This library is free software; you can redistribute it and/or - // modify it under the terms of the GNU General Public License, --// Version 2, as published by the Free Software Foundation. --// As a special exception, you have permission to link this library -+// Version 2, as published by the Free Software Foundation. -+// As a special exception, you have permission to link this library - // with the CGAL library and distribute executables. - // - // This library is distributed in the hope that it will be useful, -@@ -85,6 +85,7 @@ - unsigned int depthID; - - unsigned int framebufferID; -+ int oldFramebufferID; - - bool initialized; - }; -Only in OpenCSG-1.3.1-fbopatch/src: frameBufferObjectExt.o -diff -ur OpenCSG-1.3.1/src/frameBufferObject.h OpenCSG-1.3.1-fbopatch/src/frameBufferObject.h ---- OpenCSG-1.3.1/src/frameBufferObject.h 2010-06-09 14:39:58.000000000 -0500 -+++ OpenCSG-1.3.1-fbopatch/src/frameBufferObject.h 2011-11-23 21:43:17.701638949 -0600 -@@ -3,8 +3,8 @@ - // - // This library is free software; you can redistribute it and/or - // modify it under the terms of the GNU General Public License, --// Version 2, as published by the Free Software Foundation. --// As a special exception, you have permission to link this library -+// Version 2, as published by the Free Software Foundation. -+// As a special exception, you have permission to link this library - // with the CGAL library and distribute executables. - // - // This library is distributed in the hope that it will be useful, -@@ -85,6 +85,7 @@ - unsigned int depthID; - - unsigned int framebufferID; -+ int oldFramebufferID; - - bool initialized; - }; -Only in OpenCSG-1.3.1-fbopatch/src: frameBufferObject.o -Only in OpenCSG-1.3.1-fbopatch/src: occlusionQuery.o -Only in OpenCSG-1.3.1-fbopatch/src: offscreenBuffer.o -Only in OpenCSG-1.3.1-fbopatch/src: opencsgRender.o -Only in OpenCSG-1.3.1-fbopatch/src: openglHelper.o -Only in OpenCSG-1.3.1-fbopatch/src: pBufferTexture.o -Only in OpenCSG-1.3.1-fbopatch/src: primitiveHelper.o -Only in OpenCSG-1.3.1-fbopatch/src: primitive.o -Only in OpenCSG-1.3.1-fbopatch/src: renderGoldfeather.o -Only in OpenCSG-1.3.1-fbopatch/src: renderSCS.o -Only in OpenCSG-1.3.1-fbopatch/src: RenderTexture.o -Only in OpenCSG-1.3.1-fbopatch/src: scissorMemo.o -Only in OpenCSG-1.3.1-fbopatch/src: settings.o -Only in OpenCSG-1.3.1-fbopatch/src: stencilManager.o diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 58df471..314b51f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -462,7 +462,7 @@ 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} test_pretty_print.py --builddir=${CMAKE_CURRENT_BINARY_DIR}\"") +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 @@ -471,14 +471,13 @@ set(CTEST_CUSTOM_TXT "\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() +#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") - # 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) @@ -527,7 +526,7 @@ disable_tests(dumptest_transform-tests disable_tests(opencsgtest_child-background) # FIXME: This single test takes over an hour to run on a 2.7 GHz P4 -disable_tests(opencsgtest_example006) +disable_tests(opencsgtest_example006 cgalpngtest_example006) # These tests only makes sense in OpenCSG mode disable_tests(cgalpngtest_child-background diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 8f519d7..e2193e2 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -59,7 +59,7 @@ def tryread(filename): def trysave(filename,data): try: if not os.path.isdir(os.path.dirname(filename)): - print 'creating',os.path.dirname(filename) + #print 'creating',os.path.dirname(filename) os.mkdir(os.path.dirname(filename)) f=open(filename,'wb') f.write(data) @@ -386,14 +386,14 @@ def main(): logpath, logfilename = findlogfile(builddir) testlog = tryread(logfilename) startdate, tests, enddate = parselog(testlog) - print 'found sysinfo.txt' - print 'found', len(makefiles),'makefiles' + print 'found sysinfo.txt,', + print 'found', len(makefiles),'makefiles,', print 'found', len(tests),'test results' imgs, txtpages = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles) wikidir = os.path.join(logpath,sysid+'_wiki') - print 'writing',len(imgs),'images and',len(txtpages),'wiki pages to:\n ', wikidir + print 'writing',len(imgs),'images and',len(txtpages),'wiki pages to:\n ', '.'+wikidir.replace(os.getcwd(),'') for k in sorted(imgs): trysave( os.path.join(wikidir,k), imgs[k]) for k in sorted(txtpages): trysave( os.path.join(wikidir,k), txtpages[k]) -- cgit v0.10.1 From 32a3831ce9c8894a24d9a5f05c46c3fba458d34c Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 6 Dec 2011 19:15:04 -0800 Subject: alternate comparison for systems where imagemagick convert crashes diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index ebe802e..916694f 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -48,7 +48,7 @@ def verify_test(testname, cmd): def execute_and_redirect(cmd, params, outfile): retval = -1 try: - proc = subprocess.Popen([cmd] + params, stdout=outfile) + proc = subprocess.Popen([cmd] + params, stdout=outfile, stderr=subprocess.STDOUT) out = proc.communicate()[0] retval = proc.wait() except: @@ -76,27 +76,40 @@ def compare_default(resultfilename): return True def compare_png(resultfilename): + compare_method = 'pixel' #args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-blur", "2", "-threshold", "30%", "-format", "%[fx:w*h*mean]", "info:"] #args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-morphology", "Erode", "Square", "-format", "%[fx:w*h*mean]", "info:"] - # 'morphology' is only available in newer versions of ImageMagick. + + # for systems with older imagemagick that doesnt support '-morphology' # http://www.imagemagick.org/Usage/morphology/#alturnative - args = [expectedfilename, resultfilename, "-alpha", "Off", - "-compose", "difference", "-composite", "-threshold", "10%", - #"-morphology", "Erode", "Square", - "-gaussian-blur","3x65535", "-threshold","99.999%", - "-format", "%[fx:w*h*mean]", "info:"] - print >> sys.stderr, 'ImageMagick image comparison: convert ', ' '.join(args[2:]) - print >> sys.stderr, ' expected image: ', expectedfilename + # args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-gaussian-blur","3x65535", "-format", "%[fx:w*h*mean]", "info:"] + + # for systems where imagemagick crashes when using the above comparators + args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-metric", "NCC", "tmp.png"] + options.convert_exec = 'compare' + compare_method = 'NCC' + + msg = 'ImageMagick image comparison: ' + msg += os.path.basename(options.convert_exec) + ' '.join(args) + msg += ' expected image: ' + expectedfilename + print >> sys.stderr, msg if not resultfilename: print >> sys.stderr, "Error: OpenSCAD did not generate an image to test" return False print >> sys.stderr, ' actual image: ', resultfilename (retval, output) = execute_and_redirect(options.convert_exec, args, subprocess.PIPE) + print "Imagemagick return", retval, "output:", output if retval == 0: - pixelerr = int(float(output.strip())) - if pixelerr < 32: return True - else: print >> sys.stderr, pixelerr, ' pixel errors' + if compare_method=='pixel': + pixelerr = int(float(output.strip())) + if pixelerr < 32: return True + else: print >> sys.stderr, pixelerr, ' pixel errors' + elif compare_method=='NCC': + thresh = 0.99 + ncc_err = float(output.strip()) + if ncc_err > thresh: return True + else: print >> sys.stderr, ncc_err, ' Images differ: NCC comparison < ', thresh return False def compare_with_expected(resultfilename): -- cgit v0.10.1 From 61bfb8f058e8935432fed6098a1d70dba194f6bf Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 6 Dec 2011 21:48:19 -0600 Subject: fix errors with flaky wiki sites. cleanup diff --git a/doc/testing.txt b/doc/testing.txt index 9391832..df77073 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -33,10 +33,6 @@ $ ctest -C Adds extended tests belonging to configs. Examples - test all examples All - test everything -Headless unix servers (no X11): -$ Xvfb :5 -screen 0 800x600x24 & -$ DISPLAY=:5 ctest - Adding a new regression test: ------------------------------ @@ -54,13 +50,22 @@ Adding a new regression test: Troubleshooting: ------------------------------ -To helping CMAKE find eigen2, OpenCSG, CGAL, Boost, and GLEW, you can use the --D option. Here are some examples: +0. Headless unix servers (no X11): + +$ Xvfb :5 -screen 0 800x600x24 & +$ DISPLAY=:5 ctest + +1. To help CMAKE find eigen2, OpenCSG, CGAL, Boost, and GLEW, you can use + the -D option. See CMakeLists.txt for more information. Examples: cmake . -DOPENCSG_DIR=~/OpenCSG-1.3.2 cmake . -DCGAL_DIR=c:\CGAL-3.7 -DBOOST_ROOT=c:\boost_1_46_0 + +2. Logs Logs of test runs are found in tests/build/Testing/Temporary Pretty-printed html output is in a subdir of tests/build/Testing/Temporary Expected results are found in tests/regression/* Actual results are found in tests/build/testname-output/* + +3. Cross-compiling of tests has not been automated nor tested. diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index 916694f..480584c 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -82,16 +82,16 @@ def compare_png(resultfilename): # for systems with older imagemagick that doesnt support '-morphology' # http://www.imagemagick.org/Usage/morphology/#alturnative - # args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-gaussian-blur","3x65535", "-format", "%[fx:w*h*mean]", "info:"] + args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-gaussian-blur","3x65535", "-threshold", "99.99%", "-format", "%[fx:w*h*mean]", "info:"] # for systems where imagemagick crashes when using the above comparators - args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-metric", "NCC", "tmp.png"] - options.convert_exec = 'compare' - compare_method = 'NCC' + # args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-metric", "NCC", "tmp.png"] + # options.convert_exec = 'compare' + # compare_method = 'NCC' msg = 'ImageMagick image comparison: ' - msg += os.path.basename(options.convert_exec) + ' '.join(args) - msg += ' expected image: ' + expectedfilename + msg += os.path.basename(options.convert_exec) + ' ' + ' '.join(args) + msg += '\nexpected image: ' + expectedfilename + '\n' print >> sys.stderr, msg if not resultfilename: print >> sys.stderr, "Error: OpenSCAD did not generate an image to test" @@ -106,7 +106,7 @@ def compare_png(resultfilename): if pixelerr < 32: return True else: print >> sys.stderr, pixelerr, ' pixel errors' elif compare_method=='NCC': - thresh = 0.99 + thresh = 0.95 ncc_err = float(output.strip()) if ncc_err > thresh: return True else: print >> sys.stderr, ncc_err, ' Images differ: NCC comparison < ', thresh diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index e2193e2..d297caf 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -44,7 +44,7 @@ # (you can set this in the registry to never happen, but itd be better if the program # itself was able to disable that temporarily in it's own process) -import string,sys,re,os,hashlib,subprocess,textwrap +import string,sys,re,os,hashlib,subprocess,textwrap,time def tryread(filename): data = None @@ -254,7 +254,7 @@ TESTLOG 'NUMTESTS':len(tests), 'NUMPASSED':len(passed_tests), 'PERCENTPASSED':percent } for key in dic.keys(): s = s.replace(key,str(dic[key])) - for t in failed_tests: + for t in tests: if t.type=='txt': newchunk = re.sub('FTESTNAME',t.fullname,repeat2) newchunk = newchunk.replace('TESTLOG',t.fulltestlog) @@ -314,26 +314,55 @@ def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): x=re.sub("\[\[(.*?)\]\]","\\1",x) return head + x + '' +def wiki_login(wikiurl,api_php_path,botname,botpass): + site = mwclient.Site(wikiurl,api_php_path) + site.login(botname,botpass) + return site + +def wiki_upload(wikiurl,api_php_path,botname,botpass,filedata,wikipgname): + counter = 0 + done = False + descrip = 'test' + time.sleep(1) + while not done: + try: + print 'login',botname,'to',wikiurl + site = wiki_login(wikiurl,api_php_path,botname,botpass) + if wikipgname.endswith('png'): + site.upload(filedata,wikipgname,descrip,ignore=True) + else: + page = site.Pages[wikipgname] + text = page.edit() + page.save(filedata) + done = True + except Exception, e: + print 'Error:', type(e),e + counter += 1 + if counter>maxretry: + print 'giving up. please try a different wiki site' + done = True + else: + print 'wiki',wikiurl,'down. retrying in 15 seconds' + time.sleep(15) + def upload(wikiurl,api_php_path='/',wiki_rootpath='test', sysid='null', botname='cakebaby',botpass='anniew',wikidir='.',dryrun=True): wetrun = not dryrun if dryrun: print 'dry run' try: + global mwclient import mwclient except: - print 'please download mwclient and unpack here:', os.getcwd() + print 'please download mwclient 0.6.5 and unpack here:', os.getcwd() sys.exit() - print 'opening site:',wikiurl - if wetrun: - site = mwclient.Site(wikiurl,api_php_path) - - print 'bot login:', botname - if wetrun: site.login(botname,botpass) + + if wetrun: site = wiki_login(wikiurl,api_php_path,botname,botpass) wikifiles = os.listdir(wikidir) testreport_page = filter( lambda x: 'test_report' in x, wikifiles ) if (len(testreport_page)>1): print 'multiple test reports found, please clean dir',wikidir sys.exit() + rootpage = testreport_page[0] print 'add',rootpage,' to main report page ',wiki_rootpath if wetrun: @@ -347,21 +376,9 @@ def upload(wikiurl,api_php_path='/',wiki_rootpath='test', sysid='null', botname= for wikiname in wikifiles: filename = os.path.join(wikidir,wikiname) filedata = tryread(filename) - print 'upload',len(filedata),'bytes from',wikiname,'...', - sys.stdout.flush() - if wikiname.endswith('.png'): - localf = open(filename,'rb') # mwclient needs file handle - descrip = wiki_rootpath + ' test' - if wetrun: - site.upload(localf,wikiname,descrip,ignore=True) - print 'image uploaded' - else: # textpage - if wetrun: - page = site.Pages[wikiname] - text = page.edit() - page.save(filedata) - print 'text page uploaded' - + print 'upload',len(filedata),'bytes from',wikiname,'...' + if wetrun: + wiki_upload(wikiurl,api_php_path,botname,botpass,filedata,wikiname) def findlogfile(builddir): logpath = os.path.join(builddir,'Testing','Temporary') logfilename = os.path.join(logpath,'LastTest.log.tmp') @@ -374,26 +391,27 @@ def findlogfile(builddir): def main(): dry = False - print 'running test_pretty_print' + if verbose: print 'running test_pretty_print' if '--dryrun' in sys.argv: dry=True suffix = ezsearch('--suffix=(.*?) ',string.join(sys.argv)+' ') builddir = ezsearch('--builddir=(.*?) ',string.join(sys.argv)+' ') if builddir=='': builddir=os.getcwd() - print 'build dir set to', builddir + if verbose: print 'build dir set to', builddir sysinfo, sysid = read_sysinfo(os.path.join(builddir,'sysinfo.txt')) makefiles = load_makefiles(builddir) logpath, logfilename = findlogfile(builddir) testlog = tryread(logfilename) startdate, tests, enddate = parselog(testlog) - print 'found sysinfo.txt,', - print 'found', len(makefiles),'makefiles,', - print 'found', len(tests),'test results' + if verbose: + print 'found sysinfo.txt,', + print 'found', len(makefiles),'makefiles,', + print 'found', len(tests),'test results' imgs, txtpages = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles) - wikidir = os.path.join(logpath,sysid+'_wiki') - print 'writing',len(imgs),'images and',len(txtpages),'wiki pages to:\n ', '.'+wikidir.replace(os.getcwd(),'') + wikidir = os.path.join(logpath,sysid+'_report') + print 'writing',len(imgs),'images and',len(txtpages),'text pages to:\n', ' .'+wikidir.replace(os.getcwd(),'') for k in sorted(imgs): trysave( os.path.join(wikidir,k), imgs[k]) for k in sorted(txtpages): trysave( os.path.join(wikidir,k), txtpages[k]) @@ -401,7 +419,7 @@ def main(): upload(wikisite,wiki_api_path,wiki_rootpath,sysid,'openscadbot', 'tobdacsnepo',wikidir,dryrun=dry) - print 'test_pretty_print complete' + if verbose: print 'test_pretty_print complete' #wikisite = 'cakebaby.referata.com' #wiki_api_path = '' @@ -409,5 +427,7 @@ wikisite = 'cakebaby.wikia.com' wiki_api_path = '/' wiki_rootpath = 'OpenSCAD' builddir = os.getcwd() # os.getcwd()+'/build' +verbose = False +maxretry = 10 main() -- cgit v0.10.1 From d26effccf4c9fabfe19355d6da4903291d8dd599 Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 6 Dec 2011 20:20:17 -0800 Subject: allow alternate image comparison using option to cmake diff --git a/doc/testing.txt b/doc/testing.txt index df77073..c2d3ccf 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -50,13 +50,15 @@ Adding a new regression test: Troubleshooting: ------------------------------ -0. Headless unix servers (no X11): +0. Headless unix servers (no X11) $ Xvfb :5 -screen 0 800x600x24 & $ DISPLAY=:5 ctest -1. To help CMAKE find eigen2, OpenCSG, CGAL, Boost, and GLEW, you can use - the -D option. See CMakeLists.txt for more information. Examples: +1. Trouble finding libraries + + To help CMAKE find eigen2, OpenCSG, CGAL, Boost, and GLEW, you can use + the -D option. See CMakeLists.txt for more information. Examples: cmake . -DOPENCSG_DIR=~/OpenCSG-1.3.2 cmake . -DCGAL_DIR=c:\CGAL-3.7 -DBOOST_ROOT=c:\boost_1_46_0 @@ -68,4 +70,11 @@ Pretty-printed html output is in a subdir of tests/build/Testing/Temporary Expected results are found in tests/regression/* Actual results are found in tests/build/testname-output/* -3. Cross-compiling of tests has not been automated nor tested. +3. Cross-compiling + +Cross-compiling of tests has not been automated nor tested + +4. Testing images takes forever, they fail, and it says 'return -11' + +Imagemagick may have crashed. Try passing -DCOMPARATOR=ncc to cmake + diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 314b51f..04be773 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -422,6 +422,12 @@ 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}") +endif() +message(STATUS "COMPARATOR: " ${COMPARATOR}) + # # This functions adds cmd-line tests given files. # Files are sent as the parameters following TESTSUFFIX @@ -452,7 +458,7 @@ macro(add_cmdline_test TESTCMD TESTSUFFIX) set(CONFARG CONFIGURATIONS) set(CONFVAL ${FOUNDCONFIGS}) - add_test(NAME ${TEST_FULLNAME} ${CONFARG} ${CONFVAL} COMMAND ${PYTHON_EXECUTABLE} ${tests_SOURCE_DIR}/test_cmdline_tool.py -c ${ImageMagick_convert_EXECUTABLE} -s ${TESTSUFFIX} ${CMAKE_BINARY_DIR}/${TESTCMD} "${SCADFILE}") + add_test(NAME ${TEST_FULLNAME} ${CONFARG} ${CONFVAL} COMMAND ${PYTHON_EXECUTABLE} ${tests_SOURCE_DIR}/test_cmdline_tool.py --comparator=${COMPARATOR} -c ${ImageMagick_convert_EXECUTABLE} -s ${TESTSUFFIX} ${CMAKE_BINARY_DIR}/${TESTCMD} "${SCADFILE}") endif() endforeach() endmacro() diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index 480584c..dace3f5 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -78,16 +78,18 @@ def compare_default(resultfilename): def compare_png(resultfilename): compare_method = 'pixel' #args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-blur", "2", "-threshold", "30%", "-format", "%[fx:w*h*mean]", "info:"] - #args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-morphology", "Erode", "Square", "-format", "%[fx:w*h*mean]", "info:"] + args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-morphology", "Erode", "Square", "-format", "%[fx:w*h*mean]", "info:"] # for systems with older imagemagick that doesnt support '-morphology' # http://www.imagemagick.org/Usage/morphology/#alturnative - args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-gaussian-blur","3x65535", "-threshold", "99.99%", "-format", "%[fx:w*h*mean]", "info:"] + if options.comparator == 'old': + args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-composite", "-threshold", "10%", "-gaussian-blur","3x65535", "-threshold", "99.99%", "-format", "%[fx:w*h*mean]", "info:"] - # for systems where imagemagick crashes when using the above comparators - # args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-metric", "NCC", "tmp.png"] - # options.convert_exec = 'compare' - # compare_method = 'NCC' + if options.comparator == 'ncc': + # for systems where imagemagick crashes when using the above comparators + args = [expectedfilename, resultfilename, "-alpha", "Off", "-compose", "difference", "-metric", "NCC", "tmp.png"] + options.convert_exec = 'compare' + compare_method = 'NCC' msg = 'ImageMagick image comparison: ' msg += os.path.basename(options.convert_exec) + ' ' + ' '.join(args) @@ -168,7 +170,7 @@ def usage(): if __name__ == '__main__': # Handle command-line arguments try: - opts, args = getopt.getopt(sys.argv[1:], "gs:c:t:", ["generate", "convexec=", "suffix=", "test="]) + opts, args = getopt.getopt(sys.argv[1:], "gs:c:t:m:", ["generate", "convexec=", "suffix=", "test=", "comparator="]) except getopt.GetoptError, err: usage() sys.exit(2) @@ -186,8 +188,10 @@ if __name__ == '__main__': else: options.suffix = a elif o in ("-t", "--test"): options.testname = a - elif o in ("-c", "--convexec"): + elif o in ("-c", "--convexec"): options.convert_exec = os.path.normpath( a ) + elif o in ("-m", "--comparator"): + options.comparator = a # and if len(args) < 2: diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index d297caf..ca6af5f 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -19,11 +19,13 @@ # # This program 'pretty prints' the ctest output, namely # files from builddir/Testing/Temporary. -# html & wiki output are produced in Testing/Temporary/wiki -# wiki uploading is available by running +# html & wiki output are produced in Testing/Temporary/sysid_report +# +# experimental wiki uploading is available by running # # python test_pretty_print.py --upload # + # Design philosophy # # 1. parse the data (images, logs) into easy-to-use data structures -- cgit v0.10.1 From b8ca57233809d32b31342914000c6291b0bdc683 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 6 Dec 2011 22:31:59 -0600 Subject: tweak --upload of pretty print. cleanup diff --git a/doc/testing.txt b/doc/testing.txt index c2d3ccf..b94fd93 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -78,3 +78,7 @@ Cross-compiling of tests has not been automated nor tested Imagemagick may have crashed. Try passing -DCOMPARATOR=ncc to cmake +5. Testing images fails with 'morphology' not found for ImageMagick + +Your version of imagemagick is old. Upgrade, or pass -DCOMPARATOR=old to cmake. +The comparison will be of lowered reliability. diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index ca6af5f..abb50fc 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -330,6 +330,7 @@ def wiki_upload(wikiurl,api_php_path,botname,botpass,filedata,wikipgname): try: print 'login',botname,'to',wikiurl site = wiki_login(wikiurl,api_php_path,botname,botpass) + print 'uploading...', if wikipgname.endswith('png'): site.upload(filedata,wikipgname,descrip,ignore=True) else: @@ -337,6 +338,7 @@ def wiki_upload(wikiurl,api_php_path,botname,botpass,filedata,wikipgname): text = page.edit() page.save(filedata) done = True + print 'transfer ok' except Exception, e: print 'Error:', type(e),e counter += 1 @@ -378,7 +380,7 @@ def upload(wikiurl,api_php_path='/',wiki_rootpath='test', sysid='null', botname= for wikiname in wikifiles: filename = os.path.join(wikidir,wikiname) filedata = tryread(filename) - print 'upload',len(filedata),'bytes from',wikiname,'...' + print 'upload',len(filedata),'bytes from',wikiname if wetrun: wiki_upload(wikiurl,api_php_path,botname,botpass,filedata,wikiname) def findlogfile(builddir): @@ -413,6 +415,8 @@ def main(): imgs, txtpages = towiki(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles) wikidir = os.path.join(logpath,sysid+'_report') + if verbose: print 'erasing files in',wikidir + map(lambda x:os.remove(os.path.join(wikidir,x)), os.listdir(wikidir)) print 'writing',len(imgs),'images and',len(txtpages),'text pages to:\n', ' .'+wikidir.replace(os.getcwd(),'') for k in sorted(imgs): trysave( os.path.join(wikidir,k), imgs[k]) for k in sorted(txtpages): trysave( os.path.join(wikidir,k), txtpages[k]) @@ -420,7 +424,8 @@ def main(): if '--upload' in sys.argv: upload(wikisite,wiki_api_path,wiki_rootpath,sysid,'openscadbot', 'tobdacsnepo',wikidir,dryrun=dry) - + print 'upload attempt complete' + if verbose: print 'test_pretty_print complete' #wikisite = 'cakebaby.referata.com' -- cgit v0.10.1 From c2d4f7558e43891df11709a0a9aa049e93560c30 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 6 Dec 2011 22:53:58 -0600 Subject: fix html output of test results diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index abb50fc..3d42901 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -299,22 +299,59 @@ TESTLOG return imgs, txtpages -def wikitohtml(wiki_rootpath, sysid, wikidata, manifest): - # temporarily defunct/broken +def tohtml(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles): + # kludge. assume wiki stuff has alreayd run and dumped files properly head = ''+wiki_rootpath+' test run for '+sysid +'' - revmanifest = dict((val,key) for key, val in manifest.iteritems()) - x=re.sub('\{\|(.*?)\n','
\n',wikidata) - x=re.sub('\|(.*?colspan.*?)\|','
',x) - x=re.sub("'''(.*?)'''","\\1",x) - filestrs=re.findall('\[\[File\:(.*?)\|.*?\]\]',x) - for f in filestrs: - newfile_html='' - x=re.sub('\[\[File\:'+f+'\|.*?\]\]',newfile_html,x) - dic = { '|}':'
', '|-':'
', '|':'', - '!!':'', '!':'
', '\n\n':'\n

\n'} #order matters - for key in dic: x=x.replace(key,dic[key]) - x=re.sub("\[\[(.*?)\]\]","\\1",x) - return head + x + '' + tail = '' + + passed_tests = filter(lambda x: x.passed, tests) + failed_tests = filter(lambda x: not x.passed, tests) + percent = str(int(100.0*len(passed_tests) / len(tests))) + + s='' + + s+= '\n

'
+	s+= '\nSYSINFO\n'+ sysinfo
+	s+= '\n

' + + s+= '\n

'
+	s+= '\nSTARTDATE: '+ startdate
+	s+= '\nENDDATE: '+ enddate
+	s+= '\nWIKI_ROOTPATH: '+ wiki_rootpath
+	s+= '\nSYSID: '+sysid
+	s+= '\nNUMTESTS: '+str(len(tests))
+	s+= '\nNUMPASSED: '+str(len(passed_tests))
+	s+= '\nPERCENTPASSED: '+ percent
+	s+= '\n
' + + for t in tests: + if t.type=='txt': + s+='\n
'+t.fullname+'
\n' + s+='

'+t.fulltestlog+'
\n\n' + elif t.type=='png': + tmp = t.actualfile.replace(builddir,'') + wikiname_a = wikify_filename(tmp,wiki_rootpath,sysid) + tmp = t.expectedfile.replace(os.path.dirname(builddir),'') + wikiname_e = wikify_filename(tmp,wiki_rootpath,sysid) + s+='' + s+='\n
'+t.fullname + s+='\n
ExpectedActual' + s+='\n
' + s+='\n ' + s+='\n
' + s+='\n
'
+			s+=t.fulltestlog
+			s+='\n
' + + s+='\n\n

\n\n' + makefiles_wikinames = {} + for mf in sorted(makefiles.keys()): + tmp = mf.replace('CMakeFiles','').replace('.dir','') + wikiname = wikify_filename(tmp,wiki_rootpath,sysid) + s += '\n'+wikiname+'
' + s+='\n' + + return head + s + tail def wiki_login(wikiurl,api_php_path,botname,botpass): site = mwclient.Site(wikiurl,api_php_path) @@ -418,8 +455,11 @@ def main(): if verbose: print 'erasing files in',wikidir map(lambda x:os.remove(os.path.join(wikidir,x)), os.listdir(wikidir)) print 'writing',len(imgs),'images and',len(txtpages),'text pages to:\n', ' .'+wikidir.replace(os.getcwd(),'') - for k in sorted(imgs): trysave( os.path.join(wikidir,k), imgs[k]) - for k in sorted(txtpages): trysave( os.path.join(wikidir,k), txtpages[k]) + for pgname in sorted(imgs): trysave( os.path.join(wikidir,pgname), imgs[pgname]) + for pgname in sorted(txtpages): trysave( os.path.join(wikidir,pgname), txtpages[pgname]) + + htmldata = tohtml(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles) + trysave( os.path.join(wikidir,'index.html'), htmldata ) if '--upload' in sys.argv: upload(wikisite,wiki_api_path,wiki_rootpath,sysid,'openscadbot', -- cgit v0.10.1 From 067ebee76ac5bc5e00eb02244d7f7dbd7e6e2797 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 6 Dec 2011 23:00:45 -0600 Subject: now uploads all images not just failed. diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 3d42901..5e8092b 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -202,7 +202,7 @@ SYSINFO start time: STARTDATE
end time : ENDDATE
-'''Failed image tests''' +'''Image tests''' {| border=1 cellspacing=0 cellpadding=1 @@ -223,7 +223,7 @@ TESTLOG -'''Failed text tests''' +'''Text tests''' {|border=1 cellspacing=0 cellpadding=1 @@ -413,6 +413,8 @@ def upload(wikiurl,api_php_path='/',wiki_rootpath='test', sysid='null', botname= page.save(text +'\n*[['+rootpage+']]\n') wikifiles = os.listdir(wikidir) + wikifiles = filter(lambda x: not x.endswith('html'), wikifiles) + print 'upload wiki pages:' for wikiname in wikifiles: filename = os.path.join(wikidir,wikiname) @@ -420,6 +422,7 @@ def upload(wikiurl,api_php_path='/',wiki_rootpath='test', sysid='null', botname= print 'upload',len(filedata),'bytes from',wikiname if wetrun: wiki_upload(wikiurl,api_php_path,botname,botpass,filedata,wikiname) + def findlogfile(builddir): logpath = os.path.join(builddir,'Testing','Temporary') logfilename = os.path.join(logpath,'LastTest.log.tmp') -- cgit v0.10.1 From 20a3eaa0971530643d74a95507341d0bc278ddb1 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Tue, 6 Dec 2011 23:10:44 -0600 Subject: tweak diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 5e8092b..2a92bb4 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -235,6 +235,7 @@ TESTLOG TESTLOG + '''build.make and flags.make''' -- cgit v0.10.1 From 462a4f4f44543d89be829eac6bb64a33854a4dd9 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 7 Dec 2011 00:02:34 -0600 Subject: fix crash bug diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 2a92bb4..955d021 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -457,7 +457,8 @@ def main(): wikidir = os.path.join(logpath,sysid+'_report') if verbose: print 'erasing files in',wikidir - map(lambda x:os.remove(os.path.join(wikidir,x)), os.listdir(wikidir)) + try: map(lambda x:os.remove(os.path.join(wikidir,x)), os.listdir(wikidir)) + except: pass print 'writing',len(imgs),'images and',len(txtpages),'text pages to:\n', ' .'+wikidir.replace(os.getcwd(),'') for pgname in sorted(imgs): trysave( os.path.join(wikidir,pgname), imgs[pgname]) for pgname in sorted(txtpages): trysave( os.path.join(wikidir,pgname), txtpages[pgname]) -- cgit v0.10.1 From 9a665075c9df74fd646ad187636bc242a9a8816c Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 6 Dec 2011 22:36:33 -0800 Subject: update FindBoost from cmake git. improve crash handling + boost finding diff --git a/doc/testing.txt b/doc/testing.txt index b94fd93..6b0f0d2 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -61,7 +61,7 @@ $ DISPLAY=:5 ctest the -D option. See CMakeLists.txt for more information. Examples: cmake . -DOPENCSG_DIR=~/OpenCSG-1.3.2 - cmake . -DCGAL_DIR=c:\CGAL-3.7 -DBOOST_ROOT=c:\boost_1_46_0 + cmake . -DCGAL_DIR=c:\CGAL-3.7 -DBOOST_DIR=c:\boost_1_46_0 2. Logs @@ -76,7 +76,8 @@ Cross-compiling of tests has not been automated nor tested 4. Testing images takes forever, they fail, and it says 'return -11' -Imagemagick may have crashed. Try passing -DCOMPARATOR=ncc to cmake +Imagemagick may have crashed. You can try using the alternate comparison +based on Normalized Cross Correlation. Pass -DCOMPARATOR=ncc to cmake 5. Testing images fails with 'morphology' not found for ImageMagick diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 04be773..e668db3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -71,14 +71,24 @@ if (NOT $ENV{MACOSX_DEPLOY_DIR} STREQUAL "") set(BOOST_ROOT "$ENV{MACOSX_DEPLOY_DIR}") endif() +if (NOT $ENV{BOOST_DIR} STREQUAL "") + set(BOOST_DIR "$ENV{BOOST_DIR}") +endif() + +if (NOT ${BOOST_DIR} STREQUAL "") + set(BOOST_ROOT ${BOOST_DIR}) + message(STATUS "BOOST_ROOT: " ${BOOST_ROOT}) + set(Boost_NO_SYSTEM_PATHS "TRUE") + set(Boost_DEBUG TRUE) +endif() + + if (WIN32) set(Boost_USE_STATIC_LIBS TRUE) set(BOOST_STATIC TRUE) set(BOOST_THREAD_USE_LIB TRUE) endif() -#set(Boost_DEBUG TRUE) -set(Boost_NO_SYSTEM_PATHS TRUE) set(Boost_ADDITIONAL_VERSIONS "1.47.0" "1.46.0") find_package( Boost 1.35.0 COMPONENTS thread program_options ) if(Boost_FOUND) diff --git a/tests/FindBoost.cmake b/tests/FindBoost.cmake index dfaf660..ea60354 100644 --- a/tests/FindBoost.cmake +++ b/tests/FindBoost.cmake @@ -17,8 +17,9 @@ # # == Using actual libraries from within Boost: == # -# set(Boost_USE_STATIC_LIBS ON) -# set(Boost_USE_MULTITHREADED ON) +# set(Boost_USE_STATIC_LIBS ON) +# set(Boost_USE_MULTITHREADED ON) +# set(Boost_USE_STATIC_RUNTIME OFF) # find_package( Boost 1.36.0 COMPONENTS date_time filesystem system ... ) # # if(Boost_FOUND) @@ -33,7 +34,7 @@ # Boost that contain header files only (e.g. foreach) you do not need to # specify COMPONENTS. # -# You should provide a minimum version number that should be used. If you provide this +# You should provide a minimum version number that should be used. If you provide this # version number and specify the REQUIRED attribute, this module will fail if it # can't find the specified or a later version. If you specify a version number this is # automatically put into the considered list of version numbers and thus doesn't need @@ -63,14 +64,15 @@ # Currently this module searches for the following version numbers: # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1, # 1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0, -# 1.40, 1.40.0, 1.41, 1.41.0 +# 1.40, 1.40.0, 1.41, 1.41.0, 1.42, 1.42.0, 1.43, 1.43.0, 1.44, 1.44.0, +# 1.45, 1.45.0, 1.46, 1.46.0, 1.46.1, 1.47, 1.47.0, 1.48, 1.48.0 # # NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should # add both 1.x and 1.x.0 as shown above. Official Boost include directories # omit the 3rd version number from include paths if it is 0 although not all # binary Boost releases do so. # -# SET(Boost_ADDITIONAL_VERSIONS "1.78" "1.78.0" "1.79" "1.79.0") +# set(Boost_ADDITIONAL_VERSIONS "1.78" "1.78.0" "1.79" "1.79.0") # # ===================================== ============= ======================== # @@ -84,6 +86,43 @@ # Boost_USE_STATIC_LIBS Can be set to ON to force the use of the static # boost libraries. Defaults to OFF. # +# Boost_NO_SYSTEM_PATHS Set to TRUE to suppress searching in system +# paths (or other locations outside of BOOST_ROOT +# or BOOST_INCLUDEDIR). Useful when specifying +# BOOST_ROOT. Defaults to OFF. +# [Since CMake 2.8.3] +# +# Boost_NO_BOOST_CMAKE Do not do a find_package call in config mode +# before searching for a regular boost install. +# This will avoid finding boost-cmake installs. +# Defaults to OFF. +# [Since CMake 2.8.6] +# +# Boost_USE_STATIC_RUNTIME If enabled, searches for boost libraries +# linked against a static C++ standard library +# ('s' ABI tag). This option should be set to +# ON or OFF because the default behavior +# if not specified is platform dependent +# for backwards compatibility. +# [Since CMake 2.8.3] +# +# Boost_USE_DEBUG_PYTHON If enabled, searches for boost libraries +# compiled against a special debug build of +# Python ('y' ABI tag). Defaults to OFF. +# [Since CMake 2.8.3] +# +# Boost_USE_STLPORT If enabled, searches for boost libraries +# compiled against the STLPort standard +# library ('p' ABI tag). Defaults to OFF. +# [Since CMake 2.8.3] +# +# Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS +# If enabled, searches for boost libraries +# compiled against the deprecated STLPort +# "native iostreams" feature ('n' ABI tag). +# Defaults to OFF. +# [Since CMake 2.8.3] +# # Other Variables used by this module which you may want to set. # # Boost_ADDITIONAL_VERSIONS A list of version numbers to use for searching @@ -101,17 +140,58 @@ # unless this is set to TRUE or the REQUIRED # keyword is specified in find_package(). # [Since CMake 2.8.0] -# +# # Boost_COMPILER Set this to the compiler suffix used by Boost # (e.g. "-gcc43") if FindBoost has problems finding # the proper Boost installation # +# Boost_THREADAPI When building boost.thread, sometimes the name of the +# library contains an additional "pthread" or "win32" +# string known as the threadapi. This can happen when +# compiling against pthreads on Windows or win32 threads +# on Cygwin. You may specify this variable and if set +# when FindBoost searches for the Boost threading library +# it will first try to match the threadapi you specify. +# For Example: libboost_thread_win32-mgw45-mt-1_43.a +# might be found if you specified "win32" here before +# falling back on libboost_thread-mgw45-mt-1_43.a. +# [Since CMake 2.8.3] +# +# Boost_REALPATH Resolves symbolic links for discovered boost libraries +# to assist with packaging. For example, instead of +# Boost_SYSTEM_LIBRARY_RELEASE being resolved to +# "/usr/lib/libboost_system.so" it would be +# "/usr/lib/libboost_system.so.1.42.0" instead. +# This does not affect linking and should not be +# enabled unless the user needs this information. +# [Since CMake 2.8.3] +# + + +# # These last three variables are available also as environment variables: +# Also, note they are completely UPPERCASE, except Boost_DIR. # -# BOOST_ROOT or BOOSTROOT The preferred installation prefix for searching for -# Boost. Set this if the module has problems finding +# Boost_DIR or The preferred installation prefix for searching for +# BOOST_ROOT or BOOSTROOT Boost. Set this if the module has problems finding # the proper Boost installation. # +# Note that Boost_DIR behaves exactly as _DIR +# variables are documented to behave in find_package's +# Config mode. That is, if it is set as a -D argument +# to CMake, it must point to the location of the +# BoostConfig.cmake or Boost-config.cmake file. If it +# is set as an environment variable, it must point to +# the root of the boost installation. BOOST_ROOT and +# BOOSTROOT, on the other hand, will point to the root +# in either case. +# +# To prevent falling back on the system paths, set +# Boost_NO_SYSTEM_PATHS to true. +# +# To avoid finding boost-cmake installations, set +# Boost_NO_BOOST_CMAKE to true. +# # BOOST_INCLUDEDIR Set this to the include directory of Boost, if the # module has problems finding the proper Boost installation # @@ -165,7 +245,7 @@ # Copyright 2007 Wengo # Copyright 2007 Mike Jackson # Copyright 2008 Andreas Pakulat -# Copyright 2008-2009 Philip Lowman +# Copyright 2008-2010 Philip Lowman # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -174,9 +254,46 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) + +#------------------------------------------------------------------------------- +# Before we go searching, check whether boost-cmake is avaialble, unless the +# user specifically asked NOT to search for boost-cmake. +# +# If Boost_DIR is set, this behaves as any find_package call would. If not, +# it looks at BOOST_ROOT and BOOSTROOT to find Boost. +# +if (NOT Boost_NO_BOOST_CMAKE) + # If Boost_DIR is not set, look for BOOSTROOT and BOOST_ROOT as alternatives, + # since these are more conventional for Boost. + if ("$ENV{Boost_DIR}" STREQUAL "") + if (NOT "$ENV{BOOST_ROOT}" STREQUAL "") + set(ENV{Boost_DIR} $ENV{BOOST_ROOT}) + elseif (NOT "$ENV{BOOSTROOT}" STREQUAL "") + set(ENV{Boost_DIR} $ENV{BOOSTROOT}) + endif() + endif() + + # Do the same find_package call but look specifically for the CMake version. + # Note that args are passed in the Boost_FIND_xxxxx variables, so there is no + # need to delegate them to this find_package call. + find_package(Boost QUIET NO_MODULE) + + # If we found boost-cmake, then we're done. Print out what we found. + # Otherwise let the rest of the module try to find it. + if (Boost_FOUND) + message("Boost ${Boost_FIND_VERSION} found.") + if (Boost_FIND_COMPONENTS) + message("Found Boost components:") + message(" ${Boost_FIND_COMPONENTS}") + endif() + return() + endif() +endif() + + #------------------------------------------------------------------------------- # FindBoost functions & macros # @@ -192,59 +309,65 @@ # And ELSE/ENDIF pairs were removed for readability. ######################################################################### -MACRO (_Boost_ADJUST_LIB_VARS basename) - IF (Boost_INCLUDE_DIR ) - IF (Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE) +macro(_Boost_ADJUST_LIB_VARS basename) + if(Boost_INCLUDE_DIR ) + if(Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE) # if the generator supports configuration types then set # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value - IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) - SET(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG}) - ELSE() + if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + set(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG}) + else() # if there are no configuration types and CMAKE_BUILD_TYPE has no value # then just use the release libraries - SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} ) - ENDIF() + set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} ) + endif() # FIXME: This probably should be set for both cases - SET(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG}) - ENDIF() + set(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG}) + endif() # if only the release version was found, set the debug variable also to the release version - IF (Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG) - SET(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE}) - SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE}) - SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE}) - ENDIF() + if(Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG) + set(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE}) + set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE}) + set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE}) + endif() # if only the debug version was found, set the release variable also to the debug version - IF (Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE) - SET(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG}) - SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG}) - SET(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG}) - ENDIF() - - IF (Boost_${basename}_LIBRARY) + if(Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE) + set(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG}) + set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG}) + set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG}) + endif() + + # If the debug & release library ends up being the same, omit the keywords + if(${Boost_${basename}_LIBRARY_RELEASE} STREQUAL ${Boost_${basename}_LIBRARY_DEBUG}) + set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} ) + set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE} ) + endif() + + if(Boost_${basename}_LIBRARY) set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library") # Remove superfluous "debug" / "optimized" keywords from # Boost_LIBRARY_DIRS - FOREACH(_boost_my_lib ${Boost_${basename}_LIBRARY}) - GET_FILENAME_COMPONENT(_boost_my_lib_path "${_boost_my_lib}" PATH) - LIST(APPEND Boost_LIBRARY_DIRS ${_boost_my_lib_path}) - ENDFOREACH() - LIST(REMOVE_DUPLICATES Boost_LIBRARY_DIRS) + foreach(_boost_my_lib ${Boost_${basename}_LIBRARY}) + get_filename_component(_boost_my_lib_path "${_boost_my_lib}" PATH) + list(APPEND Boost_LIBRARY_DIRS ${_boost_my_lib_path}) + endforeach() + list(REMOVE_DUPLICATES Boost_LIBRARY_DIRS) set(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS} CACHE FILEPATH "Boost library directory") - SET(Boost_${basename}_FOUND ON CACHE INTERNAL "Whether the Boost ${basename} library found") - ENDIF(Boost_${basename}_LIBRARY) + set(Boost_${basename}_FOUND ON CACHE INTERNAL "Whether the Boost ${basename} library found") + endif(Boost_${basename}_LIBRARY) - ENDIF (Boost_INCLUDE_DIR ) + endif(Boost_INCLUDE_DIR ) # Make variables changeble to the advanced user - MARK_AS_ADVANCED( + mark_as_advanced( Boost_${basename}_LIBRARY Boost_${basename}_LIBRARY_RELEASE Boost_${basename}_LIBRARY_DEBUG ) -ENDMACRO (_Boost_ADJUST_LIB_VARS) +endmacro(_Boost_ADJUST_LIB_VARS) #------------------------------------------------------------------------------- @@ -252,17 +375,17 @@ ENDMACRO (_Boost_ADJUST_LIB_VARS) # Runs compiler with "-dumpversion" and parses major/minor # version with a regex. # -FUNCTION(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION) +function(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION) - EXEC_PROGRAM(${CMAKE_CXX_COMPILER} + exec_program(${CMAKE_CXX_COMPILER} ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion OUTPUT_VARIABLE _boost_COMPILER_VERSION ) - STRING(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2" + string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2" _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION}) - SET(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE) -ENDFUNCTION() + set(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE) +endfunction() # # A convenience function for marking desired components @@ -276,16 +399,45 @@ function(_Boost_MARK_COMPONENTS_FOUND _yes_or_no) endfunction() # +# Take a list of libraries with "thread" in it +# and prepend duplicates with "thread_${Boost_THREADAPI}" +# at the front of the list +# +function(_Boost_PREPEND_LIST_WITH_THREADAPI _output) + set(_orig_libnames ${ARGN}) + string(REPLACE "thread" "thread_${Boost_THREADAPI}" _threadapi_libnames ${_orig_libnames}) + set(${_output} ${_threadapi_libnames} ${_orig_libnames} PARENT_SCOPE) +endfunction() + +# +# If a library is found, replace its cache entry with its REALPATH +# +function(_Boost_SWAP_WITH_REALPATH _library _docstring) + if(${_library}) + get_filename_component(_boost_filepathreal ${${_library}} REALPATH) + unset(${_library} CACHE) + set(${_library} ${_boost_filepathreal} CACHE FILEPATH "${_docstring}") + endif() +endfunction() + +function(_Boost_CHECK_SPELLING _var) + if(${_var}) + string(TOUPPER ${_var} _var_UC) + message(FATAL_ERROR "ERROR: ${_var} is not the correct spelling. The proper spelling is ${_var_UC}.") + endif() +endfunction() + +# # End functions/macros -# +# #------------------------------------------------------------------------------- -IF(NOT DEFINED Boost_USE_MULTITHREADED) - SET(Boost_USE_MULTITHREADED TRUE) -ENDIF() +if(NOT DEFINED Boost_USE_MULTITHREADED) + set(Boost_USE_MULTITHREADED TRUE) +endif() if(Boost_FIND_VERSION_EXACT) # The version may appear in a directory with or without the patch @@ -297,6 +449,8 @@ else(Boost_FIND_VERSION_EXACT) # The user has not requested an exact version. Among known # versions, find those that are acceptable to the user request. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} + "1.48.0" "1.48" "1.47.0" "1.47" "1.46.1" + "1.46.0" "1.46" "1.45.0" "1.45" "1.44.0" "1.44" "1.43.0" "1.43" "1.42.0" "1.42" "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33") @@ -325,49 +479,47 @@ endif(Boost_FIND_VERSION_EXACT) # Boost. set(Boost_ERROR_REASON) -SET( _boost_IN_CACHE TRUE) -IF(Boost_INCLUDE_DIR) +set( _boost_IN_CACHE TRUE) +if(Boost_INCLUDE_DIR) # On versions < 1.35, remove the System library from the considered list # since it wasn't added until 1.35. if(Boost_VERSION AND Boost_FIND_COMPONENTS) - math(EXPR _boost_maj "${Boost_VERSION} / 100000") - math(EXPR _boost_min "${Boost_VERSION} / 100 % 1000") - if(${_boost_maj}.${_boost_min} VERSION_LESS 1.35) + if(Boost_VERSION LESS 103500) list(REMOVE_ITEM Boost_FIND_COMPONENTS system) endif() endif() - FOREACH(COMPONENT ${Boost_FIND_COMPONENTS}) - STRING(TOUPPER ${COMPONENT} COMPONENT) - IF(NOT Boost_${COMPONENT}_FOUND) - SET( _boost_IN_CACHE FALSE) - ENDIF(NOT Boost_${COMPONENT}_FOUND) - ENDFOREACH(COMPONENT) -ELSE(Boost_INCLUDE_DIR) - SET( _boost_IN_CACHE FALSE) -ENDIF(Boost_INCLUDE_DIR) - -IF (_boost_IN_CACHE) + foreach(COMPONENT ${Boost_FIND_COMPONENTS}) + string(TOUPPER ${COMPONENT} COMPONENT) + if(NOT Boost_${COMPONENT}_FOUND) + set( _boost_IN_CACHE FALSE) + endif(NOT Boost_${COMPONENT}_FOUND) + endforeach(COMPONENT) +else(Boost_INCLUDE_DIR) + set( _boost_IN_CACHE FALSE) +endif(Boost_INCLUDE_DIR) + +if(_boost_IN_CACHE) # in cache already - SET(Boost_FOUND TRUE) - FOREACH(COMPONENT ${Boost_FIND_COMPONENTS}) - STRING(TOUPPER ${COMPONENT} COMPONENT) + set(Boost_FOUND TRUE) + foreach(COMPONENT ${Boost_FIND_COMPONENTS}) + string(TOUPPER ${COMPONENT} COMPONENT) _Boost_ADJUST_LIB_VARS( ${COMPONENT} ) - SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${COMPONENT}_LIBRARY}) - ENDFOREACH(COMPONENT) - SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR}) - IF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") - MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000") - MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000") - MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100") - ENDIF(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") + set(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${COMPONENT}_LIBRARY}) + endforeach(COMPONENT) + set(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR}) + if(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") + math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000") + math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000") + math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100") + endif(Boost_VERSION AND NOT "${Boost_VERSION}" STREQUAL "0") if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "boost ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} " - "is already in the cache. For debugging messages, please clear the cache.") + "is already in the cache. To view debugging messages, please clear the cache.") endif() -ELSE (_boost_IN_CACHE) +else(_boost_IN_CACHE) # Need to search for boost if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " @@ -379,9 +531,15 @@ ELSE (_boost_IN_CACHE) "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Boost_USE_STATIC_RUNTIME = ${Boost_USE_STATIC_RUNTIME}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Boost_ADDITIONAL_VERSIONS = ${Boost_ADDITIONAL_VERSIONS}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Boost_NO_SYSTEM_PATHS = ${Boost_NO_SYSTEM_PATHS}") endif() - IF(WIN32) + if(WIN32) # In windows, automatic linking is performed, so you do not have # to specify the libraries. If you are linking to a dynamic # runtime, then you can choose to link to either a static or a @@ -390,20 +548,20 @@ ELSE (_boost_IN_CACHE) # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be # linked dynamically. Alternatively you can force all Boost # libraries to dynamic link by defining BOOST_ALL_DYN_LINK. - + # This feature can be disabled for Boost library "whatever" by # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining # BOOST_ALL_NO_LIB. - + # If you want to observe which libraries are being linked against # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking # code to emit a #pragma message each time a library is selected # for linking. - SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS + set(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define") - ENDIF(WIN32) + endif(WIN32) - SET(_boost_INCLUDE_SEARCH_DIRS + set(_boost_INCLUDE_SEARCH_DIRS_SYSTEM C:/boost/include C:/boost "$ENV{ProgramFiles}/boost/include" @@ -411,29 +569,38 @@ ELSE (_boost_IN_CACHE) /sw/local/include ) + _Boost_CHECK_SPELLING(Boost_ROOT) + _Boost_CHECK_SPELLING(Boost_LIBRARYDIR) + _Boost_CHECK_SPELLING(Boost_INCLUDEDIR) + + # If BOOST_ROOT was defined in the environment, use it. + if (NOT BOOST_ROOT AND NOT $ENV{Boost_DIR} STREQUAL "") + set(BOOST_ROOT $ENV{Boost_DIR}) + endif() + # If BOOST_ROOT was defined in the environment, use it. if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") set(BOOST_ROOT $ENV{BOOST_ROOT}) - endif(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") + endif() # If BOOSTROOT was defined in the environment, use it. if (NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "") set(BOOST_ROOT $ENV{BOOSTROOT}) - endif(NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "") + endif() # If BOOST_INCLUDEDIR was defined in the environment, use it. - IF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" ) + if( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" ) set(BOOST_INCLUDEDIR $ENV{BOOST_INCLUDEDIR}) - ENDIF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" ) - + endif() + # If BOOST_LIBRARYDIR was defined in the environment, use it. - IF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" ) + if( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" ) set(BOOST_LIBRARYDIR $ENV{BOOST_LIBRARYDIR}) - ENDIF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" ) - - IF( BOOST_ROOT ) + endif() + + if( BOOST_ROOT ) file(TO_CMAKE_PATH ${BOOST_ROOT} BOOST_ROOT) - ENDIF( BOOST_ROOT ) + endif() if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " @@ -448,50 +615,54 @@ ELSE (_boost_IN_CACHE) "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}") endif() - IF( BOOST_ROOT ) - SET(_boost_INCLUDE_SEARCH_DIRS - ${BOOST_ROOT}/include + if( Boost_NO_SYSTEM_PATHS) + set(_boost_FIND_OPTIONS NO_CMAKE_SYSTEM_PATH) + else() + set(_boost_INCLUDE_SEARCH_DIRS ${_boost_INCLUDE_SEARCH_DIRS_SYSTEM}) + endif() + + if( BOOST_ROOT ) + set(_boost_INCLUDE_SEARCH_DIRS + ${BOOST_ROOT}/include ${BOOST_ROOT} ${_boost_INCLUDE_SEARCH_DIRS}) - ENDIF( BOOST_ROOT ) + endif() - IF( BOOST_INCLUDEDIR ) + # prepend BOOST_INCLUDEDIR to search path if specified + if( BOOST_INCLUDEDIR ) file(TO_CMAKE_PATH ${BOOST_INCLUDEDIR} BOOST_INCLUDEDIR) - SET(_boost_INCLUDE_SEARCH_DIRS + set(_boost_INCLUDE_SEARCH_DIRS ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS}) - ENDIF( BOOST_INCLUDEDIR ) + endif( BOOST_INCLUDEDIR ) # ------------------------------------------------------------------------ - # Search for Boost include DIR + # Search for Boost include DIR # ------------------------------------------------------------------------ # Try to find Boost by stepping backwards through the Boost versions # we know about. - IF( NOT Boost_INCLUDE_DIR ) + if( NOT Boost_INCLUDE_DIR ) # Build a list of path suffixes for each version. - SET(_boost_PATH_SUFFIXES) - FOREACH(_boost_VER ${_boost_TEST_VERSIONS}) + set(_boost_PATH_SUFFIXES) + foreach(_boost_VER ${_boost_TEST_VERSIONS}) # Add in a path suffix, based on the required version, ideally # we could read this from version.hpp, but for that to work we'd # need to know the include dir already set(_boost_BOOSTIFIED_VERSION) # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0 - IF(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+") - STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" + if(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+") + string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" _boost_BOOSTIFIED_VERSION ${_boost_VER}) - ELSEIF(_boost_VER MATCHES "[0-9]+\\.[0-9]+") - STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" + elseif(_boost_VER MATCHES "[0-9]+\\.[0-9]+") + string(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" _boost_BOOSTIFIED_VERSION ${_boost_VER}) - ENDIF() - - list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}") - if(WIN32) - # For BoostPro's underscores (and others?) - list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}") endif() - ENDFOREACH(_boost_VER) - + list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}") + list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}") + + endforeach(_boost_VER) + if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "Include debugging info:") @@ -502,61 +673,62 @@ ELSE (_boost_IN_CACHE) endif() # Look for a standard boost header file. - FIND_PATH(Boost_INCLUDE_DIR + find_path(Boost_INCLUDE_DIR NAMES boost/config.hpp HINTS ${_boost_INCLUDE_SEARCH_DIRS} PATH_SUFFIXES ${_boost_PATH_SUFFIXES} + ${_boost_FIND_OPTIONS} ) - ENDIF( NOT Boost_INCLUDE_DIR ) - + endif( NOT Boost_INCLUDE_DIR ) + # ------------------------------------------------------------------------ # Extract version information from version.hpp # ------------------------------------------------------------------------ - IF(Boost_INCLUDE_DIR) + if(Boost_INCLUDE_DIR) # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp # Read the whole file: # - SET(BOOST_VERSION 0) - SET(BOOST_LIB_VERSION "") - FILE(READ "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS) + set(BOOST_VERSION 0) + set(BOOST_LIB_VERSION "") + file(READ "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS) if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp") endif() - - STRING(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}") - STRING(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}") - - SET(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE INTERNAL "The library version string for boost libraries") - SET(Boost_VERSION ${Boost_VERSION} CACHE INTERNAL "The version number for boost libraries") - - IF(NOT "${Boost_VERSION}" STREQUAL "0") - MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000") - MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000") - MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100") + + string(REGEX REPLACE ".*#define BOOST_VERSION ([0-9]+).*" "\\1" Boost_VERSION "${_boost_VERSION_HPP_CONTENTS}") + string(REGEX REPLACE ".*#define BOOST_LIB_VERSION \"([0-9_]+)\".*" "\\1" Boost_LIB_VERSION "${_boost_VERSION_HPP_CONTENTS}") + + set(Boost_LIB_VERSION ${Boost_LIB_VERSION} CACHE INTERNAL "The library version string for boost libraries") + set(Boost_VERSION ${Boost_VERSION} CACHE INTERNAL "The version number for boost libraries") + + if(NOT "${Boost_VERSION}" STREQUAL "0") + math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000") + math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000") + math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100") set(Boost_ERROR_REASON "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}") - ENDIF(NOT "${Boost_VERSION}" STREQUAL "0") + endif(NOT "${Boost_VERSION}" STREQUAL "0") if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "version.hpp reveals boost " "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") endif() - ELSE(Boost_INCLUDE_DIR) + else(Boost_INCLUDE_DIR) set(Boost_ERROR_REASON "${Boost_ERROR_REASON}Unable to find the Boost header files. Please set BOOST_ROOT to the root directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost's headers.") - ENDIF(Boost_INCLUDE_DIR) - + endif(Boost_INCLUDE_DIR) + # ------------------------------------------------------------------------ # Suffix initialization and compiler suffix detection. # ------------------------------------------------------------------------ # Setting some more suffixes for the library - SET (Boost_LIB_PREFIX "") - if ( WIN32 AND Boost_USE_STATIC_LIBS ) - SET (Boost_LIB_PREFIX "lib") + set(Boost_LIB_PREFIX "") + if ( WIN32 AND Boost_USE_STATIC_LIBS AND NOT CYGWIN) + set(Boost_LIB_PREFIX "lib") endif() if (Boost_COMPILER) @@ -571,62 +743,64 @@ ELSE (_boost_IN_CACHE) # please report them and use the Boost_COMPILER variable # to work around the problems. if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" - OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" + OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc") if(WIN32) set (_boost_COMPILER "-iw") else() set (_boost_COMPILER "-il") endif() - elseif (MSVC90) - SET (_boost_COMPILER "-vc90") + elseif (MSVC11) + set(_boost_COMPILER "-vc110") elseif (MSVC10) - SET (_boost_COMPILER "-vc100") + set(_boost_COMPILER "-vc100") + elseif (MSVC90) + set(_boost_COMPILER "-vc90") elseif (MSVC80) - SET (_boost_COMPILER "-vc80") + set(_boost_COMPILER "-vc80") elseif (MSVC71) - SET (_boost_COMPILER "-vc71") + set(_boost_COMPILER "-vc71") elseif (MSVC70) # Good luck! - SET (_boost_COMPILER "-vc7") # yes, this is correct + set(_boost_COMPILER "-vc7") # yes, this is correct elseif (MSVC60) # Good luck! - SET (_boost_COMPILER "-vc6") # yes, this is correct + set(_boost_COMPILER "-vc6") # yes, this is correct elseif (BORLAND) - SET (_boost_COMPILER "-bcb") + set(_boost_COMPILER "-bcb") elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "SunPro") set(_boost_COMPILER "-sw") elseif (MINGW) if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34) - SET(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34 + set(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34 else() _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION) - SET (_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}") + set(_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}") endif() elseif (UNIX) if (CMAKE_COMPILER_IS_GNUCXX) if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34) - SET(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34 + set(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34 else() _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION) # Determine which version of GCC we have. - IF(APPLE) - IF(Boost_MINOR_VERSION) - IF(${Boost_MINOR_VERSION} GREATER 35) + if(APPLE) + if(Boost_MINOR_VERSION) + if(${Boost_MINOR_VERSION} GREATER 35) # In Boost 1.36.0 and newer, the mangled compiler name used # on Mac OS X/Darwin is "xgcc". - SET(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}") - ELSE(${Boost_MINOR_VERSION} GREATER 35) + set(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}") + else(${Boost_MINOR_VERSION} GREATER 35) # In Boost <= 1.35.0, there is no mangled compiler name for # the Mac OS X/Darwin version of GCC. - SET(_boost_COMPILER "") - ENDIF(${Boost_MINOR_VERSION} GREATER 35) - ELSE(Boost_MINOR_VERSION) + set(_boost_COMPILER "") + endif(${Boost_MINOR_VERSION} GREATER 35) + else(Boost_MINOR_VERSION) # We don't know the Boost version, so assume it's # pre-1.36.0. - SET(_boost_COMPILER "") - ENDIF(Boost_MINOR_VERSION) - ELSE() - SET (_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}") - ENDIF() + set(_boost_COMPILER "") + endif(Boost_MINOR_VERSION) + else() + set(_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}") + endif() endif() endif (CMAKE_COMPILER_IS_GNUCXX) endif() @@ -636,7 +810,7 @@ ELSE (_boost_IN_CACHE) endif() endif(Boost_COMPILER) - SET (_boost_MULTITHREADED "-mt") + set (_boost_MULTITHREADED "-mt") if( NOT Boost_USE_MULTITHREADED ) set (_boost_MULTITHREADED "") endif() @@ -645,32 +819,67 @@ ELSE (_boost_IN_CACHE) "_boost_MULTITHREADED = ${_boost_MULTITHREADED}") endif() - SET( _boost_STATIC_TAG "") - set( _boost_ABI_TAG "") - IF (WIN32) - IF(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" + #====================== + # Systematically build up the Boost ABI tag + # http://boost.org/doc/libs/1_41_0/more/getting_started/windows.html#library-naming + set( _boost_RELEASE_ABI_TAG "-") + set( _boost_DEBUG_ABI_TAG "-") + # Key Use this library when: + # s linking statically to the C++ standard library and + # compiler runtime support libraries. + if(Boost_USE_STATIC_RUNTIME) + set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}s") + set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}s") + endif() + # g using debug versions of the standard and runtime + # support libraries + if(WIN32) + if(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc") - SET (_boost_ABI_TAG "g") - ENDIF() - IF( Boost_USE_STATIC_LIBS ) - SET( _boost_STATIC_TAG "-s") - ENDIF( Boost_USE_STATIC_LIBS ) - ENDIF(WIN32) - SET (_boost_ABI_TAG "${_boost_ABI_TAG}d") + set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}g") + endif() + endif() + # y using special debug build of python + if(Boost_USE_DEBUG_PYTHON) + set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}y") + endif() + # d using a debug version of your code + set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}d") + # p using the STLport standard library rather than the + # default one supplied with your compiler + if(Boost_USE_STLPORT) + set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}p") + set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}p") + endif() + # n using the STLport deprecated "native iostreams" feature + if(Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS) + set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}n") + set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}n") + endif() + if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_STATIC_TAG = ${_boost_STATIC_TAG}") + "_boost_RELEASE_ABI_TAG = ${_boost_RELEASE_ABI_TAG}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_ABI_TAG = ${_boost_ABI_TAG}") + "_boost_DEBUG_ABI_TAG = ${_boost_DEBUG_ABI_TAG}") endif() # ------------------------------------------------------------------------ # Begin finding boost libraries # ------------------------------------------------------------------------ - SET(_boost_LIBRARIES_SEARCH_DIRS + if(BOOST_ROOT) + set(_boost_LIBRARY_SEARCH_DIRS_ALWAYS + ${BOOST_ROOT}/lib + ${BOOST_ROOT}/stage/lib) + endif() + set(_boost_LIBRARY_SEARCH_DIRS_ALWAYS + ${_boost_LIBRARY_SEARCH_DIRS_ALWAYS} ${Boost_INCLUDE_DIR}/lib ${Boost_INCLUDE_DIR}/../lib + ${Boost_INCLUDE_DIR}/stage/lib + ) + set(_boost_LIBRARY_SEARCH_DIRS_SYSTEM C:/boost/lib C:/boost "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}_${Boost_SUBMINOR_VERSION}/lib" @@ -679,78 +888,158 @@ ELSE (_boost_IN_CACHE) "$ENV{ProgramFiles}/boost" /sw/local/lib ) - IF( BOOST_ROOT ) - SET(_boost_LIBRARIES_SEARCH_DIRS - ${BOOST_ROOT}/lib - ${BOOST_ROOT}/stage/lib - ${_boost_LIBRARIES_SEARCH_DIRS}) - ENDIF( BOOST_ROOT ) - - IF( BOOST_LIBRARYDIR ) + set(_boost_LIBRARY_SEARCH_DIRS ${_boost_LIBRARY_SEARCH_DIRS_ALWAYS}) + if( Boost_NO_SYSTEM_PATHS ) + set(_boost_FIND_OPTIONS NO_CMAKE_SYSTEM_PATH) + else() + list(APPEND _boost_LIBRARY_SEARCH_DIRS ${_boost_LIBRARY_SEARCH_DIRS_SYSTEM}) + endif() + + # prepend BOOST_LIBRARYDIR to search path if specified + if( BOOST_LIBRARYDIR ) file(TO_CMAKE_PATH ${BOOST_LIBRARYDIR} BOOST_LIBRARYDIR) - SET(_boost_LIBRARIES_SEARCH_DIRS - ${BOOST_LIBRARYDIR} ${_boost_LIBRARIES_SEARCH_DIRS}) - ENDIF( BOOST_LIBRARYDIR ) + set(_boost_LIBRARY_SEARCH_DIRS + ${BOOST_LIBRARYDIR} ${_boost_LIBRARY_SEARCH_DIRS}) + endif() if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_LIBRARIES_SEARCH_DIRS = ${_boost_LIBRARIES_SEARCH_DIRS}") - endif() - - FOREACH(COMPONENT ${Boost_FIND_COMPONENTS}) - STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT) - SET( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" ) - SET( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" ) - SET( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND") - - # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES - IF( Boost_USE_STATIC_LIBS ) - SET( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - IF(WIN32) - SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - ELSE(WIN32) - SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - ENDIF(WIN32) - ENDIF( Boost_USE_STATIC_LIBS ) - - FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE - NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG} - HINTS ${_boost_LIBRARIES_SEARCH_DIRS} + "_boost_LIBRARY_SEARCH_DIRS = ${_boost_LIBRARY_SEARCH_DIRS}") + endif() + + # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES + if( Boost_USE_STATIC_LIBS ) + set( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ) + endif() + endif() + + # We want to use the tag inline below without risking double dashes + if(_boost_RELEASE_ABI_TAG) + if(${_boost_RELEASE_ABI_TAG} STREQUAL "-") + set(_boost_RELEASE_ABI_TAG "") + endif() + endif() + if(_boost_DEBUG_ABI_TAG) + if(${_boost_DEBUG_ABI_TAG} STREQUAL "-") + set(_boost_DEBUG_ABI_TAG "") + endif() + endif() + + # The previous behavior of FindBoost when Boost_USE_STATIC_LIBS was enabled + # on WIN32 was to: + # 1. Search for static libs compiled against a SHARED C++ standard runtime library (use if found) + # 2. Search for static libs compiled against a STATIC C++ standard runtime library (use if found) + # We maintain this behavior since changing it could break people's builds. + # To disable the ambiguous behavior, the user need only + # set Boost_USE_STATIC_RUNTIME either ON or OFF. + set(_boost_STATIC_RUNTIME_WORKAROUND false) + if(WIN32 AND Boost_USE_STATIC_LIBS) + if(NOT DEFINED Boost_USE_STATIC_RUNTIME) + set(_boost_STATIC_RUNTIME_WORKAROUND true) + endif() + endif() + + + foreach(COMPONENT ${Boost_FIND_COMPONENTS}) + string(TOUPPER ${COMPONENT} UPPERCOMPONENT) + set( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" ) + set( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" ) + set( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND") + + set( _boost_docstring_release "Boost ${COMPONENT} library (release)") + set( _boost_docstring_debug "Boost ${COMPONENT} library (debug)") + + # + # Find RELEASE libraries + # + set(_boost_RELEASE_NAMES + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT} ) + if(_boost_STATIC_RUNTIME_WORKAROUND) + set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}") + list(APPEND _boost_RELEASE_NAMES + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} ) + endif() + if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread") + _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_RELEASE_NAMES ${_boost_RELEASE_NAMES}) + endif() + if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Searching for ${UPPERCOMPONENT}_LIBRARY_RELEASE: ${_boost_RELEASE_NAMES}") + endif() + find_library(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE + NAMES ${_boost_RELEASE_NAMES} + HINTS ${_boost_LIBRARY_SEARCH_DIRS} + ${_boost_FIND_OPTIONS} + DOC "${_boost_docstring_release}" ) - FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG - NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG} - ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_boost_ABI_TAG} - HINTS ${_boost_LIBRARIES_SEARCH_DIRS} + # + # Find DEBUG libraries + # + set(_boost_DEBUG_NAMES + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED} + ${Boost_LIB_PREFIX}boost_${COMPONENT} ) + if(_boost_STATIC_RUNTIME_WORKAROUND) + set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}") + list(APPEND _boost_DEBUG_NAMES + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} ) + endif() + if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread") + _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_DEBUG_NAMES ${_boost_DEBUG_NAMES}) + endif() + if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Searching for ${UPPERCOMPONENT}_LIBRARY_DEBUG: ${_boost_DEBUG_NAMES}") + endif() + find_library(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG + NAMES ${_boost_DEBUG_NAMES} + HINTS ${_boost_LIBRARY_SEARCH_DIRS} + ${_boost_FIND_OPTIONS} + DOC "${_boost_docstring_debug}" ) + if(Boost_REALPATH) + _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "${_boost_docstring_release}") + _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "${_boost_docstring_debug}" ) + endif() + _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT}) - IF( Boost_USE_STATIC_LIBS ) - SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) - ENDIF( Boost_USE_STATIC_LIBS ) - ENDFOREACH(COMPONENT) + + endforeach(COMPONENT) + + # Restore the original find library ordering + if( Boost_USE_STATIC_LIBS ) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) + endif() # ------------------------------------------------------------------------ # End finding boost libraries # ------------------------------------------------------------------------ - SET(Boost_INCLUDE_DIRS + set(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR} ) - SET(Boost_FOUND FALSE) - IF(Boost_INCLUDE_DIR) - SET( Boost_FOUND TRUE ) + set(Boost_FOUND FALSE) + if(Boost_INCLUDE_DIR) + set( Boost_FOUND TRUE ) # Check the version of Boost against the requested version. if (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR) @@ -785,7 +1074,7 @@ ELSE (_boost_IN_CACHE) if (NOT Boost_FIND_VERSION_PATCH) set(Boost_FIND_VERSION_PATCH 0) endif (NOT Boost_FIND_VERSION_PATCH) - + # We'll set Boost_FOUND true again if we have an exact version match. set(Boost_FOUND FALSE) _Boost_MARK_COMPONENTS_FOUND(OFF) @@ -804,7 +1093,7 @@ ELSE (_boost_IN_CACHE) set(Boost_ERROR_REASON "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}") if (Boost_FIND_VERSION_PATCH) - set(Boost_ERROR_REASON + set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}") endif (Boost_FIND_VERSION_PATCH) if (NOT Boost_FIND_VERSION_EXACT) @@ -823,7 +1112,7 @@ ELSE (_boost_IN_CACHE) string(TOLOWER ${COMPONENT} COMPONENT) list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT}) set( Boost_FOUND FALSE) - endif(NOT Boost_${COMPONENT}_FOUND) + endif() endforeach(COMPONENT) if(Boost_DEBUG) @@ -844,67 +1133,67 @@ ELSE (_boost_IN_CACHE) list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS) if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS}) set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}No Boost libraries were found. You may need to set Boost_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") + "${Boost_ERROR_REASON}No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") else (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS}) set(Boost_ERROR_REASON - "${Boost_ERROR_REASON}Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set Boost_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") + "${Boost_ERROR_REASON}Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") endif (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS}) endif (_Boost_MISSING_COMPONENTS) - IF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT ) + if( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT ) # Compatibility Code for backwards compatibility with CMake # 2.4's FindBoost module. # Look for the boost library path. # Note that the user may not have installed any libraries # so it is quite possible the Boost_LIBRARY_PATH may not exist. - SET(_boost_LIB_DIR ${Boost_INCLUDE_DIR}) - - IF("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+") - GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH) - ENDIF ("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+") - - IF("${_boost_LIB_DIR}" MATCHES "/include$") + set(_boost_LIB_DIR ${Boost_INCLUDE_DIR}) + + if("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+") + get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH) + endif() + + if("${_boost_LIB_DIR}" MATCHES "/include$") # Strip off the trailing "/include" in the path. - GET_FILENAME_COMPONENT(_boost_LIB_DIR ${_boost_LIB_DIR} PATH) - ENDIF("${_boost_LIB_DIR}" MATCHES "/include$") - - IF(EXISTS "${_boost_LIB_DIR}/lib") - SET (_boost_LIB_DIR ${_boost_LIB_DIR}/lib) - ELSE(EXISTS "${_boost_LIB_DIR}/lib") - IF(EXISTS "${_boost_LIB_DIR}/stage/lib") - SET(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib) - ELSE(EXISTS "${_boost_LIB_DIR}/stage/lib") - SET(_boost_LIB_DIR "") - ENDIF(EXISTS "${_boost_LIB_DIR}/stage/lib") - ENDIF(EXISTS "${_boost_LIB_DIR}/lib") - - IF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}") - SET(Boost_LIBRARY_DIRS ${_boost_LIB_DIR} CACHE FILEPATH "Boost library directory") - ENDIF(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}") - - ENDIF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT ) - - ELSE(Boost_INCLUDE_DIR) - SET( Boost_FOUND FALSE) - ENDIF(Boost_INCLUDE_DIR) - - IF (Boost_FOUND) - IF (NOT Boost_FIND_QUIETLY) - MESSAGE(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") + get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH) + endif() + + if(EXISTS "${_boost_LIB_DIR}/lib") + set(_boost_LIB_DIR ${_boost_LIB_DIR}/lib) + else() + if(EXISTS "${_boost_LIB_DIR}/stage/lib") + set(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib) + else() + set(_boost_LIB_DIR "") + endif() + endif() + + if(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}") + set(Boost_LIBRARY_DIRS ${_boost_LIB_DIR} CACHE FILEPATH "Boost library directory") + endif() + + endif( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT ) + + else(Boost_INCLUDE_DIR) + set( Boost_FOUND FALSE) + endif(Boost_INCLUDE_DIR) + + if(Boost_FOUND) + if(NOT Boost_FIND_QUIETLY) + message(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") if(Boost_FIND_COMPONENTS) message(STATUS "Found the following Boost libraries:") endif() - ENDIF(NOT Boost_FIND_QUIETLY) - FOREACH ( COMPONENT ${Boost_FIND_COMPONENTS} ) - STRING( TOUPPER ${COMPONENT} UPPERCOMPONENT ) - IF ( Boost_${UPPERCOMPONENT}_FOUND ) - IF (NOT Boost_FIND_QUIETLY) - MESSAGE (STATUS " ${COMPONENT}") - ENDIF(NOT Boost_FIND_QUIETLY) - SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${UPPERCOMPONENT}_LIBRARY}) - ENDIF ( Boost_${UPPERCOMPONENT}_FOUND ) - ENDFOREACH(COMPONENT) + endif(NOT Boost_FIND_QUIETLY) + foreach( COMPONENT ${Boost_FIND_COMPONENTS} ) + string( TOUPPER ${COMPONENT} UPPERCOMPONENT ) + if( Boost_${UPPERCOMPONENT}_FOUND ) + if(NOT Boost_FIND_QUIETLY) + message (STATUS " ${COMPONENT}") + endif(NOT Boost_FIND_QUIETLY) + set(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${UPPERCOMPONENT}_LIBRARY}) + endif( Boost_${UPPERCOMPONENT}_FOUND ) + endforeach(COMPONENT) else() if(Boost_FIND_REQUIRED) message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}") @@ -924,9 +1213,8 @@ ELSE (_boost_IN_CACHE) endif() # show the Boost_INCLUDE_DIRS AND Boost_LIBRARIES variables only in the advanced view - MARK_AS_ADVANCED(Boost_INCLUDE_DIR + mark_as_advanced(Boost_INCLUDE_DIR Boost_INCLUDE_DIRS Boost_LIBRARY_DIRS ) -ENDIF(_boost_IN_CACHE) - +endif(_boost_IN_CACHE) diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index dace3f5..848a6eb 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -26,6 +26,7 @@ import re import getopt import shutil import platform +import string def initialize_environment(): if not options.generate: options.generate = bool(os.getenv("TEST_GENERATE")) @@ -91,8 +92,7 @@ def compare_png(resultfilename): options.convert_exec = 'compare' compare_method = 'NCC' - msg = 'ImageMagick image comparison: ' - msg += os.path.basename(options.convert_exec) + ' ' + ' '.join(args) + msg = 'ImageMagick image comparison: ' + options.convert_exec + ' '+ ' '.join(args[2:]) msg += '\nexpected image: ' + expectedfilename + '\n' print >> sys.stderr, msg if not resultfilename: -- cgit v0.10.1 From b23c60d320f744f0e585992ba32226daa685d6cb Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 7 Dec 2011 00:47:15 -0600 Subject: add notice about NDEBUG and CMakeCache.txt to fix cgalpngtest errors diff --git a/doc/testing.txt b/doc/testing.txt index 6b0f0d2..403ef4a 100644 --- a/doc/testing.txt +++ b/doc/testing.txt @@ -83,3 +83,8 @@ based on Normalized Cross Correlation. Pass -DCOMPARATOR=ncc to cmake Your version of imagemagick is old. Upgrade, or pass -DCOMPARATOR=old to cmake. The comparison will be of lowered reliability. + +6. Many cgalpngtests are failing with weird assertion errors. + +Edit CMakeCache.txt and replace '-DNDEBUG' or '/D NDEBUG' with blank spaces + diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index 955d021..fa8b390 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -33,7 +33,6 @@ # 3. save the wikified data to disk # todo -# repair html output # do something if tests for GL extensions for OpenCSG fail (test fail, no image production) # copy all images, sysinfo.txt to bundle for html/upload (images # can be altered by subsequent runs) -- cgit v0.10.1 From faae7882e26c048b0ae2bf7a54065d31d0edbc31 Mon Sep 17 00:00:00 2001 From: Don Bright Date: Wed, 7 Dec 2011 00:56:40 -0600 Subject: fix pretty diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e668db3..bb05ce7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -487,10 +487,10 @@ set(CTEST_CUSTOM_TXT "\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() +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") -- cgit v0.10.1