diff --git a/test/cht/Makefile.am b/test/cht/Makefile.am index 2c88e42..78ca860 100644 --- a/test/cht/Makefile.am +++ b/test/cht/Makefile.am @@ -1,3 +1,4 @@ +TESTS=./run LDADD=-lconfuse $(top_builddir)/src/apps/cht/libcht.a $(top_builddir)/src/2pc/lib2pc.a $(top_builddir)/src/libdfa/libdfa.a \ $(top_builddir)/src/lladd/liblladd.a $(top_builddir)/src/pbl/libpbl.a $(top_builddir)/src/libdfa/librw.a bin_PROGRAMS=simple cht_server client coordinator subordinate diff --git a/test/cht/client.c b/test/cht/client.c index 350cbcb..7c3670f 100644 --- a/test/cht/client.c +++ b/test/cht/client.c @@ -37,13 +37,14 @@ int main(int argc, char ** argv) { unsigned int newLen = sizeof(int); int ret = cHtLookup(xid, cht_client, new_ht, &newOne, sizeof(int), &newTwo, &newLen); xid++; - printf("lookup returned %d (%d->%d)\n", ret, newOne, newTwo); + //printf("lookup returned %d (%d->%d)\n", ret, newOne, newTwo); + assert(ret); assert(newOne == one); assert(newTwo == two); assert(newLen == sizeof(int)); } - // shutdown main thread somehow... + /** @todo devise a way to cleanly shut a CHT down. */ // dfa_free(cht_client); } diff --git a/test/cht/prepend b/test/cht/prepend new file mode 100755 index 0000000..a195c3a --- /dev/null +++ b/test/cht/prepend @@ -0,0 +1,7 @@ +#! /usr/bin/perl -w + +use strict; +$| = 1; +while(my $line = ) { + print("$ARGV[0]:\t$line"); +} diff --git a/test/cht/run b/test/cht/run new file mode 100755 index 0000000..52199aa --- /dev/null +++ b/test/cht/run @@ -0,0 +1,40 @@ +#!/usr/bin/perl -w +use strict; + +print("\n\nRunning Cluster Hash Table self test.\n"); +print("-------------------------------------\n"); + +mkdir 'coord'; +mkdir 'sub0'; +mkdir 'sub1'; +mkdir 'sub2'; +mkdir 'sub3'; + +chdir 'coord'; +system ("rm *.txt"); +system ("../coordinator ../cluster.conf > /dev/null &"); +chdir '..'; +chdir 'sub0'; +system ("rm *.txt"); +system ("../subordinate 0 ../cluster.conf > /dev/null &"); +chdir '..'; +chdir 'sub1'; +system ("rm *.txt"); +system ("../subordinate 1 ../cluster.conf > /dev/null &"); +chdir '..'; +chdir 'sub2'; +system ("rm *.txt"); +system ("../subordinate 2 ../cluster.conf > /dev/null &"); +chdir '..'; +chdir 'sub3'; +system ("rm *.txt"); +system ("../subordinate 3 ../cluster.conf > /dev/null &"); +chdir '..'; + +system ("rm *.txt"); +my $ret = system ("./client 2>&1"); + +`killall coordinator`; +`killall subordinate`; + +exit $ret;