From 06efcf0f77b8bc69bf152c67b6164792952adb72 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 17 Aug 2007 11:06:49 +0200 Subject: [PATCH] merge together work done for the Testsuite. - to make it similar to Cehteh's tests, moved my testcode to tests/components - made scons build the errortest and plugin-example as well - scons check will run the suite please note, my implementation work is quite incomplete (warnings, app shuttdown not yet implemented); I hadn't success running the plugintest. --- SConstruct | 28 +++++++---- admin/scons/Buildhelper.py | 4 +- tests/.gitignore | 4 ++ tests/50components.tests | 12 +++++ tests/SConscript | 47 +++++++++++++++++-- {src/test => tests/components}/DIR_INFO | 0 .../components}/common/factorytest.cpp | 2 +- .../components}/common/helloworldtest.cpp | 4 +- {src/test => tests/components}/helper/run.hpp | 4 +- .../components}/helper/suite.cpp | 4 +- .../components}/helper/suite.hpp | 0 {src/test => tests/components}/mainsuite.cpp | 2 +- tests/{ => examples}/errortest.c | 4 +- tests/examples/hello_interface.h | 2 +- tests/examples/plugin_main.c | 2 +- 15 files changed, 94 insertions(+), 25 deletions(-) create mode 100644 tests/.gitignore create mode 100644 tests/50components.tests rename {src/test => tests/components}/DIR_INFO (100%) rename {src/test => tests/components}/common/factorytest.cpp (97%) rename {src/test => tests/components}/common/helloworldtest.cpp (93%) rename {src/test => tests/components}/helper/run.hpp (96%) rename {src/test => tests/components}/helper/suite.cpp (98%) rename {src/test => tests/components}/helper/suite.hpp (100%) rename {src/test => tests/components}/mainsuite.cpp (97%) rename tests/{ => examples}/errortest.c (98%) diff --git a/SConstruct b/SConstruct index 459ac9da4..59ab06d15 100644 --- a/SConstruct +++ b/SConstruct @@ -55,20 +55,23 @@ def setupBasicEnvironment(): opts = defineCmdlineOptions() env = Environment(options=opts) + + env.Append ( CCCOM=' -std=gnu99') # workaround for a bug: CCCOM currently doesn't honor CFLAGS, only CCFLAGS env.Replace( VERSION=VERSION , SRCDIR=SRCDIR , BINDIR=BINDIR , CPPPATH="#"+SRCDIR # used to find includes, "#" means always absolute to build-root , CPPDEFINES=['-DCINELERRA_VERSION=\\"%s\\"' % VERSION ] # note: make it a list to append further defines + , CCFLAGS='-Wall' ) handleNoBugSwitches(env) appendCppDefine(env,'DEBUG','DEBUG', 'NDEBUG') appendCppDefine(env,'OPENGL','USE_OPENGL') - appendVal(env,'ARCHFLAGS', 'CPPFLAGS') # for both C and C++ - appendVal(env,'OPTIMIZE', 'CPPFLAGS', val=' -O3') - appendVal(env,'DEBUG', 'CPPFLAGS', val=' -g') + appendVal(env,'ARCHFLAGS', 'CCFLAGS') # for both C and C++ + appendVal(env,'OPTIMIZE', 'CCFLAGS', val=' -O3') + appendVal(env,'DEBUG', 'CCFLAGS', val=' -g') prepareOptionsHelp(opts,env) opts.Save(OPTIONSCACHEFILE, env) @@ -132,6 +135,8 @@ USAGE: scons [-c] [OPTS] [key=val,...] [TARGETS] Special Targets: build : just compile and link + testcode: additionally compile the Testsuite + check : build and run the Testsuite install : install created artifacts at PREFIX src.tar : create source tarball doc.tar : create developer doc tarball @@ -157,6 +162,10 @@ def configurePlatform(env): print 'Did not find math.h / libm, exiting.' Exit(1) + if not conf.CheckLibWithHeader('dl', 'dlfcn.h', 'C'): + print 'Functions for runtime dynamic loading not available, exiting.' + Exit(1) + if not conf.CheckLibWithHeader('nobugmt', 'nobug.h', 'C'): print 'Did not find NoBug [http://www.pipapo.org/pipawiki/NoBug], exiting.' Exit(1) @@ -210,21 +219,20 @@ def defineBuildTargets(env, artifacts): setup sub-environments with special build options if necessary. We use a custom function to declare a whole tree of srcfiles. """ - cinobj = ( srcSubtree(env,'backend') - + srcSubtree(env,'proc') - + srcSubtree(env,'common') -# + srcSubtree(env,'lib') + cinobj = ( srcSubtree(env,'$SRCDIR/backend') + + srcSubtree(env,'$SRCDIR/proc') + + srcSubtree(env,'$SRCDIR/common') + + srcSubtree(env,'$SRCDIR/lib') ) applobj = cinobj + env.Object('$SRCDIR/main.cpp') - testobj = srcSubtree(env,'test/*', isShared=False) - plugobj = srcSubtree(env,'plugin', isShared=True) + plugobj = srcSubtree(env,'$SRCDIR/plugin', isShared=True) artifacts['cinelerra'] = env.Program('$BINDIR/cinelerra', applobj) artifacts['plugins'] = env.SharedLibrary('$BINDIR/cinelerra-plugin', plugobj) # call subdir SConscript(s) for independent components SConscript(dirs=[SRCDIR+'/tool'], exports='env artifacts') - SConscript(dirs=[TESTDIR], exports='env artifacts cinobj testobj') + SConscript(dirs=[TESTDIR], exports='env artifacts cinobj') def defineInstallTargets(env, artifacts): diff --git a/admin/scons/Buildhelper.py b/admin/scons/Buildhelper.py index 85da4784e..3f6a0e7d5 100644 --- a/admin/scons/Buildhelper.py +++ b/admin/scons/Buildhelper.py @@ -48,10 +48,10 @@ def isHelpRequest(): def srcSubtree(env,tree,isShared=False, **args): """ convienience wrapper: scans the given subtree, which is - to be located within $SRCDIR, find all source files and + relative to the current SConscript, find all source files and declare them as Static or SharedObjects for compilation """ - root = env.subst('$SRCDIR/%s' % tree) # expand $SRCDIR + root = env.subst(tree) # expand Construction Vars if isShared: builder = lambda f: env.SharedObject(f, **args) else: diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 000000000..cbfcd6fe3 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,4 @@ +,* +mainsuite +errortest +plugin-example diff --git a/tests/50components.tests b/tests/50components.tests new file mode 100644 index 000000000..ec2ae8f18 --- /dev/null +++ b/tests/50components.tests @@ -0,0 +1,12 @@ + +TESTING "Component Test Suite" ./mainsuite + +TEST "Fac test" Factory_test < -#include "test/helper/run.hpp" +#include "helper/run.hpp" namespace cinelerra @@ -40,7 +40,7 @@ namespace cinelerra void greeting() { - std::cout << "This is how the world ends...\n\n"; + std::cout << "This is how the world ends...\n"; } }; diff --git a/src/test/helper/run.hpp b/tests/components/helper/run.hpp similarity index 96% rename from src/test/helper/run.hpp rename to tests/components/helper/run.hpp index e34394af2..518ff37d2 100644 --- a/src/test/helper/run.hpp +++ b/tests/components/helper/run.hpp @@ -28,7 +28,7 @@ #include #include -#include "test/helper/suite.hpp" +#include "helper/suite.hpp" namespace test @@ -48,6 +48,7 @@ namespace test class Test { public: + virtual ~Test() {} virtual void run(Arg arg) = 0; }; @@ -57,6 +58,7 @@ namespace test class Launcher { public: + virtual ~Launcher() {} virtual auto_ptr operator() () = 0; }; diff --git a/src/test/helper/suite.cpp b/tests/components/helper/suite.cpp similarity index 98% rename from src/test/helper/suite.cpp rename to tests/components/helper/suite.cpp index 45a1adef6..6d8250cac 100644 --- a/src/test/helper/suite.cpp +++ b/tests/components/helper/suite.cpp @@ -28,8 +28,8 @@ #include #include -#include "test/helper/suite.hpp" -#include "test/helper/run.hpp" +#include "helper/suite.hpp" +#include "helper/run.hpp" #include "common/error.hpp" #include "common/util.hpp" diff --git a/src/test/helper/suite.hpp b/tests/components/helper/suite.hpp similarity index 100% rename from src/test/helper/suite.hpp rename to tests/components/helper/suite.hpp diff --git a/src/test/mainsuite.cpp b/tests/components/mainsuite.cpp similarity index 97% rename from src/test/mainsuite.cpp rename to tests/components/mainsuite.cpp index 729f55e6b..9ed0831fe 100644 --- a/src/test/mainsuite.cpp +++ b/tests/components/mainsuite.cpp @@ -21,7 +21,7 @@ */ -#include "test/helper/suite.hpp" +#include "helper/suite.hpp" /** run all tests or any single test specified in the first diff --git a/tests/errortest.c b/tests/examples/errortest.c similarity index 98% rename from tests/errortest.c rename to tests/examples/errortest.c index 9c1ae1f12..96d49b851 100644 --- a/tests/errortest.c +++ b/tests/examples/errortest.c @@ -19,10 +19,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include #include #include +#include "lib/error.h" + + CINELERRA_ERROR_DEFINE(TEST, "test error"); int diff --git a/tests/examples/hello_interface.h b/tests/examples/hello_interface.h index 183a22c54..ccec270ed 100644 --- a/tests/examples/hello_interface.h +++ b/tests/examples/hello_interface.h @@ -1,4 +1,4 @@ -#include "plugin.h" +#include "lib/plugin.h" CINELERRA_INTERFACE(hello, 1, CINELERRA_INTERFACE_PROTO(void, hello, (void)) diff --git a/tests/examples/plugin_main.c b/tests/examples/plugin_main.c index 427f88655..c2346b8da 100644 --- a/tests/examples/plugin_main.c +++ b/tests/examples/plugin_main.c @@ -1,6 +1,6 @@ -#include "plugin.h" +#include "lib/plugin.h" #include "hello_interface.h"