uORB: Unit test fix

The latency_test used to pass an object pointer as argv which
won't work in the posix port because it expects argv to be a
null terminated array of character pointers (which it makes a
copy of).

The test was refactored to use a singleton pattern and avoid
having to pass the object pointer to the thread.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-05-06 13:19:52 -07:00
parent 872e1ebda0
commit 7ebee7ca6f
3 changed files with 26 additions and 17 deletions
+9 -7
View File
@@ -36,6 +36,12 @@
#include <px4_config.h>
#include <px4_time.h>
uORBTest::UnitTest &uORBTest::UnitTest::instance()
{
static uORBTest::UnitTest t;
return t;
}
int uORBTest::UnitTest::pubsublatency_main(void)
{
/* poll on test topic and output latency */
@@ -276,12 +282,8 @@ int uORBTest::UnitTest::test_note(const char *fmt, ...)
return OK;
}
int uORBTest::UnitTest::pubsubtest_threadEntry( char* const* data )
int uORBTest::UnitTest::pubsubtest_threadEntry(char* const argv[])
{
uORBTest::UnitTest* t = (uORBTest::UnitTest*) data;
if( data != nullptr )
{
return t->pubsublatency_main();
}
return uORB::ERROR;
uORBTest::UnitTest &t = uORBTest::UnitTest::instance();
return t.pubsublatency_main();
}