summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDon Bright <hugh.m.bright@gmail.com>2011-11-13 20:34:01 (GMT)
committerDon Bright <hugh.m.bright@gmail.com>2011-11-13 20:34:01 (GMT)
commitc4231685f6cba5feec8bcec324a3fd884687d56e (patch)
tree37d0406d3017b509e147f88fea91e4972dfd2d48
parent1f9ce62573b65715e7b134ad4d8c8079fc28aa44 (diff)
option '--info' to opencsgtest for windows. also output html + wiki code.
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/OffscreenContext.cc47
-rw-r--r--tests/OffscreenContext.h2
-rw-r--r--tests/OffscreenContext.mm8
-rw-r--r--tests/OffscreenContextWGL.cc33
-rw-r--r--tests/OffscreenView.cc5
-rw-r--r--tests/OffscreenView.h2
-rw-r--r--tests/csgtestcore.cc55
-rwxr-xr-xtests/ctest_pretty_print.py60
-rw-r--r--tests/system-gl.cc38
-rw-r--r--tests/system-gl.h3
11 files changed, 210 insertions, 44 deletions
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 <GL/gl.h>
#include <GL/glx.h>
+#include <assert.h>
+#include <sstream>
+
+#include <sys/utsname.h> // 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 <iostream> // for error output
+#include <string>
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 <GL/gl.h> // must be included after glew.h
+#include <string>
+#include <sstream>
+
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 &center)
{
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 <Eigen/Core>
#include <Eigen/Geometry>
+#include <string>
#ifndef _MSC_VER
#include <stdint.h>
#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<string> >(), "input file");
+// po::options_description hidden("Hidden options");
+// hidden.add_options()
+ ("input-file", po::value< vector<string> >(), "input file")
("output-file", po::value< vector<string> >(), "ouput file");
po::positional_options_description p;
- p.add("input-file", -1);
- p.add("output-file", -1);
+ 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<string> >().begin()->c_str();
+ if (vm.count("output-file"))
outfilename = vm["output-file"].as< vector<string> >().begin()->c_str();
- }
- if (!filename || !outfilename || !sysinfo_dump) {
+ if ((!filename || !outfilename) && !sysinfo_dump) {
cerr << "Usage: " << argv[0] << " <file.scad> <output.png>\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:
+<pre>
+SYSINFO
+</pre>
+
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<p>\n')
+ data = re.sub('\{\|.*?\n','<table border=1>\n',data)
+ data = re.sub('\n\! ','\n<tr>\n<td>',data)
+ data = data.replace(' !! ','<td>')
+ data = data.replace('|-','<tr>')
+ data = re.sub('\n\| ','\n<td>',data)
+ data = data.replace(' || ','<td>')
+ data = data.replace('|}','\n</table>')
+ data = re.sub('[[File:(.*?)|.*?]]','<img src="(\1)">',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 <iostream>
+#include <sstream>
+#include <string>
#include "system-gl.h"
#include <boost/algorithm/string.hpp>
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 <GL/glew.h>
+#include <string>
-void glew_dump();
+std::string glew_dump(bool dumpall);
bool report_glerror(const char *task);
#endif
contact: Jan Huwald // Impressum