2007-08-13 09:55:32 +02:00
|
|
|
# -*- python -*-
|
|
|
|
|
##
|
|
|
|
|
## SConscript - SCons buildscript for the Testsuite (called by SConstruct)
|
|
|
|
|
##
|
|
|
|
|
|
2008-10-23 04:53:50 +02:00
|
|
|
import os
|
2007-09-20 03:46:14 +02:00
|
|
|
from os import path
|
2007-08-18 04:28:14 +02:00
|
|
|
from Buildhelper import srcSubtree
|
2008-09-07 23:43:06 +02:00
|
|
|
from Buildhelper import scanSubtree
|
2007-08-18 04:28:14 +02:00
|
|
|
from Buildhelper import globRootdirs
|
2009-01-12 12:48:14 +01:00
|
|
|
from Buildhelper import createPlugins
|
2007-08-13 09:55:32 +02:00
|
|
|
|
2009-01-12 12:48:14 +01:00
|
|
|
Import('env','envPlu','artifacts','core')
|
2007-08-13 09:55:32 +02:00
|
|
|
|
2008-05-20 13:04:22 +02:00
|
|
|
# temp fix to add test.h -- wouldn't it be better to put this header be into src/lib ?
|
|
|
|
|
env = env.Clone()
|
|
|
|
|
env.Append(CPPPATH='#/.') # add Rootdir to Includepath, so test/test.h is found
|
2009-01-12 12:48:14 +01:00
|
|
|
envPlu = envPlu.Clone()
|
|
|
|
|
envPlu.Append(CPPPATH='#/.')
|
2008-05-20 13:04:22 +02:00
|
|
|
# temp fix-------------
|
2007-08-17 11:06:49 +02:00
|
|
|
|
2007-09-20 03:46:14 +02:00
|
|
|
def testExecutable(env,tree, exeName=None, obj=None):
|
2007-08-18 04:28:14 +02:00
|
|
|
""" declare all targets needed to create a standalone
|
2008-12-08 05:20:14 +01:00
|
|
|
Test executable of the given Sub-tree. Note that
|
2007-08-18 04:28:14 +02:00
|
|
|
each subdir is built in its own Environment.
|
|
|
|
|
"""
|
|
|
|
|
env = env.Clone()
|
|
|
|
|
env.Append(CPPPATH=tree) # add Subdir to Includepath
|
|
|
|
|
tree = env.subst(tree) # expand Construction Vars
|
2007-09-20 03:46:14 +02:00
|
|
|
if obj:
|
|
|
|
|
obj = [path.join(tree,name) for name in obj]
|
|
|
|
|
else:
|
2008-12-12 02:04:50 +01:00
|
|
|
obj = srcSubtree(env,tree, isShared=False) # use all sourcefiles found in subtree
|
2007-09-20 03:46:14 +02:00
|
|
|
if not exeName:
|
|
|
|
|
exeName = 'test-%s' % tree
|
2008-01-27 02:39:13 +01:00
|
|
|
return env.Program('#$BINDIR/'+exeName, obj + core)
|
2007-08-18 04:28:14 +02:00
|
|
|
|
2007-08-17 11:06:49 +02:00
|
|
|
|
2008-09-07 23:43:06 +02:00
|
|
|
def testCollection(env,dir):
|
|
|
|
|
""" treat a Directory containing a collection of standalone tests.
|
|
|
|
|
Link each of them into an independent executable
|
|
|
|
|
"""
|
2008-10-16 02:07:32 +02:00
|
|
|
srcpatt = ['test-*.c']
|
2008-09-07 23:43:06 +02:00
|
|
|
exeName = lambda p: path.basename(path.splitext(p)[0])
|
|
|
|
|
buildIt = lambda p: env.Program("#$BINDIR/"+exeName(p), [p] + core)
|
2008-10-16 02:07:32 +02:00
|
|
|
return [buildIt(f) for f in scanSubtree(dir,srcpatt)]
|
2008-09-07 23:43:06 +02:00
|
|
|
|
|
|
|
|
|
2009-01-12 12:48:14 +01:00
|
|
|
|
|
|
|
|
|
2007-08-17 11:06:49 +02:00
|
|
|
|
2007-09-20 03:46:14 +02:00
|
|
|
# but have to treat some subdirs individually.
|
2008-12-26 22:26:41 +01:00
|
|
|
specials = ['plugin','lib','components']
|
2009-01-12 12:48:14 +01:00
|
|
|
moduledirs = globRootdirs('*')
|
2007-09-20 03:46:14 +02:00
|
|
|
|
|
|
|
|
|
2007-08-18 04:28:14 +02:00
|
|
|
|
2008-12-26 22:26:41 +01:00
|
|
|
artifacts['testsuite'] = ts = ( [ testExecutable(env, dir) for dir in ['lib','components'] ]
|
|
|
|
|
+ [ testCollection(env, dir) for dir in moduledirs if not dir in specials]
|
2009-01-12 12:48:14 +01:00
|
|
|
+ createPlugins(envPlu, 'plugin')
|
2007-09-20 03:46:14 +02:00
|
|
|
)
|
2007-08-18 04:28:14 +02:00
|
|
|
|
2007-08-17 11:06:49 +02:00
|
|
|
|
2007-08-13 09:55:32 +02:00
|
|
|
|
|
|
|
|
|
2009-01-17 14:27:35 +01:00
|
|
|
# for creating a Valgrind-Suppression file
|
|
|
|
|
vgsuppr = env.Program('#$BINDIR/vgsuppression','tool/vgsuppression.c', LIBS=core) ## for suppressing false valgrind alarms
|
|
|
|
|
artifacts['tools'] += [vgsuppr]
|
|
|
|
|
Depends(ts,vgsuppr)
|
2007-08-17 11:06:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# actually run the Testsuite
|
|
|
|
|
#
|
|
|
|
|
# - the product of running the Testsuite is the ",testlog"
|
|
|
|
|
# - it depends on all artifacts defined as "ts" above
|
2008-10-23 04:53:50 +02:00
|
|
|
# - if not set via options switch, the environment variable TESTSUITES
|
|
|
|
|
# is explicitly propagated to test.sh
|
2007-08-17 11:06:49 +02:00
|
|
|
#
|
2007-08-31 20:32:26 +02:00
|
|
|
testEnv = env.Clone()
|
2008-12-26 23:31:00 +01:00
|
|
|
|
|
|
|
|
valgrind = os.environ.get('VALGRINDFLAGS', '') # unset if not defined
|
|
|
|
|
if not valgrind and not env['VALGRIND']:
|
|
|
|
|
valgrind = 'DISABLE'
|
|
|
|
|
|
|
|
|
|
testEnv.Append(ENV = { 'VALGRINDFLAGS' : valgrind
|
|
|
|
|
, 'LUMIERA_CONFIG_PATH' : './'
|
|
|
|
|
})
|
2008-12-18 09:59:31 +01:00
|
|
|
|
2008-10-23 04:53:50 +02:00
|
|
|
testsuites = env['TESTSUITES'] or os.environ.get('TESTSUITES')
|
|
|
|
|
if testsuites:
|
|
|
|
|
testEnv['ENV']['TESTSUITES'] = testsuites
|
2008-12-18 09:59:31 +01:00
|
|
|
|
|
|
|
|
pluginpath = os.environ.get('LUMIERA_PLUGIN_PATH')
|
|
|
|
|
if testsuites:
|
|
|
|
|
testEnv['ENV']['LUMIERA_PLUGIN_PATH'] = pluginpath
|
2010-02-15 03:25:01 +01:00
|
|
|
|
|
|
|
|
# specify path to test.conf
|
|
|
|
|
testEnv['ENV']['TEST_CONF'] = env.File("test.conf").abspath
|
|
|
|
|
|
2008-10-23 04:53:50 +02:00
|
|
|
|
2007-09-02 23:57:40 +02:00
|
|
|
testDir = env.Dir('#$BINDIR')
|
|
|
|
|
runTest = env.File("test.sh").abspath
|
2007-08-31 20:32:26 +02:00
|
|
|
|
2007-09-02 23:57:40 +02:00
|
|
|
runTs = testEnv.Command(',testlog', ts, runTest, chdir=testDir)
|
2007-08-18 06:13:39 +02:00
|
|
|
|
2007-08-18 04:28:14 +02:00
|
|
|
|
2007-08-17 11:06:49 +02:00
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# define Phony targets
|
|
|
|
|
# - 'scons testcode' triggers building of the Testsuite
|
|
|
|
|
# - 'scons check' triggers building and running
|
|
|
|
|
#
|
|
|
|
|
env.Alias('testcode', ts )
|
|
|
|
|
env.Alias('check', runTs )
|
|
|
|
|
|
2008-10-23 04:53:50 +02:00
|
|
|
# allow tempfiles of test.sh to be cleaned
|
2007-08-18 06:13:39 +02:00
|
|
|
env.Clean ('check', [',testlog.pre',',expect_stdout',',stdout',',stderr',',testtmp','.libs'])
|