cleanup test includes

This commit is contained in:
Fischlurch 2011-12-02 21:34:29 +01:00
parent b9d1899486
commit b2d6074097
26 changed files with 123 additions and 67 deletions

View file

@ -248,7 +248,7 @@ lumiera_plugin_discover (LumieraPlugin (*callback_load)(const char* plugin),
LumieraPlugin
lumiera_plugin_load (const char* plugin)
{
TRACE (pluginloader_dbg);
TRACE (pluginloader_dbg, "plugin=%s", plugin);
/* dispatch on ext, call the registered function */
const char* ext = strrchr (plugin, '.');
@ -417,6 +417,7 @@ lumiera_plugin_delete_fn (PSplaynode node)
LUMIERA_INTERFACE_CAST(lumieraorg__plugin, 0) self->plugin;
lumiera_interfaceregistry_bulkremove_interfaces (handle->plugin_interfaces ());
}
TRACE (pluginloader_dbg, "unloading plugin/module %s", self->name);
itr->lumiera_plugin_unload_fn (self);
break;
}

View file

@ -34,7 +34,7 @@
LumieraPlugin
lumiera_plugin_load_DYNLIB (const char* name)
{
TRACE (pluginloader_dbg);
TRACE (pluginloader_dbg, "load DYNLIB: %s", name);
REQUIRE (name);
LumieraPlugin self = lumiera_plugin_new (name);
LumieraInterface plugin = NULL;

View file

@ -1,8 +1,8 @@
/*
test.h - macros for running tests
TEST.h - support macros for plain-C tests
Copyright (C)
2008, 2009, 2010, Christian Thaeter <ct@pipapo.org>
Copyright (C) Lumiera.org
2008, 2010 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
@ -17,10 +17,21 @@
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.
*/
#ifndef TEST_H
#define TEST_H
/** @file test.h
** Helpers and support macros for defining test executables in C.
** These macros provide some building blocks to assemble a \c main() function,
** which checks a test name parameter and invokes the matching embedded code block.
**
** @see test-mpool.c C test example
** @see HelloWorld_test C++ test example
*/
#ifndef LIB_TEST_TEST_H
#define LIB_TEST_TEST_H
#include <stdio.h>
#include <stdlib.h>
@ -51,10 +62,10 @@ main (int argc, const char** argv) \
fprintf (stderr, " "#name" (planned)\n"); \
else if (!++testcnt)
#define TESTS_END \
if (!testcnt && argc !=1) \
fprintf (stderr,"no such test: %s\n", argv[1]); \
return ret; \
#define TESTS_END \
if (!testcnt && argc !=1) \
fprintf (stderr,"no such test: %s\n", argv[1]); \
return ret; \
}

View file

@ -10,7 +10,8 @@ export LUMIERA_PLUGIN_PATH=modules
export LUMIERA_CONFIG_PATH=./
TEST "discovering plugins" plugin_discover <<END
out: found plugin: modules/examplepluginc.lum
out: found plugin: modules/test-c-plugin.lum
out: found plugin: modules/test-cpp-plugin.lum
return: 0
END
@ -20,7 +21,7 @@ out: plugin discovered after unload: \(nil\)
return: 0
END
TEST "C plugin test" plugin_examplepluginc <<END
TEST "C plugin test" plugin_exampleplugin <<END
out: Hallo Welt!
out: Tschuess Welt!
out: Hello World!
@ -28,7 +29,7 @@ out: Bye World!
return: 0
END
TEST "C plugin test, nested" plugin_examplepluginc_nested <<END
TEST "C plugin test, nested" plugin_exampleplugin_nested <<END
out: config path is: \./
out: plugin path is: modules
out: Hallo Welt!
@ -38,5 +39,15 @@ out: Tschuess Welt!
return: 0
END
TEST "C++ plugin test" plugin_exampleplugin_cpp <<END
out: opened 0x.+ global interfaces 0x...
out: Hallo Welt!
out: Tschüss schnöde Welt!
out: Hello World!
out: Bye Vale of Tears!
out: dying
return: 0
END
unset LUMIERA_PLUGIN_PATH
unset LUMIERA_CONFIG_PATH

View file

@ -13,11 +13,10 @@ from Buildhelper import globRootdirs
from Buildhelper import createPlugins
Import('env','artifacts','core')
# 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
# temp fix-------------
env.Append(CPPPATH='include') # additional headers for tests
def testExecutable(env,tree, exeName=None, obj=None):
""" declare all targets needed to create a standalone
@ -25,7 +24,7 @@ def testExecutable(env,tree, exeName=None, obj=None):
@note this tree uses separate Environment/Includepath
"""
env = env.Clone()
env.Append(CPPPATH=tree) # add Subdir to Includepath
env.Append(CPPPATH=tree) # add subdir to Includepath
tree = env.subst(tree) # expand Construction Vars
if obj:
obj = [path.join(tree,name) for name in obj]
@ -40,6 +39,8 @@ def testCollection(env,dir):
""" treat a Directory containing a collection of standalone tests.
Link each of them into an independent executable
"""
env = env.Clone()
env.Append(CPPPATH=dir) # add subdir to Includepath
srcpatt = ['test-*.c']
exeName = lambda p: path.basename(path.splitext(p)[0])
buildIt = lambda p: env.Program(exeName(p), [p] + core)

View file

@ -24,7 +24,7 @@
#include "backend/backend.h"
#include "backend/filedescriptor.h"
#include "tests/test.h"
#include "lib/test/test.h"
TESTS_BEGIN

View file

@ -25,7 +25,7 @@
#include "backend/backend.h"
#include "backend/filehandlecache.h"
#include "tests/test.h"
#include "lib/test/test.h"
TESTS_BEGIN

View file

@ -22,7 +22,7 @@
#include "backend/backend.h"
#include "backend/fileheader.h"
#include "tests/test.h"
#include "lib/test/test.h"
#include "backend/filehandlecache.h"
extern LumieraFilehandlecache lumiera_fhcache;

View file

@ -31,7 +31,7 @@
#include "backend/mmapings.h"
#include "backend/mmap.h"
#include "tests/test.h"
#include "lib/test/test.h"
#include <unistd.h>
#include <string.h>

View file

@ -21,7 +21,7 @@
#include "backend/resourcecollector.h"
#include "tests/test.h"
#include "lib/test/test.h"
#include <unistd.h>
#include <errno.h>

View file

@ -19,7 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "tests/test.h"
#include "lib/test/test.h"
#include "backend/threadpool.h"
#include "include/logging.h"

View file

@ -27,7 +27,7 @@
#include "include/logging.h"
#include "lib/mutex.h"
#include "backend/threads.h"
#include "tests/test.h"
#include "lib/test/test.h"
#include <unistd.h>
#include <errno.h>

View file

@ -24,7 +24,7 @@
#include "common/config.h"
#include "common/configitem.h"
#include "tests/test.h"
#include "lib/test/test.h"
TESTS_BEGIN

View file

@ -25,8 +25,8 @@
#include "common/config.h"
#include "common/config_interface.h"
#include "tests/test.h"
#include "tests/common/hello_interface.h"
#include "lib/test/test.h"
#include "interface/say_hello.h"
/*
define 2 example interfaces
@ -465,7 +465,9 @@ TEST (plugin_discover)
if (lumiera_plugin_discover (lumiera_plugin_load, lumiera_plugin_register))
{
LumieraPlugin p = lumiera_plugin_lookup ("modules/examplepluginc.lum");
LumieraPlugin p = lumiera_plugin_lookup ("modules/test-c-plugin.lum");
printf ("found plugin: %s\n", lumiera_plugin_name (p));
p = lumiera_plugin_lookup ("modules/test-cpp-plugin.lum");
printf ("found plugin: %s\n", lumiera_plugin_name (p));
lumiera_plugin_discover (lumiera_plugin_load, lumiera_plugin_register);
}
@ -482,12 +484,12 @@ TEST (plugin_unload)
lumiera_interfaceregistry_init ();
lumiera_plugin_discover (lumiera_plugin_load, lumiera_plugin_register);
LumieraPlugin p = lumiera_plugin_lookup ("modules/examplepluginc.lum");
LumieraPlugin p = lumiera_plugin_lookup ("modules/test-c-plugin.lum");
printf ("plugin discovered before unload: %p\n", p);
CHECK (p, "prerequisite: need to load examplepluginc.lum");
CHECK (p, "prerequisite: need to load test-c-plugin.lum");
lumiera_plugin_unload (lumiera_plugin_lookup ("modules/examplepluginc.lum"));
p = lumiera_plugin_lookup ("examplepluginc.lum");
lumiera_plugin_unload (lumiera_plugin_lookup ("modules/test-c-plugin.lum"));
p = lumiera_plugin_lookup ("test-c-plugin.lum");
printf ("plugin discovered after unload: %p\n", p);
CHECK (!p, "failed to unload plugin.");
@ -496,7 +498,7 @@ TEST (plugin_unload)
}
TEST (plugin_examplepluginc)
TEST (plugin_exampleplugin)
{
lumiera_interfaceregistry_init ();
lumiera_plugin_discover (lumiera_plugin_load, lumiera_plugin_register);
@ -522,7 +524,7 @@ TEST (plugin_examplepluginc)
lumiera_config_destroy ();
}
TEST (plugin_examplepluginc_nested)
TEST (plugin_exampleplugin_nested)
{
lumiera_interfaceregistry_init ();
lumiera_plugin_discover (lumiera_plugin_load, lumiera_plugin_register);
@ -540,6 +542,32 @@ TEST (plugin_examplepluginc_nested)
lumiera_config_destroy ();
}
TEST (plugin_exampleplugin_cpp)
{
lumiera_interfaceregistry_init ();
lumiera_plugin_discover (lumiera_plugin_load, lumiera_plugin_register);
LUMIERA_INTERFACE_HANDLE(lumieraorg_testhello, 0) german =
LUMIERA_INTERFACE_OPEN (lumieraorg_testhello, 0, 0, lumieraorg_hello_german_cpp);
LUMIERA_INTERFACE_HANDLE(lumieraorg_testhello, 0) english =
LUMIERA_INTERFACE_OPEN (lumieraorg_testhello, 0, 0, lumieraorg_hello_english_cpp);
german->hello ();
german->goodbye ("schnöde Welt!");
english->hello ();
english->goodbye ("Vale of Tears!");
LUMIERA_INTERFACE_CLOSE (german);
LUMIERA_INTERFACE_CLOSE (english);
lumiera_interfaceregistry_destroy ();
lumiera_config_destroy ();
}
TESTS_END

View file

@ -35,7 +35,7 @@ namespace lumiera{
namespace test {
/******************************************
* Hellooooooo the world is a test
* Hellooooooo the world is just a test
* @test demo of using the test framework
*/
class HelloWorld_test : public Test
@ -58,10 +58,15 @@ namespace test {
/** Register this test class to be invoked in some test groups (suites) */
Launch<HelloWorld_test> run_HelloWorld_test("HelloWorld_test","unit common");
// NOTE: you may use the Macro "LAUNCHER" in run.hpp to simplify this Registration
/** Register this test class to be invoked in some test groups (suites)
* @remarks this macro \c LUNCHER is defined in run.hpp to simplify
* the registration of test classes. It expands to the
* following static variable definition
* \code
* Launch<HelloWorld_test> run_HelloWorld_test("HelloWorld_test","unit common");
* \endcode
*/
LAUNCHER (HelloWorld_test, "unit common");

View file

@ -22,7 +22,7 @@
#include <nobug.h>
#include "lib/llist.h"
#include "tests/test.h"
#include "lib/test/test.h"
TESTS_BEGIN

View file

@ -19,7 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "tests/test.h"
#include "lib/test/test.h"
#include "lib/mutex.h"
#include "lib/recmutex.h"
#include "lib/condition.h"

View file

@ -19,7 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "tests/test.h"
#include "lib/test/test.h"
#include "lib/mpool.h"
struct teststruct

View file

@ -24,7 +24,7 @@
#include <nobug.h>
#include "lib/psplay.h"
#include "tests/test.h"
#include "lib/test/test.h"
struct testitem
{

View file

@ -18,7 +18,7 @@
*/
#include "lib/safeclib.h"
#include "lib/tmpbuf.h" /* not factored out yet */
#include "tests/test.h"
#include "lib/test/test.h"
#include <sys/time.h>
#include <sys/resource.h>

View file

@ -20,7 +20,7 @@
*/
#include "lib/slist.h"
#include "tests/test.h"
#include "lib/test/test.h"
#include <sys/time.h>
#include <nobug.h>

View file

@ -21,7 +21,7 @@
typedef unsigned int uint;
#include "tests/test.h"
#include "lib/test/test.h"
#include "lib/time.h"
#include <nobug.h>

View file

@ -1 +0,0 @@
tests for the main lumiera loader

View file

@ -26,7 +26,7 @@
#include "common/interfacedescriptor.h"
#include "common/config_interface.h"
#include "tests/common/hello_interface.h"
#include "interface/say_hello.h"
LUMIERA_PLUGIN_INTERFACEHANDLE;

View file

@ -1,5 +1,5 @@
/*
example_plugin.cpp - example plugin (C++) for testing the interface/plugin system
ExamplePlugin - example plugin (C++) for testing the interface/plugin system
Copyright (C) Lumiera.org
2008, Christian Thaeter <ct@pipapo.org>,
@ -32,7 +32,7 @@ extern "C" {
#include "common/interface.h"
#include "common/interfacedescriptor.h"
#include "tests/common/hello_interface.h"
#include "interface/say_hello.h"
}
using boost::format;
@ -41,7 +41,7 @@ using std::endl;
class example_plugin
class ExamplePlugin
{
public:
static LumieraInterface
@ -55,13 +55,13 @@ class example_plugin
static void
myclose (LumieraInterface)
{
std::cout << "closed" << endl;
std::cout << "dying" << endl;
}
};
class example_plugin_de
: public example_plugin
class ExamplePlugin_de
: public ExamplePlugin
{
public:
static void
@ -73,13 +73,13 @@ class example_plugin_de
static void
servus (const char* m)
{
std::cout << "Tschuess " << m << endl;
std::cout << "Tschüss " << m << endl;
}
};
class example_plugin_en
: public example_plugin
class ExamplePlugin_en
: public ExamplePlugin
{
public:
static void
@ -107,22 +107,22 @@ extern "C" { /* ================== define two lumieraorg_testhello instance ====
LUMIERA_INTERFACE_DEFINE (lumieraorg_testhello, 0
,lumieraorg_hello_german_cpp
, NULL /* no descriptor given */
, example_plugin::myopen
, example_plugin::myclose
, ExamplePlugin::myopen
, ExamplePlugin::myclose
, LUMIERA_INTERFACE_MAP (hello, "\300\244\125\265\235\312\175\263\335\044\371\047\247\263\015\322",
example_plugin_de::griazi)
ExamplePlugin_de::griazi)
, LUMIERA_INTERFACE_MAP (goodbye, "\115\365\126\102\201\104\012\257\153\232\006\210\010\346\076\070",
example_plugin_de::servus)
ExamplePlugin_de::servus)
),
LUMIERA_INTERFACE_DEFINE (lumieraorg_testhello, 0
,lumieraorg_hello_english_cpp
, NULL /* no descriptor given */
, example_plugin::myopen
, example_plugin::myclose
, ExamplePlugin::myopen
, ExamplePlugin::myclose
, LUMIERA_INTERFACE_MAP (hello, "\303\367\107\154\077\063\237\066\034\034\050\136\170\220\260\226",
example_plugin_en::hello)
ExamplePlugin_en::hello)
, LUMIERA_INTERFACE_MAP (goodbye, "\107\207\072\105\101\102\150\201\322\043\104\110\232\023\205\161",
example_plugin_en::bye)
ExamplePlugin_en::bye)
)
);