diff options
| -rwxr-xr-x | scripts/uni-build-dependencies.sh | 27 | ||||
| -rwxr-xr-x | scripts/uni-get-dependencies.sh | 13 | ||||
| -rw-r--r-- | tests/CMakeLists.txt | 3 | ||||
| -rwxr-xr-x | tests/test_pretty_print.py | 52 | ||||
| -rwxr-xr-x | tests/test_upload.py | 253 | 
5 files changed, 308 insertions, 40 deletions
| diff --git a/scripts/uni-build-dependencies.sh b/scripts/uni-build-dependencies.sh index 8a7dda1..b5937ed 100755 --- a/scripts/uni-build-dependencies.sh +++ b/scripts/uni-build-dependencies.sh @@ -306,7 +306,14 @@ build_cgal()  build_glew()  { -  if [ -e $DEPLOYDIR/include/GL/glew.h ]; then +  GLEW_INSTALLED= +  if [ -e $DEPLOYDIR/lib64/libGLEW.so ]; then +    GLEW_INSTALLED=1 +  fi +  if [ -e $DEPLOYDIR/lib/libGLEW.so ]; then +    GLEW_INSTALLED=1 +  fi +  if [ $GLEW_INSTALLED ]; then      echo "glew already installed. not building"      return    fi @@ -499,29 +506,29 @@ if [ "`cmake --version | grep 'version 2.[1-6][^0-9]'`" ]; then    build_cmake 2.8.8  fi -build_git 1.7.10.3 -exit 1 -# Singly build CGAL or OpenCSG -# (Most systems have all libraries available as packages except CGAL/OpenCSG) -# (They can be built singly here by passing a command line arg to the script) +# Singly build certain tools or libraries  if [ $1 ]; then +  if [ $1 == "git" ]; then +    build_git 1.7.10.3 +    exit $? +  fi    if [ $1 = "cgal" ]; then      build_cgal 4.0.2 use-sys-libs -    exit +    exit $?    fi    if [ $1 = "opencsg" ]; then      build_opencsg 1.3.2 -    exit +    exit $?    fi    if [ $1 == "qt4" ]; then      # such a huge build, put here by itself      build_qt4 4.8.4 -    exit +    exit $?    fi    if [ $1 == "glu" ]; then      # Mesa and GLU split in late 2012, so it's not on some systems      build_glu 9.0.0 -    exit +    exit $?    fi  fi diff --git a/scripts/uni-get-dependencies.sh b/scripts/uni-get-dependencies.sh index cf9f136..882cb17 100755 --- a/scripts/uni-get-dependencies.sh +++ b/scripts/uni-get-dependencies.sh @@ -6,8 +6,13 @@  get_fedora_deps()  { - sudo yum install qt-devel bison flex eigen2-devel \ -  boost-devel mpfr-devel gmp-devel glew-devel CGAL-devel gcc pkgconfig git + sudo yum install qt-devel bison flex eigen2-devel python-paramiko \ +  boost-devel mpfr-devel gmp-devel glew-devel CGAL-devel gcc pkgconfig git libXmu-devel +} + +get_qomo_deps() +{ + get_fedora_deps  }  get_altlinux_deps() @@ -75,10 +80,14 @@ if [ -e /etc/issue ]; then    get_fedora_deps   elif [ "`grep -i mageia /etc/issue`" ]; then    get_mageia_deps + elif [ "`grep -i qomo /etc/issue`" ]; then +  get_qomo_deps   elif [ "`command -v rpm`" ]; then    if [ "`rpm -qa | grep altlinux`" ]; then     get_altlinux_deps    fi + else +  unknown   fi  elif [ "`uname | grep -i freebsd `" ]; then   get_freebsd_deps diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1352658..2ada23c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -31,7 +31,8 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")  # Build debug build as default  if(NOT CMAKE_BUILD_TYPE) -  set(CMAKE_BUILD_TYPE RelWithDebInfo) +#  set(CMAKE_BUILD_TYPE RelWithDebInfo) +  set(CMAKE_BUILD_TYPE Release)  endif()  if(CMAKE_COMPILER_IS_GNUCXX) diff --git a/tests/test_pretty_print.py b/tests/test_pretty_print.py index ed86b65..a85d000 100755 --- a/tests/test_pretty_print.py +++ b/tests/test_pretty_print.py @@ -9,26 +9,23 @@  # files from builddir/Testing/Temporary.   # html & wiki output are produced in Testing/Temporary/sysid_report  # -# experimental wiki uploading is available by running  -#  -#  python test_pretty_print.py --upload -# + +# Note: Wiki code is deprecated. All future development should move to  +# create html output (or even xml output). Wiki design was based on the  +# wrong assumption of easily accessible public wiki servers with  +# auto-upload scripts available.  # 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 +# 4. save html +# 5. upload html to public site +#   # todo -# deal better with the situation where Offscreen rendering fails -# 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)  # why is hash differing -# 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,time,platform @@ -441,6 +438,20 @@ def findlogfile(builddir):  	return logpath, logfilename  def main(): +	#wikisite = 'cakebaby.referata.com' +	#wiki_api_path = '' +	wikisite = 'cakebaby.wikia.com' +	wiki_api_path = '/' +	wiki_rootpath = 'OpenSCAD' +	builddir = os.getcwd() # os.getcwd()+'/build' +	verbose = False +	maxretry = 10 + +	if bool(os.getenv("TEST_GENERATE")): sys.exit(0) + +	include_passed = False +	if '--include-passed' in sys.argv: include_passed = True +  	dry = False  	if verbose: print 'running test_pretty_print'  	if '--dryrun' in sys.argv: dry=True @@ -472,25 +483,12 @@ def main():  	htmldata = tohtml(wiki_rootpath, startdate, tests, enddate, sysinfo, sysid, makefiles)  	trysave( os.path.join(wikidir,'index.html'), htmldata ) -	if '--upload' in sys.argv: +	if '--wiki-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' -#wiki_api_path = '' -wikisite = 'cakebaby.wikia.com' -wiki_api_path = '/' -wiki_rootpath = 'OpenSCAD' -builddir = os.getcwd() # os.getcwd()+'/build' -verbose = False -maxretry = 10 - -if bool(os.getenv("TEST_GENERATE")): sys.exit(0) - -include_passed = False -if '--include-passed' in sys.argv: include_passed = True - -main() +if __name__=='__main__': +	main() diff --git a/tests/test_upload.py b/tests/test_upload.py new file mode 100755 index 0000000..5d7cd3e --- /dev/null +++ b/tests/test_upload.py @@ -0,0 +1,253 @@ +#!/usr/bin/python + +# Copyright 2013 Don Bright <hugh.m.bright@gmail.com> +# released under Zlib-style license: +# +# This software is provided 'as-is', without any express or implied +# warranty.  In no event will the authors be held liable for any damages +# arising from the use of this software. +# +# Permission is granted to anyone to use this software for any purpose,  +# including commercial applications, and to alter it and redistribute it  +# freely, subject to the following restrictions: +# +#  1. The origin of this software must not be misrepresented; you must  +# not claim that you wrote the original software. If you use this  +# software in a product, an acknowledgment in the product documentation  +# would be appreciated but is not required. +#  2. Altered source versions must be plainly marked as such, and must  +# not be misrepresented as being the original software. 3. This notice  +# may not be removed or altered from any source distribution. +# +# This license is based on zlib license by Jean-loup Gailly and Mark Adler + + +#  +# this program takes html output by test_pretty_print.py and uploads +# it to a web server.  +# + +# +# design +# +# On the remote web server there is a directory called 'openscad_tests' +# Inside of it is a file, 'index.html', that lists all the test reports +# stored in that directory.  +#  +# Each test report is a single .html file, with all of the .png images +# encoded directly into the file using the Data URI and base64 encoding. +# The name of the report file is something like OS_cpu_GLinfo_hash, like +# linux_x86_radeon_abcd. This is read using test_pretty_print.py +# +# This script uploads the last report created by test_pretty_print.py  +# Then it modifies the remote index.html file (if necessary) to display  +# a link to the new test report. +# +# Requirements for remote web server and local system: +#  +# 1. Local system must have sftp access to remote server +# This can be tested by runnig this: sftp user@remotehost +#  +# 2. Remote web server only needs static html. There is no requirement +# for php/cgi/etc.  +#  +# 3. Local system must have the python Paramiko library installed,  +# which in turn requires pycript to also be installed. (to PYTHONPATH) +# +# This script returns '1' on failure, '0' on success (shell-style) +# + +import sys,os,platform,string + +try: +	import paramiko +except: +	x='''  +please install the paramiko python library in your  +PYTHONPATH If that is not feasible, you can upload the main html report  +file by hand to any site that accepts html code.  +''' + +from test_pretty_print import ezsearch, read_sysinfo +from test_cmdline_tool import execute_and_redirect + +debug_test_upload = False +dryrun = False + +def help(): +	text=''' +test_upload.py + +usage: + +  test_upload.py --username=uname --host=host --remotepath=/some/path \ +	[--dryrun] [--debug] + +example: +   +  test_upload.py andreis web.sourceforge.net /home/project-web/openscad/htdocs/ +''' +	print text + + +def debug(x): +	if debug_test_upload: +		print 'test_upload.py:', x +	sys.stdout.flush() + + +blankchunk='''<!-- __entry__ -->''' + +index_template=''' +<html> +<head> +OpenSCAD regression test results +</head> +<body> + <h3> +  OpenSCAD regression test results + </h3> + <ul>  +''' + blankchunk + ''' + </ul> +</body> +</html> +''' + +entry_template=''' +  <li><a href="__href__">__rept_name__</a></li> +''' + + +def paramiko_upload( newrept_fname, username, host, remotepath ): +        debug("running paramiko upload") + +        basepath = 'openscad_tests' +	basefilename = os.path.basename( newrept_fname ) +        newrept_name = string.split(basefilename,'.html')[0] +	debug("input filename: "+ newrept_fname ) +	debug("new report name: "+ newrept_name ) + +        debug("connect to " + username + "@" + host) +        client = paramiko.SSHClient() +        client.set_missing_host_key_policy(paramiko.AutoAddPolicy) +        client.load_system_host_keys() +	if dryrun: +		debug("dryrun: no client.connect()") +		return 0 +        try: +                client.connect(host,username=username) +        except paramiko.PasswordRequiredException, e: +                passw = getpass.getpass('enter passphrase for private key: ') +                client.connect(host,username=username,password=passw) + +        #stdin,stdout,stderr=client.exec_command('ls -l') + +        debug("find " + basepath + "/index.html (or create blank) ") +        ftp = client.open_sftp() +        if not basepath in ftp.listdir(): +                ftp.mkdir( basepath ) +        ftp.chdir( basepath ) + +        if not 'index.html' in ftp.listdir(): +                f = ftp.file( 'index.html', 'w+') +                f.write(index_template) +                f.close() + +        debug("upload new report") +        # pass + +        debug("add new reprt link to index.html") +        f = ftp.file( 'index.html', 'r' ) +        text = f.read() +        f.close() + +        text2 = entry_template +        text2 = text2.replace( '__href__', newrept_fname ) +        text2 = text2.replace( '__rept_name__', newrept_name ) + +        if newrept_fname in text: +                debug( newrept_fname + " already linked from index.html") +        else: +                text = text.replace( blankchunk, blankchunk+'\n'+text2 ) + +        f = ftp.file( 'index.html', 'w+' ) +        f.write(text) +        f.close() + +        debug("close connections") +        ftp.close() +        client.close() + + +def upload_unix( reptfile, username, host, remotepath): +	debug("detected unix-like system.") +	paramiko_upload( reptfile, username, host, remotepath ) + +def upload_darwin( reptfile, username, host, remotepath ): +	debug("detected osx/darwin") +	upload_unix( reptfile, username, host, remotepath ) +	 +def upload_windows( reptfile, username, host, remotepath ): +	debug("detected windows") +	print 'sorry, not implemented on windows' +	return 1 +	# use pycript and paramiko +	# the problem is downloading them and installing them  + +def upload( reptfile, username, host, remotepath ): +	sysname = platform.system().lower() +	result = 1 +	if 'linux' in sysname or 'bsd' in sysname: +		result = upload_unix( reptfile, username, host, remotepath ) +	elif 'darwin' in sysname: +		result = upload_darwin( reptfile, username, host, remotepath ) +	elif 'windows' in platform.system(): +		result = upload_windows( reptfile, username, host, remotepath ) +	else: +		print "unknown system type. cant upload, sorry" +	return result + +def main(): +	if '--debug' in string.join(sys.argv):  +		global debug_test_upload +		debug_test_upload = True +	if '--dryrun' in string.join(sys.argv):  +		global dryrun +		dryrun = True + +	debug('running test_upload') +	debug('args: '+str(sys.argv[1:])) + +        builddir = ezsearch('--builddir=(.*?) ',string.join(sys.argv)+' ') +        if builddir=='': builddir=os.getcwd() +	sysinfo, sysid = read_sysinfo(os.path.join(builddir,'sysinfo.txt')) +	debug("sysinfo: " + sysinfo[0:60].replace('\n','') + ". . . ") +	debug("sysid: " + sysid ) +	if len(sysid)<6: +		print "unable to find valid system id" +		sys.exit(1) + +	sysidpath = sysid + '_report' + '.html' +	testdir = os.path.join(builddir, 'Testing', 'Temporary', sysidpath ) +	debug("testdir:\n" + testdir ) +		 +        username = ezsearch('--username=(.*?) ',string.join(sys.argv)+' ') +        host = ezsearch('--host=(.*?) ',string.join(sys.argv)+' ') +        remotepath = ezsearch('--remotepath=(.*?) ',string.join(sys.argv)+' ') + +	if testdir=='' or username=='' or host=='' or remotepath=='': +		help() +		sys.exit(1) + +	res = upload( testdir, username, host, remotepath )	 +	if res==1: +		print "upload failed" +		return 1 +	else: +		return 0 + + +if __name__ == '__main__': +	sys.exit(main()) + | 
