27 #include <blackboard/local.h>
28 #include <blackboard/remote.h>
29 #include <blackboard/exceptions.h>
30 #include <blackboard/bbconfig.h>
32 #include <interfaces/TestInterface.h>
34 #include <core/threading/thread.h>
35 #include <core/exceptions/system.h>
36 #include <utils/time/time.h>
46 using namespace fawkes;
52 signal_handler(
int signum)
59 #define BLACKBOARD_MEMSIZE 2 * 1024 * 1024
60 #define BLACKBOARD_MAGIC_TOKEN "FawkesBlackBoard"
63 main(
int argc,
char **argv)
68 signal(SIGINT, signal_handler);
77 cout <<
"Opening interfaces.. " << flush;
80 cout <<
"success" << endl;
82 cout <<
"failed! Aborting" << endl;
87 cout <<
"Writing initial value ("
88 << TestInterface::TEST_CONSTANT <<
") into interface as TestInt" << endl;
93 cout <<
"BUG: caught write denied exception" << endl;
97 cout <<
"Reading value from reader interface.. " << flush;
100 if ( val == TestInterface::TEST_CONSTANT ) {
101 cout <<
" success, value is " << ti_reader->
test_int() <<
" as expected" << endl;
103 cout <<
" failure, value is " << ti_reader->
test_int() <<
", expected "
104 << TestInterface::TEST_CONSTANT << endl;
107 printf(
"Reader instance serial: %u\n", ti_reader->
serial());
109 cout <<
"Harnessing message queues by excessively sending messages" << endl
110 <<
"Press Ctrl-C to stop testing. No output means everything is fine" << endl;
112 int expval = ti_reader->
test_int() + 1;
115 printf(
"Sent with message ID %u\n", msgid);
118 cout <<
"Error, more than one message! flushing." << endl;
127 printf(
"Received message of ID %u, Message improperly detected to be a SetTestStringMessage\n", msg->
id());
131 printf(
"Received message with ID %u (enqueue time: %s)\n", m2->
id(),
137 cout <<
"BUG: caught write denied exception" << endl;
142 cout <<
"Illegal message '" << ti_writer->
msgq_first()->
type() <<
"' type received" << endl;
150 if ( val == expval ) {
153 cout <<
" failure, value is " << ti_reader->
test_int() <<
", expected "
157 printf(
"No message in queue, if network test this means the message was dropped\n");
163 bb->
close(ti_reader);
164 bb->
close(ti_writer);
168 cout <<
"Tests done" << endl;
170 Thread::destroy_main();