testsuite update, new test.h to be in sync with nobug

test.h introduces a PLANNED_TEST() macro for C code, shows what tests
are provided and so on (the nobug version did that since some time).

test names are now passed as identifers and translated to strings by the
macros.

A lot fixes for existing tests, replace some printfs with ECHO, cosmetics.

one threadpool (sync_many) test is broken and set to PLANNED, this needs
further testsuite support for dispatching output.

add a TEST nobug flag to test.h
This commit is contained in:
Christian Thaeter 2010-03-04 16:23:57 +01:00
parent 3201ae5d8c
commit 4fee3d85cf
14 changed files with 354 additions and 344 deletions

View file

@ -1,40 +1,50 @@
TESTING "Single Linked Lists" ./test-slist
TEST "initialization and predicates" basic <<END
out: 1
out: 0
out: 1
out: 0
out: 1
out: 0
out: 1
out: 0
err: ECHO: .*: 1
err: ECHO: .*: 0
err: ECHO: .*: 1
err: ECHO: .*: 0
err: ECHO: .*: 1
err: ECHO: .*: 0
err: ECHO: .*: 1
err: ECHO: .*: 0
END
TEST "insert/delete nodes" insert_delete <<END
out: 1
out: 0
out: 1
out: 0
out: 1
err: ECHO: .*: 1
err: ECHO: .*: 0
err: ECHO: .*: 1
err: ECHO: .*: 0
err: ECHO: .*: 1
END
TEST "moving across a list" movement <<END
out: 1
err: ECHO: .*: 1
END
TEST "enumerates elements of a list" enumerations <<END
out: A B C D .
out: ---
out: B C .
out: ---
out: A B C D .
out: 1
err: ECHO: .*: A
err: ECHO: .*: B
err: ECHO: .*: C
err: ECHO: .*: D
err: ECHO: .*: ,
err: ECHO: .*: ---
err: ECHO: .*: B
err: ECHO: .*: C
err: ECHO: .*: ,
err: ECHO: .*: ---
err: ECHO: .*: A
err: ECHO: .*: B
err: ECHO: .*: C
err: ECHO: .*: D
err: ECHO: .*: ,
err: ECHO: .*: 1
END
TEST "get length and n-th element of a list" count <<END
out: 3
out: 1
err: ECHO: .*: 3
err: ECHO: .*: 1
END
TEST "sorts a list" sort <<END
@ -42,5 +52,5 @@ return: 0
END
TEST "finds element inside a list" search <<END
out: 1
err: ECHO: .*: 1
END

View file

@ -30,7 +30,10 @@ err: syncing with the other thread
err: result is 0
END
TEST "sync many" sync-many <<END
# Broken, needs better test drive (planned features for dispatching output)
PLANNED "sync many" sync-many <<END
err(worker_): result is 0
err(thread_1): value is 84
END
TEST "joinable thread" joinable-thread <<END

View file

@ -44,7 +44,7 @@ TESTS_BEGIN
The first two are not really tests, but some code to check for
filesystem and kernel semantics which might be moved elsewhere someday
*/
TEST ("mmap_semantic")
TEST (mmap_semantic)
{
int fd = open (",mmaptest", O_RDWR|O_CREAT, 0666);
printf ("got fd %d\n", fd);
@ -78,7 +78,7 @@ TEST ("mmap_semantic")
}
}
TEST ("fd_semantic")
TEST (fd_semantic)
{
mkdir (",testdir", 0777); errno = 0;
@ -106,7 +106,7 @@ TEST ("fd_semantic")
}
TEST ("mmap_missing_chunksize")
TEST (mmap_missing_chunksize)
{
lumiera_backend_init ();
LumieraFile file = lumiera_file_new (",tmp-filemmap", LUMIERA_FILE_CREATE);
@ -123,7 +123,7 @@ TEST ("mmap_missing_chunksize")
}
TEST ("mmap_forget_releasing")
TEST (mmap_forget_releasing)
{
lumiera_backend_init ();
LumieraFile file = lumiera_file_new (",tmp-filemmap", LUMIERA_FILE_CREATE);
@ -142,7 +142,7 @@ TEST ("mmap_forget_releasing")
}
TEST ("mmap_simple")
TEST (mmap_simple)
{
lumiera_backend_init ();
LumieraFile file = lumiera_file_new (",tmp-filemmap", LUMIERA_FILE_CREATE);
@ -167,7 +167,7 @@ TEST ("mmap_simple")
TEST ("mmap_checkout_twice")
TEST (mmap_checkout_twice)
{
lumiera_backend_init ();
LumieraFile file = lumiera_file_new (",tmp-filemmap", LUMIERA_FILE_CREATE);
@ -198,7 +198,7 @@ TEST ("mmap_checkout_twice")
TEST ("mmap_checkout_again")
TEST (mmap_checkout_again)
{
lumiera_backend_init ();
LumieraFile file = lumiera_file_new (",tmp-filemmap", LUMIERA_FILE_CREATE);
@ -225,7 +225,7 @@ TEST ("mmap_checkout_again")
TEST ("mmap_grow_existing_file")
TEST (mmap_grow_existing_file)
{
lumiera_backend_init ();
LumieraFile file = lumiera_file_new (",tmp-filemmap", LUMIERA_FILE_READWRITE);
@ -249,7 +249,7 @@ TEST ("mmap_grow_existing_file")
}
TEST ("mmap_readonly_file")
TEST (mmap_readonly_file)
{
lumiera_backend_init ();
LumieraFile file = lumiera_file_new (",tmp-filemmap", LUMIERA_FILE_READONLY);
@ -274,7 +274,7 @@ TEST ("mmap_readonly_file")
TEST ("file_access")
TEST (file_access)
{
lumiera_backend_init ();
LumieraFile file = lumiera_file_new (",tmp-filemmap", LUMIERA_FILE_RECREATE);
@ -294,7 +294,7 @@ TEST ("file_access")
TEST ("mmap_section")
TEST (mmap_section)
{
lumiera_backend_init ();
LumieraFile file = lumiera_file_new (",tmp-filemmap", LUMIERA_FILE_RECREATE);
@ -312,7 +312,7 @@ TEST ("mmap_section")
}
TEST ("mmap_section_err")
TEST (mmap_section_err)
{
lumiera_backend_init ();
LumieraFile file = lumiera_file_new (",tmp-filemmap", LUMIERA_FILE_RECREATE);
@ -331,7 +331,7 @@ TEST ("mmap_section_err")
#if 0
TEST ("refactored_usage")
TEST (refactored_usage)
{
LumieraFile file = lumiera_file_new ("filename", mode);

View file

@ -48,14 +48,14 @@ test_memory_handler (enum lumiera_resource_try itr, void* data, void* context)
TESTS_BEGIN
TEST ("basic")
TEST (basic)
{
lumiera_resourcecollector_init ();
lumiera_resourcecollector_register_handler (LUMIERA_RESOURCE_MEMORY, test_memory_handler, NULL);
lumiera_resourcecollector_destroy ();
}
TEST ("memory_collection_mockup")
TEST (memory_collection_mockup)
{
REQUIRE (argv[2]);
lumiera_resourcecollector_init ();

View file

@ -37,10 +37,10 @@ void is_prime(void * arg)
for (unsigned long long x = number-1; x >= sqrt(number); --x)
{
if ((number % x) == 0)
{
prime = 0;
break;
}
{
prime = 0;
break;
}
}
*(unsigned long long *)arg = prime;
usleep(1);
@ -89,11 +89,13 @@ void joinable_master_fn(void * arg)
lumiera_thread_sync ();
CHECK (input == 42, "input is not 42, but %d", input);
LumieraThread worker = lumiera_thread_run (LUMIERA_THREADCLASS_IDLE
| LUMIERA_THREAD_JOINABLE,
&joinable_worker_fn,
(void *)&input,
"joinable worker thread",
&NOBUG_FLAG (test));
| LUMIERA_THREAD_JOINABLE,
&joinable_worker_fn,
(void *)&input,
"joinable worker thread",
&NOBUG_FLAG (NOBUG_ON));
lumiera_thread_sync_other (worker);
lumiera_thread_join (worker);
lumiera_thread_sync_other (worker); // wait until the arguments are sent
lumiera_thread_join (worker); // wait until the result has been calculated
CHECK (input == 42-13, "result is not 42-13=29, but %d", input);
@ -103,27 +105,27 @@ void joinable_master_fn(void * arg)
TESTS_BEGIN
TEST ("threadpool-basic")
TEST (threadpool-basic)
{
lumiera_threadpool_init();
lumiera_threadpool_destroy();
}
TEST ("threadpool1")
TEST (threadpool1)
{
ECHO("start by initializing the threadpool");
lumiera_threadpool_init();
LumieraThread t1 =
lumiera_threadpool_acquire_thread(LUMIERA_THREADCLASS_INTERACTIVE,
"test purpose",
&NOBUG_FLAG(TESTS));
"test purpose",
&NOBUG_FLAG(NOBUG_ON));
// lumiera_threadpool_release_thread(t1);
ECHO("acquired thread 1 %p",t1);
lumiera_threadpool_destroy();
}
TEST ("two-thread-acquire")
TEST (two-thread-acquire)
{
ECHO("start by initializing the threadpool");
lumiera_threadpool_init();
@ -131,14 +133,14 @@ TEST ("two-thread-acquire")
LumieraThread t1 =
lumiera_threadpool_acquire_thread(LUMIERA_THREADCLASS_INTERACTIVE,
"test purpose",
&NOBUG_FLAG(TESTS));
"test purpose",
&NOBUG_FLAG(NOBUG_ON));
ECHO("acquiring thread 2");
LumieraThread t2 =
lumiera_threadpool_acquire_thread(LUMIERA_THREADCLASS_IDLE,
"test purpose",
&NOBUG_FLAG(TESTS));
"test purpose",
&NOBUG_FLAG(NOBUG_ON));
ECHO("thread 1 state=%s", lumiera_threadstate_names[t1->state]);
CHECK(LUMIERA_THREADSTATE_IDLE == t1->state);
@ -146,13 +148,13 @@ TEST ("two-thread-acquire")
ECHO("thread 2 state=%s", lumiera_threadstate_names[t2->state]);
CHECK(LUMIERA_THREADSTATE_IDLE == t2->state);
LUMIERA_CONDITION_SECTION(TESTS, &t1->signal)
LUMIERA_CONDITION_SECTION(NOBUG_ON, &t1->signal)
{
t1->state = LUMIERA_THREADSTATE_WAKEUP;
LUMIERA_CONDITION_SIGNAL;
}
LUMIERA_CONDITION_SECTION(TESTS, &t2->signal)
LUMIERA_CONDITION_SECTION(NOBUG_ON, &t2->signal)
{
t2->state = LUMIERA_THREADSTATE_WAKEUP;
LUMIERA_CONDITION_SIGNAL;
@ -162,7 +164,7 @@ TEST ("two-thread-acquire")
lumiera_threadpool_destroy();
}
TEST ("many-sleepy-threads")
TEST (many-sleepy-threads)
{
const int threads_per_pool_count = 10;
@ -174,21 +176,21 @@ TEST ("many-sleepy-threads")
for (int kind = 0; kind < LUMIERA_THREADCLASS_COUNT; ++kind)
{
for (int i = 0; i < threads_per_pool_count; ++i)
{
threads[i+kind*threads_per_pool_count] =
lumiera_thread_run(kind,
&sleep_fn,
(void *) &delay,
"just sleep a bit",
&NOBUG_FLAG(TESTS));
}
{
threads[i+kind*threads_per_pool_count] =
lumiera_thread_run(kind,
&sleep_fn,
(void *) &delay,
"just sleep a bit",
&NOBUG_FLAG(NOBUG_ON));
}
}
lumiera_threadpool_destroy();
}
TEST ("toomany-random-sleepy-threads (compiletest only)")
TEST (toomany-random-sleepy-threads (compiletest only))
{
const int threads_per_pool_count = 500;
unsigned int delay[threads_per_pool_count*LUMIERA_THREADCLASS_COUNT];
@ -198,37 +200,37 @@ TEST ("toomany-random-sleepy-threads (compiletest only)")
for (int kind = 0; kind < LUMIERA_THREADCLASS_COUNT; ++kind)
{
for (int i = 0; i < threads_per_pool_count; ++i)
{
delay[i] = rand() % 1000000;
threads[i+kind*threads_per_pool_count] =
lumiera_thread_run(kind,
&sleep_fn,
(void *) &delay[i],
"just sleep a bit",
&NOBUG_FLAG(TESTS));
}
{
delay[i] = rand() % 1000000;
threads[i+kind*threads_per_pool_count] =
lumiera_thread_run(kind,
&sleep_fn,
(void *) &delay[i],
"just sleep a bit",
&NOBUG_FLAG(NOBUG_ON));
}
}
lumiera_threadpool_destroy();
}
TEST ("no-function")
TEST (no-function)
{
LumieraThread t;
lumiera_threadpool_init();
t = lumiera_thread_run (LUMIERA_THREADCLASS_INTERACTIVE,
NULL,
NULL,
"process my test function",
&NOBUG_FLAG(TESTS));
NULL,
NULL,
"process my test function",
&NOBUG_FLAG(NOBUG_ON));
// cleanup
ECHO("finished waiting");
lumiera_threadpool_destroy();
}
TEST ("process-function")
TEST (process-function)
{
// this is what the scheduler would do once it figures out what function a job needs to run
LumieraThread t;
@ -239,10 +241,10 @@ TEST ("process-function")
ECHO ("the input to the function is %llu", number);
t = lumiera_thread_run (LUMIERA_THREADCLASS_INTERACTIVE,
&is_prime,
(void *)&number, //void * arg,
"process my test function",
&NOBUG_FLAG(TESTS)); // struct nobug_flag* flag)
&is_prime,
(void *)&number, //void * arg,
"process my test function",
&NOBUG_FLAG(NOBUG_ON)); // struct nobug_flag* flag)
// cleanup
lumiera_threadpool_destroy();
@ -250,7 +252,7 @@ TEST ("process-function")
}
TEST ("many-random-sleepy-threads (compiletest only)")
TEST (many-random-sleepy-threads (compiletest only))
{
const int threads_per_pool_count = 10;
unsigned int delay[threads_per_pool_count*LUMIERA_THREADCLASS_COUNT];
@ -260,30 +262,30 @@ TEST ("many-random-sleepy-threads (compiletest only)")
for (int kind = 0; kind < LUMIERA_THREADCLASS_COUNT; ++kind)
{
for (int i = 0; i < threads_per_pool_count; ++i)
{
delay[i] = rand() % 1000000;
threads[i+kind*threads_per_pool_count] =
lumiera_thread_run(kind,
&sleep_fn,
(void *) &delay[i],
"just sleep a bit",
&NOBUG_FLAG(TESTS));
}
{
delay[i] = rand() % 1000000;
threads[i+kind*threads_per_pool_count] =
lumiera_thread_run(kind,
&sleep_fn,
(void *) &delay[i],
"just sleep a bit",
&NOBUG_FLAG(NOBUG_ON));
}
}
lumiera_threadpool_destroy();
}
TEST ("simple-sync")
TEST (simple-sync)
{
lumiera_threadpool_init ();
int value = 42;
LumieraThread other = lumiera_thread_run (LUMIERA_THREADCLASS_IDLE,
&other_fn,
(void *)&value,
"other thread",
&NOBUG_FLAG (TESTS));
&other_fn,
(void *)&value,
"other thread",
&NOBUG_FLAG (NOBUG_ON));
ECHO ("syncing with the other thread");
lumiera_thread_sync_other (other);
@ -293,7 +295,7 @@ TEST ("simple-sync")
lumiera_threadpool_destroy ();
}
TEST ("sync-many")
TEST (sync-many)
{
lumiera_threadpool_init ();
@ -305,10 +307,10 @@ TEST ("sync-many")
{
value = 123;
threads[i] = lumiera_thread_run (LUMIERA_THREADCLASS_IDLE,
&sleeping_worker_fn,
(void *)&value,
"worker thread",
&NOBUG_FLAG (TESTS));
&sleeping_worker_fn,
(void *)&value,
"worker thread",
&NOBUG_FLAG (NOBUG_ON));
lumiera_thread_sync_other (threads[i]);
value -= 123;
}
@ -316,21 +318,21 @@ TEST ("sync-many")
lumiera_threadpool_destroy ();
}
TEST ("joinable-thread")
TEST (joinable-thread)
{
int delay = 10000;
lumiera_threadpool_init ();
LumieraThread t = lumiera_thread_run (LUMIERA_THREADCLASS_IDLE
| LUMIERA_THREAD_JOINABLE,
&sleep_fn,
(void *)&delay,
"joinable idle thread",
&NOBUG_FLAG (test));
| LUMIERA_THREAD_JOINABLE,
&sleep_fn,
(void *)&delay,
"joinable idle thread",
&NOBUG_FLAG (NOBUG_ON));
lumiera_thread_join(t);
lumiera_threadpool_destroy ();
}
TEST ("sync-joinable")
TEST (sync-joinable)
{
// NOTE: this test essentially avoids concurrency with _sync() calls
lumiera_threadpool_init ();
@ -338,11 +340,11 @@ TEST ("sync-joinable")
int value = 42;
LumieraThread master = lumiera_thread_run (LUMIERA_THREADCLASS_IDLE
| LUMIERA_THREAD_JOINABLE,
&joinable_master_fn,
(void *)&value,
"joinable master thread",
&NOBUG_FLAG (test));
| LUMIERA_THREAD_JOINABLE,
&joinable_master_fn,
(void *)&value,
"joinable master thread",
&NOBUG_FLAG (NOBUG_ON));
lumiera_thread_sync_other (master);
value = 7732;

View file

@ -28,7 +28,7 @@
TESTS_BEGIN
TEST ("init")
TEST (init)
{
/* lumiera_config_init ("./"); */
printf ("initialized\n");
@ -37,7 +37,7 @@ TEST ("init")
}
TEST ("configitem_simple")
TEST (configitem_simple)
{
REQUIRE (argv[2]);
@ -61,7 +61,7 @@ TEST ("configitem_simple")
}
TEST ("lookup")
TEST (lookup)
{
lumiera_config_lookup lookup;
@ -81,7 +81,7 @@ TEST ("lookup")
}
TEST ("change_value")
TEST (change_value)
{
REQUIRE (argv[2]);
REQUIRE (argv[3]);
@ -110,7 +110,7 @@ TEST ("change_value")
TEST ("basic_set_get")
TEST (basic_set_get)
{
REQUIRE (argv[2]);
REQUIRE (argv[3]);
@ -133,7 +133,7 @@ TEST ("basic_set_get")
TEST ("number_get")
TEST (number_get)
{
REQUIRE (argv[2]);
REQUIRE (argv[3]);
@ -151,7 +151,7 @@ TEST ("number_get")
}
TEST ("number_get_nodefault")
TEST (number_get_nodefault)
{
REQUIRE (argv[2]);
@ -166,7 +166,7 @@ TEST ("number_get_nodefault")
}
TEST ("number_set")
TEST (number_set)
{
REQUIRE (argv[2]);
REQUIRE (argv[3]);
@ -185,7 +185,7 @@ TEST ("number_set")
}
TEST ("string_get")
TEST (string_get)
{
REQUIRE (argv[2]);
REQUIRE (argv[3]);
@ -203,7 +203,7 @@ TEST ("string_get")
}
TEST ("string_set")
TEST (string_set)
{
REQUIRE (argv[2]);
REQUIRE (argv[3]);
@ -221,7 +221,7 @@ TEST ("string_set")
}
TEST ("word_get")
TEST (word_get)
{
REQUIRE (argv[2]);
REQUIRE (argv[3]);
@ -239,7 +239,7 @@ TEST ("word_get")
}
TEST ("word_set")
TEST (word_set)
{
REQUIRE (argv[2]);
REQUIRE (argv[3]);
@ -257,7 +257,7 @@ TEST ("word_set")
}
TEST ("configitem_simple_ctor_dtor")
TEST (configitem_simple_ctor_dtor)
{
REQUIRE (argv[2]);
@ -269,7 +269,7 @@ TEST ("configitem_simple_ctor_dtor")
}
TEST ("configitem_simple_content_check")
TEST (configitem_simple_content_check)
{
REQUIRE (argv[2]);
@ -298,7 +298,7 @@ TEST ("configitem_simple_content_check")
}
TEST ("wordlist_get_nth")
TEST (wordlist_get_nth)
{
REQUIRE (argv[2]);
REQUIRE (argv[3]);
@ -315,7 +315,7 @@ TEST ("wordlist_get_nth")
}
TEST ("wordlist_find")
TEST (wordlist_find)
{
REQUIRE (argv[2]);
REQUIRE (argv[3]);
@ -332,7 +332,7 @@ TEST ("wordlist_find")
}
TEST ("wordlist_replace")
TEST (wordlist_replace)
{
REQUIRE (argv[2]);
REQUIRE (argv[3]);
@ -354,7 +354,7 @@ TEST ("wordlist_replace")
}
TEST ("wordlist_add")
TEST (wordlist_add)
{
REQUIRE (argv[2]);
REQUIRE (argv[3]);

View file

@ -53,7 +53,7 @@ LUMIERA_INTERFACE_DECLARE (lumieraorg_testexample_void, 0
void
testfunc (const char* message)
{
printf ("Called as '%s'\n", message);
ECHO ("Called as '%s'", message);
}
@ -62,7 +62,7 @@ LumieraInterface
testacquire (LumieraInterface self, LumieraInterface interface)
{
(void) interface;
printf ("Acquire %s_%d_%s\n", self->interface, self->version, self->name);
ECHO ("Acquire %s_%d_%s", self->interface, self->version, self->name);
return self;
}
@ -70,7 +70,7 @@ testacquire (LumieraInterface self, LumieraInterface interface)
void
testrelease (LumieraInterface self)
{
printf ("Release %s_%d_%s\n", self->interface, self->version, self->name);
ECHO ("Release %s_%d_%s", self->interface, self->version, self->name);
}
/*
@ -170,7 +170,7 @@ LumieraInterface
testacquire_one (LumieraInterface self, LumieraInterface interface)
{
(void) interface;
TRACE (TESTS, "Acquire one %s_%d_%s", self->interface, self->version, self->name);
ECHO ("Acquire one %s_%d_%s", self->interface, self->version, self->name);
one_keeps_two = LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_two);
one_keeps_three = LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_three);
return self;
@ -179,7 +179,7 @@ testacquire_one (LumieraInterface self, LumieraInterface interface)
void
testrelease_one (LumieraInterface self)
{
TRACE (TESTS, "Release one %s_%d_%s", self->interface, self->version, self->name);
ECHO ("Release one %s_%d_%s", self->interface, self->version, self->name);
lumiera_interface_close ((LumieraInterface)one_keeps_two);
lumiera_interface_close ((LumieraInterface)one_keeps_three);
}
@ -191,7 +191,7 @@ LumieraInterface
testacquire_two (LumieraInterface self, LumieraInterface interface)
{
(void) interface;
TRACE (TESTS, "Acquire two %s_%d_%s", self->interface, self->version, self->name);
ECHO ("Acquire two %s_%d_%s", self->interface, self->version, self->name);
two_keeps_one = LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_one);
two_keeps_four = LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_four);
return self;
@ -200,7 +200,7 @@ testacquire_two (LumieraInterface self, LumieraInterface interface)
void
testrelease_two (LumieraInterface self)
{
TRACE (TESTS, "Release two %s_%d_%s", self->interface, self->version, self->name);
ECHO ("Release two %s_%d_%s", self->interface, self->version, self->name);
lumiera_interface_close ((LumieraInterface)two_keeps_one);
lumiera_interface_close ((LumieraInterface)two_keeps_four);
}
@ -212,7 +212,7 @@ LumieraInterface
testacquire_three (LumieraInterface self, LumieraInterface interface)
{
(void) interface;
TRACE (TESTS, "Acquire three %s_%d_%s", self->interface, self->version, self->name);
ECHO ("Acquire three %s_%d_%s", self->interface, self->version, self->name);
three_keeps_two = LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_two);
three_keeps_four = LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_four);
return self;
@ -221,7 +221,7 @@ testacquire_three (LumieraInterface self, LumieraInterface interface)
void
testrelease_three (LumieraInterface self)
{
TRACE (TESTS, "Release three %s_%d_%s", self->interface, self->version, self->name);
ECHO ("Release three %s_%d_%s", self->interface, self->version, self->name);
lumiera_interface_close ((LumieraInterface)three_keeps_two);
lumiera_interface_close ((LumieraInterface)three_keeps_four);
}
@ -234,7 +234,7 @@ LumieraInterface
testacquire_four (LumieraInterface self, LumieraInterface interface)
{
(void) interface;
TRACE (TESTS, "Acquire four %s_%d_%s", self->interface, self->version, self->name);
ECHO ("Acquire four %s_%d_%s", self->interface, self->version, self->name);
four_keeps_one = LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_one);
four_keeps_two = LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_two);
four_keeps_three = LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_three);
@ -244,7 +244,7 @@ testacquire_four (LumieraInterface self, LumieraInterface interface)
void
testrelease_four (LumieraInterface self)
{
TRACE (TESTS, "Release four %s_%d_%s", self->interface, self->version, self->name);
ECHO ("Release four %s_%d_%s", self->interface, self->version, self->name);
lumiera_interface_close ((LumieraInterface)four_keeps_one);
lumiera_interface_close ((LumieraInterface)four_keeps_two);
lumiera_interface_close ((LumieraInterface)four_keeps_three);
@ -301,7 +301,7 @@ LUMIERA_EXPORT (
TESTS_BEGIN
TEST ("basic")
TEST (basic)
{
lumiera_interfaceregistry_init ();
@ -325,14 +325,14 @@ TEST ("basic")
lumiera_interfaceregistry_destroy ();
}
TEST ("open_close")
TEST (open_close)
{
lumiera_interfaceregistry_init ();
lumiera_interfaceregistry_bulkregister_interfaces (lumiera_plugin_interfaces(), NULL);
LUMIERA_INTERFACE_HANDLE(lumieraorg_testexample_one, 0) handle =
LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_one, 0, 0, lumieraorg_first_test);
ENSURE (handle);
CHECK (handle);
handle->bar1 ("this is bar1");
@ -342,16 +342,16 @@ TEST ("open_close")
lumiera_interfaceregistry_destroy ();
}
TEST ("dependencies_one")
TEST (dependencies_one)
{
lumiera_interfaceregistry_init ();
LUMIERA_INTERFACE_REGISTEREXPORTED;
LUMIERA_INTERFACE_HANDLE(lumieraorg_testexample_void, 0) handle =
LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_one);
ENSURE (handle);
CHECK (handle);
TRACE (TESTS, "Sucessfully opened");
ECHO ("Sucessfully opened");
lumiera_interface_close ((LumieraInterface)handle);
@ -360,16 +360,16 @@ TEST ("dependencies_one")
}
TEST ("dependencies_two")
TEST (dependencies_two)
{
lumiera_interfaceregistry_init ();
LUMIERA_INTERFACE_REGISTEREXPORTED;
LUMIERA_INTERFACE_HANDLE(lumieraorg_testexample_void, 0) handle =
LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_two);
ENSURE (handle);
CHECK (handle);
TRACE (TESTS, "Sucessfully opened");
ECHO ("Sucessfully opened");
lumiera_interface_close ((LumieraInterface)handle);
@ -377,16 +377,16 @@ TEST ("dependencies_two")
lumiera_interfaceregistry_destroy ();
}
TEST ("dependencies_three")
TEST (dependencies_three)
{
lumiera_interfaceregistry_init ();
LUMIERA_INTERFACE_REGISTEREXPORTED;
LUMIERA_INTERFACE_HANDLE(lumieraorg_testexample_void, 0) handle =
LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_three);
ENSURE (handle);
CHECK (handle);
TRACE (TESTS, "Sucessfully opened");
ECHO ("Sucessfully opened");
lumiera_interface_close ((LumieraInterface)handle);
@ -395,16 +395,16 @@ TEST ("dependencies_three")
}
TEST ("dependencies_four")
TEST (dependencies_four)
{
lumiera_interfaceregistry_init ();
LUMIERA_INTERFACE_REGISTEREXPORTED;
LUMIERA_INTERFACE_HANDLE(lumieraorg_testexample_void, 0) handle =
LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_four);
ENSURE (handle);
CHECK (handle);
TRACE (TESTS, "Sucessfully opened");
ECHO ("Sucessfully opened");
lumiera_interface_close ((LumieraInterface)handle);
@ -414,43 +414,43 @@ TEST ("dependencies_four")
TEST ("dependencies_all")
TEST (dependencies_all)
{
lumiera_interfaceregistry_init ();
LUMIERA_INTERFACE_REGISTEREXPORTED;
TRACE (TESTS, "OPEN one");
ECHO ("OPEN one");
LUMIERA_INTERFACE_HANDLE(lumieraorg_testexample_void, 0) handle_one =
LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_one);
ENSURE (handle_one);
CHECK (handle_one);
TRACE (TESTS, "OPEN three");
ECHO ("OPEN three");
LUMIERA_INTERFACE_HANDLE(lumieraorg_testexample_void, 0) handle_three =
LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_three);
ENSURE (handle_three);
CHECK (handle_three);
TRACE (TESTS, "OPEN two");
ECHO ("OPEN two");
LUMIERA_INTERFACE_HANDLE(lumieraorg_testexample_void, 0) handle_two =
LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_two);
ENSURE (handle_two);
CHECK (handle_two);
TRACE (TESTS, "OPEN four");
ECHO ("OPEN four");
LUMIERA_INTERFACE_HANDLE(lumieraorg_testexample_void, 0) handle_four =
LUMIERA_INTERFACE_OPEN (lumieraorg_testexample_void, 0, 0, lumieraorg_dependencytest_four);
ENSURE (handle_four);
CHECK (handle_four);
TRACE (TESTS, "Sucessfully OPENED");
ECHO ("Sucessfully OPENED");
TRACE (TESTS, "CLOSE four");
ECHO ("CLOSE four");
lumiera_interface_close ((LumieraInterface)handle_four);
TRACE (TESTS, "CLOSE two");
ECHO ("CLOSE two");
lumiera_interface_close ((LumieraInterface)handle_two);
TRACE (TESTS, "CLOSE three");
ECHO ("CLOSE three");
lumiera_interface_close ((LumieraInterface)handle_three);
TRACE (TESTS, "CLOSE one");
ECHO ("CLOSE one");
lumiera_interface_close ((LumieraInterface)handle_one);
@ -459,7 +459,7 @@ TEST ("dependencies_all")
}
TEST ("plugin_discover")
TEST (plugin_discover)
{
lumiera_interfaceregistry_init ();
@ -477,7 +477,7 @@ TEST ("plugin_discover")
}
TEST ("plugin_unload")
TEST (plugin_unload)
{
lumiera_interfaceregistry_init ();
@ -491,7 +491,7 @@ TEST ("plugin_unload")
}
TEST ("plugin_examplepluginc")
TEST (plugin_examplepluginc)
{
lumiera_interfaceregistry_init ();
lumiera_plugin_discover (lumiera_plugin_load, lumiera_plugin_register);
@ -517,7 +517,7 @@ TEST ("plugin_examplepluginc")
lumiera_config_destroy ();
}
TEST ("plugin_examplepluginc_nested")
TEST (plugin_examplepluginc_nested)
{
lumiera_interfaceregistry_init ();
lumiera_plugin_discover (lumiera_plugin_load, lumiera_plugin_register);

View file

@ -19,15 +19,14 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
//#include <stdio.h>
//#include <string.h>
#include <nobug.h>
#include "lib/llist.h"
#include "tests/test.h"
TESTS_BEGIN
TEST ("basic")
TEST (basic)
{
LLIST_AUTO (node1);
@ -38,7 +37,7 @@ TEST ("basic")
printf ("%d\n", llist_is_empty (&node2));
}
TEST ("nodeinsert")
TEST (nodeinsert)
{
LLIST_AUTO (list);
LLIST_AUTO (node1);
@ -59,7 +58,7 @@ TEST ("nodeinsert")
printf ("%d\n", llist_count (&list));
}
TEST ("predicates")
TEST (predicates)
{
LLIST_AUTO (list);
LLIST_AUTO (node1);
@ -86,7 +85,7 @@ TEST ("predicates")
printf ("%d\n", llist_is_before_after (&list, &node1, &nil));
}
TEST ("unlink")
TEST (unlink)
{
LLIST_AUTO (list);
LLIST_AUTO (node1);
@ -128,7 +127,7 @@ TEST ("unlink")
printf ("%d\n", llist_is_empty (&nil));
}
TEST ("whiles")
TEST (whiles)
{
LLIST_AUTO (list);
LLIST_AUTO (node1);
@ -185,7 +184,7 @@ TEST ("whiles")
}
TEST ("relocate")
TEST (relocate)
{
llist source;
llist_init (&source);

View file

@ -32,7 +32,7 @@
TESTS_BEGIN
TEST ("mutexsection")
TEST (mutexsection)
{
lumiera_mutex m;
lumiera_mutex_init (&m, "mutexsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -51,7 +51,7 @@ TEST ("mutexsection")
}
TEST ("mutexforgotunlock")
TEST (mutexforgotunlock)
{
lumiera_mutex m;
lumiera_mutex_init (&m, "mutexforgotunlock", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -65,7 +65,7 @@ TEST ("mutexforgotunlock")
}
TEST ("mutexexplicitunlock")
TEST (mutexexplicitunlock)
{
lumiera_mutex m;
lumiera_mutex_init (&m, "mutexforgotunlock", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -81,7 +81,7 @@ TEST ("mutexexplicitunlock")
}
TEST ("nestedmutexsection")
TEST (nestedmutexsection)
{
lumiera_mutex m;
lumiera_mutex_init (&m, "m_mutexsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -103,7 +103,7 @@ TEST ("nestedmutexsection")
lumiera_mutex_destroy (&m, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
}
TEST ("chainedmutexsection")
TEST (chainedmutexsection)
{
lumiera_mutex m;
lumiera_mutex_init (&m, "m_mutexsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -127,7 +127,7 @@ TEST ("chainedmutexsection")
TEST ("recursivemutexsection")
TEST (recursivemutexsection)
{
lumiera_recmutex m;
lumiera_recmutex_init (&m, "m_recmutexsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -148,7 +148,7 @@ TEST ("recursivemutexsection")
TEST ("rwlocksection")
TEST (rwlocksection)
{
lumiera_rwlock rwlock;
lumiera_rwlock_init (&rwlock, "rwsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -167,7 +167,7 @@ TEST ("rwlocksection")
}
TEST ("rwlockforgotunlock")
TEST (rwlockforgotunlock)
{
lumiera_rwlock rwlock;
lumiera_rwlock_init (&rwlock, "rwlockforgotunlock", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -182,7 +182,7 @@ TEST ("rwlockforgotunlock")
TEST ("rwdeadlockwr")
TEST (rwdeadlockwr)
{
lumiera_rwlock rwlock;
lumiera_rwlock_init (&rwlock, "rwsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -201,7 +201,7 @@ TEST ("rwdeadlockwr")
TEST ("rwdeadlockrw")
TEST (rwdeadlockrw)
{
lumiera_rwlock rwlock;
lumiera_rwlock_init (&rwlock, "rwsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -219,7 +219,7 @@ TEST ("rwdeadlockrw")
}
TEST ("conditionops (compiletest only)")
TEST (conditionops (compiletest only))
{
lumiera_condition cond;
lumiera_condition_init (&cond, "conditionsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -235,7 +235,7 @@ TEST ("conditionops (compiletest only)")
}
TEST ("conditionsection")
TEST (conditionsection)
{
lumiera_condition cond;
lumiera_condition_init (&cond, "conditionsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -255,7 +255,7 @@ TEST ("conditionsection")
TEST ("conditionforgotunlock")
TEST (conditionforgotunlock)
{
lumiera_condition cond;
lumiera_condition_init (&cond, "conditionforgotunlock", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -270,7 +270,7 @@ TEST ("conditionforgotunlock")
TEST ("recconditionops (compiletest only)")
TEST (recconditionops (compiletest only))
{
lumiera_reccondition reccond;
lumiera_reccondition_init (&reccond, "recconditionsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -286,7 +286,7 @@ TEST ("recconditionops (compiletest only)")
}
TEST ("recconditionsection")
TEST (recconditionsection)
{
lumiera_reccondition reccond;
lumiera_reccondition_init (&reccond, "recconditionsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -305,7 +305,7 @@ TEST ("recconditionsection")
}
TEST ("recconditionforgotunlock")
TEST (recconditionforgotunlock)
{
lumiera_reccondition reccond;
lumiera_reccondition_init (&reccond, "recconditionforgotunlock", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -318,7 +318,7 @@ TEST ("recconditionforgotunlock")
lumiera_reccondition_destroy (&reccond, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
}
TEST ("chainedrecconditionsection")
TEST (chainedrecconditionsection)
{
lumiera_reccondition outer, inner;
lumiera_reccondition_init (&outer, "outer_recconditionsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
@ -336,7 +336,7 @@ TEST ("chainedrecconditionsection")
lumiera_reccondition_destroy (&inner, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
}
TEST ("nestedrecconditionsection")
TEST (nestedrecconditionsection)
{
lumiera_reccondition outer, inner;
lumiera_reccondition_init (&outer, "outer_recconditionsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);

View file

@ -45,7 +45,7 @@ dtor (void* o)
TESTS_BEGIN
TEST ("basic")
TEST (basic)
{
mpool mypool;
mpool_init (&mypool, sizeof(void*), 10, dtor);
@ -68,7 +68,7 @@ TEST ("basic")
}
TEST ("destroy")
TEST (destroy)
{
mpool mypool;
mpool_init (&mypool, sizeof(void*), 10, dtor);
@ -86,7 +86,7 @@ TEST ("destroy")
}
TEST ("clusters")
TEST (clusters)
{
mpool mypool;
mpool_init (&mypool, sizeof(void*), 2, dtor);
@ -107,7 +107,7 @@ TEST ("clusters")
}
TEST ("clusters_big")
TEST (clusters_big)
{
mpool mypool;
mpool_init (&mypool, sizeof(void*), 200, dtor);
@ -128,7 +128,7 @@ TEST ("clusters_big")
}
TEST ("alloc_free")
TEST (alloc_free)
{
mpool mypool;
mpool_init (&mypool, 24, 4, dtor);
@ -155,7 +155,7 @@ TEST ("alloc_free")
}
TEST ("alloc_free_big")
TEST (alloc_free_big)
{
mpool mypool;
mpool_init (&mypool, 24, 4, dtor);
@ -185,7 +185,7 @@ TEST ("alloc_free_big")
TEST ("reserve")
TEST (reserve)
{
}
@ -193,7 +193,7 @@ TEST ("reserve")
/*
benchmark mpool vs malloc, first only the allocation/free itself with some necessary llist ops
*/
TEST ("bench_mpool")
TEST (bench_mpool)
{
mpool mypool;
mpool_init (&mypool, sizeof(struct teststruct), 2000, NULL);
@ -222,7 +222,7 @@ TEST ("bench_mpool")
}
TEST ("bench_malloc")
TEST (bench_malloc)
{
mpool mypool;
mpool_init (&mypool, sizeof(llist), 2000, NULL);
@ -256,7 +256,7 @@ TEST ("bench_malloc")
- allocate list nodes which have 2 data members as payload
- there is a 25% chance at each alloc that the head of the list gets deleted
*/
TEST ("bench_mpool_sim")
TEST (bench_mpool_sim)
{
mpool mypool;
mpool_init (&mypool, sizeof(struct teststruct), 2000, NULL);
@ -298,7 +298,7 @@ TEST ("bench_mpool_sim")
}
TEST ("bench_malloc_sim")
TEST (bench_malloc_sim)
{
mpool mypool;
mpool_init (&mypool, sizeof(llist), 2000, NULL);

View file

@ -21,6 +21,7 @@
#include <time.h>
#include <stdlib.h>
#include <nobug.h>
#include "lib/psplay.h"
#include "tests/test.h"
@ -183,7 +184,7 @@ TEST ("basic")
TEST ("basic_insert_dump")
{
REQUIRE (argv[2]);
CHECK (argv[2]);
psplay splay_tree;
psplay_init (&splay_tree, cmp_fn, key_fn, delete_fn);
@ -195,7 +196,7 @@ TEST ("basic_insert_dump")
for (int i = 1; i <= end; ++i)
{
sprintf (key, "%d", i);
TRACE (TESTS, "insert %s", key);
ECHO ("insert %s", key);
psplay_insert (&splay_tree, (PSplaynode)testitem_new (key), 100);
}
@ -205,14 +206,14 @@ TEST ("basic_insert_dump")
for (int i = 1; i <= end; ++i)
{
sprintf (key, "%d", i);
TRACE (TESTS, "insert %s", key);
ECHO ("insert %s", key);
psplay_remove_key (&splay_tree, key);
psplay_dump (&splay_tree, stderr);
}
for (int i = end; i; --i)
{
sprintf (key, "%d", i);
TRACE (TESTS, "insert %s", key);
ECHO ("insert %s", key);
psplay_remove_key (&splay_tree, key);
psplay_dump (&splay_tree, stderr);
}
@ -287,7 +288,7 @@ TEST ("insert_find")
TEST ("basic_insert_splay")
{
REQUIRE (argv[2]);
CHECK (argv[2]);
psplay splay_tree;
psplay_init (&splay_tree, cmp_fn, key_fn, delete_fn);
@ -299,7 +300,7 @@ TEST ("basic_insert_splay")
for (int i = 1; i <= end; ++i)
{
sprintf (key, "%d", i);
TRACE (TESTS, "insert %s", key);
ECHO ("insert %s", key);
psplay_insert (&splay_tree, (PSplaynode)testitem_new (key), 100);
}
@ -316,7 +317,7 @@ TEST ("basic_insert_splay")
TEST ("basic_rand_insert_dump")
{
REQUIRE (argv[2]);
CHECK (argv[2]);
psplay splay_tree;
psplay_init (&splay_tree, cmp_fn, key_fn, delete_fn);
@ -341,7 +342,7 @@ TEST ("basic_rand_insert_dump")
TEST ("fast_insert")
{
REQUIRE (argv[2]);
CHECK (argv[2]);
psplay splay_tree;
psplay_init (&splay_tree, fcmp_fn, fkey_fn, fdelete_fn);
@ -365,14 +366,14 @@ TEST ("fast_insert")
TEST ("nonexistant")
{
REQUIRE (argv[2]);
CHECK (argv[2]);
}
TEST ("insert")
{
REQUIRE (argv[2]);
CHECK (argv[2]);
}
@ -380,7 +381,7 @@ TEST ("insert")
TEST ("insert_rand")
{
REQUIRE (argv[2]);
CHECK (argv[2]);
}
@ -388,7 +389,7 @@ TEST ("insert_rand")
TEST ("insert_fastcheck")
{
REQUIRE (argv[2]);
CHECK (argv[2]);
}
@ -406,16 +407,16 @@ TESTS_END
static int
cmp_fn (const void* a, const void* b)
{
REQUIRE (a);
REQUIRE (b);
CHECK (a);
CHECK (b);
return strcmp (a, b);
}
static const void*
key_fn (const PSplaynode node)
{
REQUIRE (node);
REQUIRE (((TestItem)node)->key);
CHECK (node);
CHECK (((TestItem)node)->key);
return ((TestItem)node)->key;
}
@ -423,7 +424,7 @@ key_fn (const PSplaynode node)
static void
delete_fn (PSplaynode node)
{
REQUIRE (node);
CHECK (node);
testitem_delete ((TestItem) node);
}

View file

@ -24,13 +24,13 @@
TESTS_BEGIN
TEST ("allocation0")
TEST (allocation0)
{
lumiera_malloc (0);
NOTREACHED();
}
TEST ("allocation1024")
TEST (allocation1024)
{
void* data[1024];
for (int i = 0; i < 1024; ++i)
@ -44,7 +44,7 @@ TEST ("allocation1024")
}
}
TEST ("allocationtoobig")
TEST (allocationtoobig)
{
struct rlimit rl;
rl.rlim_cur = 100*1024*1024;
@ -54,21 +54,16 @@ TEST ("allocationtoobig")
NOTREACHED();
}
TEST ("streq")
TEST (streq)
{
if (!lumiera_streq ("foo", "foo"))
LUMIERA_DIE (TEST);
if (!lumiera_streq (NULL, NULL))
LUMIERA_DIE (TEST);
if (!!lumiera_streq (NULL, "foo"))
LUMIERA_DIE (TEST);
if (!!lumiera_streq ("foo", NULL))
LUMIERA_DIE (TEST);
if (!!lumiera_streq ("foo", "bar"))
LUMIERA_DIE (TEST);
CHECK (lumiera_streq ("foo", "foo"));
CHECK (lumiera_streq (NULL, NULL));
CHECK (!lumiera_streq (NULL, "foo"));
CHECK (!lumiera_streq ("foo", NULL));
CHECK (!lumiera_streq ("foo", "bar"));
}
TEST ("tmpbuf")
TEST (tmpbuf)
{
for (int i = 0; i < 256; ++i)
{
@ -82,21 +77,21 @@ TEST ("tmpbuf")
}
TEST ("tr0")
TEST (tr0)
{
char* r = lumiera_tmpbuf_tr (argv[2], "abcdeABCDE0123456789", "ABCDEABCDE0123456789", NULL);
printf("%s\n", r?r:"failed");
}
TEST ("tr")
TEST (tr)
{
char* r = lumiera_tmpbuf_tr (argv[2], "abcdeABCDE0123456789", "ABCDEABCDE0123456789", "");
printf("%s\n", r?r:"failed");
}
TEST ("tr_")
TEST (tr_)
{
printf("%s\n", lumiera_tmpbuf_tr (argv[2], "abcdeABCDE0123456789", "ABCDEABCDE0123456789", "_"));
}

View file

@ -23,6 +23,7 @@
#include "tests/test.h"
#include <sys/time.h>
#include <nobug.h>
typedef struct item {
int key;
@ -60,36 +61,36 @@ TESTS_BEGIN
* int slist_is_before_after( const_SList list, const_SList before, const_SList after )
*/
TEST( "basic" ) {
TEST (basic) {
SLIST_AUTO( listX );
slist listY;
SLIST_AUTO( nodeA );
SLIST_AUTO( nodeB );
printf( "%d\n", slist_is_end( &listX, &listX ) );
ECHO ("%d", slist_is_end( &listX, &listX ) );
slist_init( &listY );
printf( "%d\n", slist_is_empty( &listY ) );
ECHO ("%d", slist_is_empty( &listY ) );
slist_insert( &listX, &nodeA );
printf( "%d\n", slist_is_empty( &listX ) );
printf( "%d\n", slist_is_single( &listX ) );
printf( "%d\n", slist_is_head( &listX, &nodeA ) );
printf( "%d\n", slist_is_end( &listX, &nodeA ) );
printf( "%d\n", slist_is_member( &listX, &nodeA ) );
printf( "%d\n", slist_is_member( &listX, &nodeB ) );
ECHO ("%d", slist_is_empty( &listX ) );
ECHO ("%d", slist_is_single( &listX ) );
ECHO ("%d", slist_is_head( &listX, &nodeA ) );
ECHO ("%d", slist_is_end( &listX, &nodeA ) );
ECHO ("%d", slist_is_member( &listX, &nodeA ) );
ECHO ("%d", slist_is_member( &listX, &nodeB ) );
slist_insert( &nodeA, &nodeB );
printf( "%d\n", slist_is_empty( &listX ) );
printf( "%d\n", slist_is_single( &listX ) );
printf( "%d\n", slist_is_head( &listX, &nodeB ) );
printf( "%d\n", slist_is_end( &listX, &nodeB ) );
printf( "%d\n", slist_is_member( &listX, &nodeB ) );
ECHO ("%d", slist_is_empty( &listX ) );
ECHO ("%d", slist_is_single( &listX ) );
ECHO ("%d", slist_is_head( &listX, &nodeB ) );
ECHO ("%d", slist_is_end( &listX, &nodeB ) );
ECHO ("%d", slist_is_member( &listX, &nodeB ) );
printf( "%d\n", slist_is_before_after( &listX, &nodeA, &nodeB ) );
printf( "%d\n", slist_is_before_after( &listX, &nodeB, &nodeA ) );
ECHO ("%d", slist_is_before_after( &listX, &nodeA, &nodeB ) );
ECHO ("%d", slist_is_before_after( &listX, &nodeB, &nodeA ) );
}
@ -102,7 +103,7 @@ TEST( "basic" ) {
* SList slist_unlink( SList list, SList node )
*/
TEST( "insert_delete" ) {
TEST (insert_delete) {
SLIST_AUTO( listX );
SLIST_AUTO( nodeA );
@ -112,34 +113,34 @@ TEST( "insert_delete" ) {
slist_insert_head( &listX, &nodeA );
slist_insert( &nodeA, &nodeB );
slist_insert( &nodeB, &nodeC );
printf( "%d\n", slist_next( &listX ) == &nodeA );
printf( "%d\n", slist_next( &nodeA ) == &nodeB );
printf( "%d\n", slist_next( &nodeB ) == &nodeC );
printf( "%d\n", slist_next( &nodeC ) == &listX );
ECHO ("%d", slist_next( &listX ) == &nodeA );
ECHO ("%d", slist_next( &nodeA ) == &nodeB );
ECHO ("%d", slist_next( &nodeB ) == &nodeC );
ECHO ("%d", slist_next( &nodeC ) == &listX );
slist_unlink( &listX, &nodeA );
printf( "%d\n", slist_next( &listX ) == &nodeB );
ECHO ("%d", slist_next( &listX ) == &nodeB );
slist_insert( &listX, &nodeA );
printf( "%d\n", slist_next( &listX ) == &nodeA );
ECHO ("%d", slist_next( &listX ) == &nodeA );
SLIST_AUTO( listY );
slist_insert_list( &listY, &listX );
printf( "%d\n", slist_is_empty( &listX ) );
printf( "%d\n", slist_next( &listY ) == &nodeA );
printf( "%d\n", slist_next( &nodeA ) == &nodeB );
printf( "%d\n", slist_next( &nodeB ) == &nodeC );
printf( "%d\n", slist_next( &nodeC ) == &listY );
ECHO ("%d", slist_is_empty( &listX ) );
ECHO ("%d", slist_next( &listY ) == &nodeA );
ECHO ("%d", slist_next( &nodeA ) == &nodeB );
ECHO ("%d", slist_next( &nodeB ) == &nodeC );
ECHO ("%d", slist_next( &nodeC ) == &listY );
slist_insert_range( &listX, &nodeA, &nodeB );
printf( "%d\n", slist_next( &listX ) == &nodeA );
printf( "%d\n", slist_next( &nodeA ) == &nodeB );
printf( "%d\n", slist_next( &nodeB ) == &listX );
ECHO ("%d", slist_next( &listX ) == &nodeA );
ECHO ("%d", slist_next( &nodeA ) == &nodeB );
ECHO ("%d", slist_next( &nodeB ) == &listX );
printf( "%d\n", slist_is_single( &listY ) );
printf( "%d\n", slist_next( &listY ) == &nodeC );
printf( "%d\n", slist_next( &nodeC ) == &listY );
ECHO ("%d", slist_is_single( &listY ) );
ECHO ("%d", slist_next( &listY ) == &nodeC );
ECHO ("%d", slist_next( &nodeC ) == &listY );
}
@ -152,7 +153,7 @@ TEST( "insert_delete" ) {
* void slist_forward( SList_ref node )
*/
TEST( "movement" ) {
TEST (movement) {
SLIST_AUTO( listX );
SLIST_AUTO( nodeA );
@ -163,25 +164,25 @@ TEST( "movement" ) {
slist_insert( &nodeA, &nodeB );
slist_insert( &nodeB, &nodeC );
printf( "%d\n", slist_next( &listX ) == &nodeA );
printf( "%d\n", slist_next( &nodeA ) == &nodeB );
printf( "%d\n", slist_next( &nodeB ) == &nodeC );
printf( "%d\n", slist_next( &nodeC ) == &listX );
ECHO ("%d", slist_next( &listX ) == &nodeA );
ECHO ("%d", slist_next( &nodeA ) == &nodeB );
ECHO ("%d", slist_next( &nodeB ) == &nodeC );
ECHO ("%d", slist_next( &nodeC ) == &listX );
printf( "%d\n", slist_prev( &listX, &listX ) == &nodeC );
printf( "%d\n", slist_prev( &listX, &nodeC ) == &nodeB );
printf( "%d\n", slist_prev( &listX, &nodeB ) == &nodeA );
printf( "%d\n", slist_prev( &listX, &nodeA ) == &listX );
ECHO ("%d", slist_prev( &listX, &listX ) == &nodeC );
ECHO ("%d", slist_prev( &listX, &nodeC ) == &nodeB );
ECHO ("%d", slist_prev( &listX, &nodeB ) == &nodeA );
ECHO ("%d", slist_prev( &listX, &nodeA ) == &listX );
slist_advance( &listX, &nodeA );
printf( "%d\n", slist_next( &listX ) == &nodeB );
printf( "%d\n", slist_next( &nodeB ) == &nodeA );
printf( "%d\n", slist_next( &nodeA ) == &nodeC );
printf( "%d\n", slist_next( &nodeC ) == &listX );
ECHO ("%d", slist_next( &listX ) == &nodeB );
ECHO ("%d", slist_next( &nodeB ) == &nodeA );
ECHO ("%d", slist_next( &nodeA ) == &nodeC );
ECHO ("%d", slist_next( &nodeC ) == &listX );
SList node = &listX;
slist_forward( &node );
printf( "%d\n", node == &nodeB );
ECHO ("%d", node == &nodeB );
}
@ -193,7 +194,7 @@ TEST( "movement" ) {
* SLIST_WHILE_HEAD( list, head )
*/
TEST( "enumerations" ) {
TEST (enumerations) {
SLIST_AUTO( list );
@ -214,28 +215,28 @@ TEST( "enumerations" ) {
SLIST_FOREACH ( &list, node ) {
item_t* item = ( item_t* ) SLIST_TO_STRUCTP( node, item_t, list );
printf( "%c ", item -> key );
ECHO ("%c", item -> key );
}
printf( ".\n" );
ECHO ("," );
printf( "---\n" );
ECHO ("---" );
SLIST_FORRANGE ( &nodeB.list, &nodeD.list, node ) {
item_t* item = ( item_t* ) SLIST_TO_STRUCTP( node, item_t, list );
printf( "%c ", item -> key );
ECHO ("%c", item -> key );
}
printf( ".\n" );
ECHO ("," );
printf( "---\n" );
ECHO ("---" );
SLIST_WHILE_HEAD ( &list, head ) {
item_t* item = ( item_t* ) SLIST_TO_STRUCTP( head, item_t, list );
printf( "%c ", item -> key );
ECHO ("%c ", item -> key );
slist_unlink( &list, head );
}
printf( ".\n" );
ECHO ("," );
printf( "%d\n", slist_is_empty( &list ) );
ECHO ("%d", slist_is_empty( &list ) );
}
@ -246,7 +247,7 @@ TEST( "enumerations" ) {
* SList slist_get_nth_stop( SList list, int n, const_SList stop )
*/
TEST( "count" ) {
TEST (count) {
SLIST_AUTO( list );
SLIST_AUTO( nodeA );
@ -257,9 +258,9 @@ TEST( "count" ) {
slist_insert( &nodeA, &nodeB );
slist_insert( &nodeB, &nodeC );
printf( "%u\n", slist_count( &list ) );
printf( "%d\n", slist_get_nth( &list, 3 ) == &nodeC );
printf( "%d\n", slist_get_nth_stop( &list, 3, &nodeC ) == NULL );
ECHO ("%u", slist_count( &list ) );
ECHO ("%d", slist_get_nth( &list, 3 ) == &nodeC );
ECHO ("%d", slist_get_nth_stop( &list, 3, &nodeC ) == NULL );
}
@ -268,7 +269,7 @@ TEST( "count" ) {
* SList slist_sort( SList list, slist_cmpfn cmp )
*/
TEST( "sort" ) {
TEST (sort) {
srand( time( NULL ) );
@ -315,7 +316,7 @@ TEST( "sort" ) {
* SList slist_sfind( const_SList list, const_SList pattern, slist_cmpfn cmp )
*/
TEST( "search" ) {
TEST (search) {
SLIST_AUTO( list );
@ -337,12 +338,12 @@ TEST( "search" ) {
nodeX.key = 'C';
printf( "%d\n", slist_find( &list, &nodeX.list, cmp ) == &nodeC.list );
printf( "%d\n", slist_ufind( &list, &nodeX.list, cmp ) == &nodeC.list );
printf( "%d\n", slist_next( &nodeC.list ) == &nodeA.list );
ECHO ("%d", slist_find( &list, &nodeX.list, cmp ) == &nodeC.list );
ECHO ("%d", slist_ufind( &list, &nodeX.list, cmp ) == &nodeC.list );
ECHO ("%d", slist_next( &nodeC.list ) == &nodeA.list );
nodeX.key = 'A';
printf( "%d\n", slist_sfind( &list, &nodeX.list, cmp ) == NULL );
ECHO ("%d", slist_sfind( &list, &nodeX.list, cmp ) == NULL );
}

View file

@ -1,8 +1,8 @@
/*
test.h - macros for running tests
Copyright (C) CinelerraCV
2008, Christian Thaeter <ct@pipapo.org>
Copyright (C)
2008, 2009, 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
@ -22,40 +22,39 @@
#ifndef TEST_H
#define TEST_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <nobug.h>
#include "lib/error.h"
#include <stdio.h>
NOBUG_DEFINE_FLAG (TESTS);
LUMIERA_ERROR_DEFINE (TEST, "test error");
NOBUG_DEFINE_FLAG_LIMIT(TEST, LOG_DEBUG);
#define TESTS_BEGIN \
int \
main (int argc, const char** argv) \
{ \
NOBUG_INIT; \
NOBUG_INIT_FLAG (TESTS); \
NOBUG_INIT_FLAG (TEST); \
unsigned testcnt=0; \
int ret = 0; \
\
if (argc == 1) \
{ \
fprintf (stderr, "missing argument\n"); \
return 1; \
}
fprintf (stderr, "supported tests:\n");
#define TEST(name) \
else if (!strcmp(argv[1], name))
if (argc == 1) \
fprintf (stderr, " "#name"\n"); \
else if (!strcmp(argv[1], #name) && ++testcnt)
#define PLANNED_TEST(name) \
if (argc == 1) \
fprintf (stderr, " "#name" (planned)\n"); \
else if (!++testcnt)
#define TESTS_END \
else \
{ \
fprintf (stderr, "unknown test\n"); \
return 1; \
} \
\
return 0; \
#define TESTS_END \
if (!testcnt && argc !=1) \
fprintf (stderr,"no such test: %s\n", argv[1]); \
return ret; \
}