buildsystem: aligned/automated building of tests, now build the core as static lib

This commit is contained in:
Fischlurch 2007-08-18 04:28:14 +02:00
parent 06efcf0f77
commit 963ce7ec53
16 changed files with 138 additions and 54 deletions

View file

@ -60,7 +60,7 @@ def setupBasicEnvironment():
env.Replace( VERSION=VERSION
, SRCDIR=SRCDIR
, BINDIR=BINDIR
, CPPPATH="#"+SRCDIR # used to find includes, "#" means always absolute to build-root
, 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'
)
@ -224,15 +224,15 @@ def defineBuildTargets(env, artifacts):
+ srcSubtree(env,'$SRCDIR/common')
+ srcSubtree(env,'$SRCDIR/lib')
)
applobj = cinobj + env.Object('$SRCDIR/main.cpp')
plugobj = srcSubtree(env,'$SRCDIR/plugin', isShared=True)
corelib = env.StaticLibrary('$BINDIR/core.la', cinobj)
artifacts['cinelerra'] = env.Program('$BINDIR/cinelerra', applobj)
artifacts['cinelerra'] = env.Program('$BINDIR/cinelerra', ['$SRCDIR/main.cpp']+ corelib )
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')
SConscript(dirs=[TESTDIR], exports='env artifacts corelib')
def defineInstallTargets(env, artifacts):

View file

@ -1,5 +1,5 @@
TESTING "Error handling" ./errortest
TESTING "Error handling" ./test-error
TEST "no error" <<END
return: 0

5
tests/15plugin.tests Normal file
View file

@ -0,0 +1,5 @@
TESTING "test plugin example code" ./test-plugin
TEST "plugin example" <<END
END

View file

@ -1,5 +1,5 @@
TESTING "Component Test Suite" ./mainsuite
TESTING "Component Test Suite" ./test-components
TEST "Fac test" Factory_test <<END
return: 0

View file

@ -1,5 +0,0 @@
TESTING "test plugin example code" ./plugin_example
TEST "plugin example" <<END
END

View file

@ -18,10 +18,10 @@
tests_srcdir = $(top_srcdir)/tests
check_PROGRAMS += errortest
check_PROGRAMS += test-error
errortest_SOURCES = $(tests_srcdir)/errortest.c
errortest_CPPFLAGS = $(AM_CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/lib/
errortest_SOURCES = $(tests_srcdir)/error/errortest.c
errortest_CPPFLAGS = $(AM_CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/
errortest_LDADD = $(builddir)/libcin3.a -lnobugmt -lpthread -ldl
TESTS = $(tests_srcdir)/test.sh

View file

@ -3,37 +3,54 @@
## SConscript - SCons buildscript for the Testsuite (called by SConstruct)
##
import os
from Buildhelper import *
from Buildhelper import srcSubtree
from Buildhelper import globRootdirs
Import('env','artifacts','cinobj')
Import('env','artifacts','corelib')
# build objects for the testcases...
def SingleTestExecutableSubdir(env,tree):
""" declare all targets needed to create a standalone
Test executalbe of the given Sub-tree. Note that
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
exeName = 'test-%s' % tree
objects = srcSubtree(env,tree)
return env.Program(exeName, objects + corelib)
def treatPluginTestcase(env):
""" Special case: the test-plugin executable
"""
env = env.Clone()
env.Append(CPPPATH='plugin')
testplugin = env.SharedLibrary('hello_1', 'plugin/example_plugin.c', SHLIBPREFIX='')
testExe = env.Program('test-plugin', ['plugin/plugin_main.c'] + corelib)
env.Depends(testExe, testplugin)
return testExe
#-- it depentds (at the moment) on a specific isolated test-plugin,
# which is not integrated in the "normal procedure" for building Plugins
# (which is not yet implemented as of 8/07)
# TODO: handle this case automatically
#
# build a Test-Executable out of every subdir...
moduledirs = globRootdirs('*')
#
env = env.Clone()
env.Append(CPPPATH = ['components','examples'])
# have to treat the plugin-example specially.
isnt_plugin = lambda dir : dir!='plugin'
moduledirs = filter(isnt_plugin, moduledirs)
pluginExe = treatPluginTestcase(env)
print 'moduledirs: %s' %moduledirs
testobj = srcSubtree(env,'components/*', isShared=False)
artifacts['testsuite'] = ts = [ SingleTestExecutableSubdir(env, dir) for dir in moduledirs] + pluginExe
example = env.StaticLibrary('examples/cin3example', ['#$SRCDIR/lib/error.o','#$SRCDIR/lib/plugin.o'])
plugin = env.StaticLibrary('example_plugin.la', ['examples/example_plugin.c'])
# build test applications
#
envp = env.Clone() # special Environment including libs for the plugin-test
envp.Append(LIBS = [example,plugin])
artifacts['testsuite'] = ts = ( env.Program('mainsuite', cinobj + testobj + ['components/mainsuite.cpp'])
+ envp.Program('errortest', example + ['examples/errortest.c'] )
+ envp.Program('plugin-example', example + plugin + ['examples/plugin_main.c'])
)
# TODO: we could apply much more "magic" here
# - organize the source of testcases more systematically
# - build /every/ $TESTDIR/*.cpp into an application
# - link the testobj dynamically
# - install additionally scripts into tests-dir if desired
@ -46,6 +63,8 @@ artifacts['testsuite'] = ts = ( env.Program('mainsuite', cinobj + testobj + ['co
#
runTs = env.Command(',testlog', ts, "./test.sh", chdir=1)
env.Clean (runTs, [ ',*']) # declare tempfiles of test.sh as cleanable
#
# define Phony targets

28
tests/bugs/bugmain.c Normal file
View file

@ -0,0 +1,28 @@
/*
errortest.c - executable for running bug regression tests
Copyright (C) CinelerraCV
2007, Christian Thaeter <ct@pipapo.org>
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
int main(int argc, char* argv[])
{
printf("hello sunshine, noBugs whatsoever\n");
return 0;
}

3
tests/error/DIR_INFO Normal file
View file

@ -0,0 +1,3 @@
example (test) code for errorhandling
The test application to be built from this directory shows how
to use the various error handling features.

View file

@ -1,3 +1,3 @@
working example code
working example code for cinelerra's plugin system
This directory contains example code which shows how to use specific features.
All examples will be build and run as part of the testsuite

View file

@ -15,11 +15,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
examples_srcdir = $(top_srcdir)/tests/examples
noinst_PROGRAMS += plugin_example
examples_srcdir = $(top_srcdir)/tests/plugin
noinst_PROGRAMS += test-plugin
plugin_example_CFLAGS = $(CFLAGS) -std=gnu99 -Wall -Werror
plugin_example_CPPFLAGS = $(CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/lib/
plugin_example_CPPFLAGS = $(CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/
plugin_example_LDADD = $(builddir)/libcin3.a -lnobugmt -lpthread -ldl
plugin_example_SOURCES = $(examples_srcdir)/plugin_main.c

View file

@ -7,6 +7,8 @@
int
main(int argc, char** argv)
{
NOBUG_INIT;
/*
we have a plugin 'hello_1' which provides us 2 hello interfaces, one for english and one for german output,
open both try them, close them.

View file

@ -2333,6 +2333,28 @@ I made this proposal 'final' now further details are likely better worked out in
-- [&quot;ct&quot;] [[DateTime(2007-06-27T16:01:52Z)]]
</pre>
</div>
<div title="SCons" modifier="Ichthyostega" modified="200708180224" created="200708180211" tags="organization buildsys" changecount="3">
<pre>[SCons|http://www.scons.org/] is an //alternate build system// written in Python and using specific python-scripts for defining the buildprocess. These build scripts, called {{{SConstruct}}} and {{{SConsscript}}} are indeed //definitions//, not scripts for //doing// the build. If you are new to SCons (and familiar with make), you should really read the [Introduction of the users guide|http://www.scons.org/doc/0.97/HTML/scons-user/book1.html], because SCons is quite a different beast then make and the autotools.
To learn how to use SCons and to get a better feeling of its strenghtes and weaknesses, Ichthyo started a SCons based build system for cinelerra in July 2007 and will maintain it for some time parallel to the automake system (maintained by Cehteh). Every build system looks good in theory and has some big advantages, but only in real use one can see how much effort is needed to keep up with the demands of a given project.
!some Notes
* we build always in the top level directory
* at the moment, we use no separate build directory, rather we place the object files alongside with the sources
* but we place the created executables and shared libraries into one $BINDIR (configurable in the top level {{{SConstruct}}})
* note: for SCons, each file (which is buildable) and each directory (containing buildable files) is on itself a Target.
* additionally, we provide some //aliasses//
** build == $BINDIR
** install places some of the created artifacts into $DESTDIR
** testcode is an alias for all the executables comprising the testsuite
** check == directory {{{tests}}} and runs the testsuite
* run scons -h to get additional explanations.
Typically, one would just write the necessary definitions as they come into one global scope. But because the buildscripts are actually Python scripts, ichthyo found it preferable to use some more structuring and break down the code into several python functions and pass all necessary variables as parameters. This may seem overkill at first look, but the cinelerra project is expected to become a large project.
Moreover, one could simply list all needed files or break everything down into a hierarchical build. But instead, we use for most objects a helper function (located in {{{admin/scons/Buildhelper.py}}}) called {{{srcSubtree()}}}, which will scan a directory tree and add all {{{'*.c','*.cpp','*.cc'}}} - files as Object nodes to the build process. Besides that, we use the //hierarchical aproach rather reluctant//: at the moment, only the subtree for separate tools and the tests-directory have a separate buildscript. Probably, the subtree for plugins will get one as well at some point in the future.
</pre>
</div>
<div title="ShortCuts" modifier="MichaelPloujnikov" modified="200706270305" created="200706260438" tags="portal" changecount="7">
<pre>~~This small Tiddler contains usefull Shortcuts, Info, Links~~
@ -3472,7 +3494,7 @@ Portions written by Luke Blanshard are hereby released into the public domain.
&lt;!--}}}--&gt;
</pre>
</div>
<div title="TestSh" modifier="Ichthyostega" modified="200708170336" created="200708131509" tags="buildsys organization testsuite" changecount="7">
<div title="TestSh" modifier="Ichthyostega" modified="200708180215" created="200708131509" tags="buildsys organization testsuite" changecount="9">
<pre>! The Test Script
To drive the various tests, we use the script {{{tests/test.sh}}}. All tests are run under valgrind control if available unless {{{VALGRINDFLAGS=DISABLE}}} is defined.
* The SCons buildsystem will build and run the testcode when executing the target {{{scons tests}}}.
@ -3495,7 +3517,7 @@ make check
}}}
! Writing Tests
Tests are written in files named {{{NNname.tests}}} in the {{{tests}}} dir, where NN is a number defining the order of the various test files, 'name' should be a descriptive name about whats going to be tested.
~Test-Definitons are written in files named {{{NNname.tests}}} in the {{{tests}}} dir, where NN is a number defining the order of the various test files, 'name' should be a descriptive name about whats going to be tested.
In a .tests file one has to define following:
* {{{TESTING &lt;description&gt; &lt;binary&gt;}}} set the program binary to be tested to &lt;binary&gt;, &lt;description&gt; should be a string which is displayed as header before running following tests
@ -3509,18 +3531,28 @@ If no {{{out:}}} or {{{err:}}} is given, stdout and stderr are not considered as
</pre>
</div>
<div title="TestSuite" modifier="Ichthyostega" modified="200708170345" created="200708120254" tags="buildsys organization testsuite" changecount="8">
<div title="TestSuite" modifier="Ichthyostega" modified="200708180218" created="200708120254" tags="buildsys organization testsuite" changecount="11">
<pre>For running the automatic Tests, we use Cehteh's simple [[test.sh|TestSh]].
This page is a proposal (by Ichthyo) how the various tests could be organized.
* individual Testcases are classes, doing whatsoever and however they see fit.
* it is up to the individual test classes to take care / handle / isolate themself form any dependencies (similar to the [[philosophy of TestNG|http://www.beust.com/weblog/archives/000082.html]])
* Testcases are grouped together into thematic (Sub)-Testsuites. Each Testcase has an unique ID and can be tagged with several groupIDs
* for each Testsuite (=distinct collection of tests) we build an executable linked against the test class objects.
* moreover, for simple Tests, we can build separate stelf-contained executables or even use other scripts.
* when we get several Testsuites at some point in the future, we may consider building a shared lib of the test objects.
* the Testsuite executable should provide some command line magic to select individual tests.
* Top-level Testsuites or ~Test-Collections for [[test.sh|TestSh]] contain calls to the different (sub)-Suites, together with the expected results/output
* individual ''Testcases'' are classes, doing whatsoever and however they see fit.
* it is up to the individual test classes to take care / handle / isolate themself form any ''dependencies'' (similar to the [[philosophy of TestNG|http://www.beust.com/weblog/archives/000082.html]])
* Testcases are ''grouped'' together into thematic (Sub)-Testsuites. Each Testcase has an unique ID and can be tagged with several groupIDs
* for running a ''Testsuite'' (=distinct collection of tests) we build an executable linked against the test class objects.
* moreover, for ''simple Tests'', we can build separate stelf-contained executables or even use other scripts.
* the Testsuite executable provides some command line magic to select individual tests.
* Top-level Testsuites or ''~Test-Collections'' for [[test.sh|TestSh]] contain calls to the different (sub)-Suites, together with the expected results/output
!conventions for the Buildsystem
to help with automating the build, ichthyo would appreciate to have the following conventions.
* in the {{{tests}}} directory are
** the testdefinitions together with {{{test.sh}}}
** the test-executables, which should named according to the pattern {{{test-XXX}}}
* below are the source directories for each of the aforementioned test-executables. When such a source directory is named &quot;XXX&quot;, the corresponding executable is &quot;test-XXX&quot;
* each of the source directories, which actually could be source trees, will be compiled and linked together with the cinelerra core classes and files. Thus, it needs to contain exactly //one// main(), but by using commandline parameters, one executable can drive a lot of different tests.
-------
//as of 18.8.2007, ichthyo has implemented this scheme for the SCons build//
</pre>
</div>
<div title="TextAreaPlugin" modifier="Jeremy" created="200601261745" tags="systemConfig" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200601261745">