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
+3 -5
View File
@@ -90,7 +90,7 @@ uorb_main(int argc, char *argv[])
*/
if (!strcmp(argv[1], "test"))
{
uORBTest::UnitTest t;
uORBTest::UnitTest &t = uORBTest::UnitTest::instance();
return t.test();
}
@@ -99,7 +99,7 @@ uorb_main(int argc, char *argv[])
*/
if (!strcmp(argv[1], "latency_test")) {
uORBTest::UnitTest t;
uORBTest::UnitTest &t = uORBTest::UnitTest::instance();
if (argc > 2 && !strcmp(argv[2], "medium")) {
return t.latency_test<struct orb_test_medium>(ORB_ID(orb_test_medium), true);
} else if (argc > 2 && !strcmp(argv[2], "large")) {
@@ -118,7 +118,5 @@ uorb_main(int argc, char *argv[])
}
usage();
errx(-EINVAL, "unrecognized command, try 'start', 'test', 'latency_test' or 'status'");
return -EINVAL;
}