Browse Source

uorb tests: move orb metadata struct definition into cpp file

If they're in the header and the header is used in multiple .cpp, there
are multiple definitions. Oddly it did not lead to an error, but there
were multiple structs of the same topic but with different adresses.
This lead to a metadata mismatch, when running eg:
uorb_tests
uorb_tests latency_test
sbg
Beat Küng 8 years ago committed by Julian Oes
parent
commit
76733ce54b
  1. 15
      src/modules/uORB/uORB_tests/uORBTest_UnitTest.cpp
  2. 23
      src/modules/uORB/uORB_tests/uORBTest_UnitTest.hpp
  3. 2
      src/modules/uORB/uORB_tests/uORB_tests_main.cpp

15
src/modules/uORB/uORB_tests/uORBTest_UnitTest.cpp

@ -39,6 +39,21 @@ @@ -39,6 +39,21 @@
#include <errno.h>
#include <poll.h>
ORB_DEFINE(orb_test, struct orb_test, sizeof(orb_test), "ORB_TEST:int val;hrt_abstime time;");
ORB_DEFINE(orb_multitest, struct orb_test, sizeof(orb_test), "ORB_MULTITEST:int val;hrt_abstime time;");
ORB_DEFINE(orb_test_medium, struct orb_test_medium, sizeof(orb_test_medium),
"ORB_TEST_MEDIUM:int val;hrt_abstime time;char[64] junk;");
ORB_DEFINE(orb_test_medium_multi, struct orb_test_medium, sizeof(orb_test_medium),
"ORB_TEST_MEDIUM_MULTI:int val;hrt_abstime time;char[64] junk;");
ORB_DEFINE(orb_test_medium_queue, struct orb_test_medium, sizeof(orb_test_medium),
"ORB_TEST_MEDIUM_MULTI:int val;hrt_abstime time;char[64] junk;");
ORB_DEFINE(orb_test_medium_queue_poll, struct orb_test_medium, sizeof(orb_test_medium),
"ORB_TEST_MEDIUM_MULTI:int val;hrt_abstime time;char[64] junk;");
ORB_DEFINE(orb_test_large, struct orb_test_large, sizeof(orb_test_large),
"ORB_TEST_LARGE:int val;hrt_abstime time;char[512] junk;");
uORBTest::UnitTest &uORBTest::UnitTest::instance()
{
static uORBTest::UnitTest t;

23
src/modules/uORB/uORB_tests/uORBTest_UnitTest.hpp

@ -41,8 +41,8 @@ struct orb_test { @@ -41,8 +41,8 @@ struct orb_test {
int val;
hrt_abstime time;
};
ORB_DEFINE(orb_test, struct orb_test, sizeof(orb_test), "ORB_TEST:int val;hrt_abstime time;");
ORB_DEFINE(orb_multitest, struct orb_test, sizeof(orb_test), "ORB_MULTITEST:int val;hrt_abstime time;");
ORB_DECLARE(orb_test);
ORB_DECLARE(orb_multitest);
struct orb_test_medium {
@ -50,22 +50,17 @@ struct orb_test_medium { @@ -50,22 +50,17 @@ struct orb_test_medium {
hrt_abstime time;
char junk[64];
};
ORB_DEFINE(orb_test_medium, struct orb_test_medium, sizeof(orb_test_medium),
"ORB_TEST_MEDIUM:int val;hrt_abstime time;char[64] junk;");
ORB_DEFINE(orb_test_medium_multi, struct orb_test_medium, sizeof(orb_test_medium),
"ORB_TEST_MEDIUM_MULTI:int val;hrt_abstime time;char[64] junk;");
ORB_DEFINE(orb_test_medium_queue, struct orb_test_medium, sizeof(orb_test_medium),
"ORB_TEST_MEDIUM_MULTI:int val;hrt_abstime time;char[64] junk;");
ORB_DEFINE(orb_test_medium_queue_poll, struct orb_test_medium, sizeof(orb_test_medium),
"ORB_TEST_MEDIUM_MULTI:int val;hrt_abstime time;char[64] junk;");
ORB_DECLARE(orb_test_medium);
ORB_DECLARE(orb_test_medium_multi);
ORB_DECLARE(orb_test_medium_queue);
ORB_DECLARE(orb_test_medium_queue_poll);
struct orb_test_large {
int val;
hrt_abstime time;
char junk[512];
};
ORB_DEFINE(orb_test_large, struct orb_test_large, sizeof(orb_test_large),
"ORB_TEST_LARGE:int val;hrt_abstime time;char[512] junk;");
ORB_DECLARE(orb_test_large);
namespace uORBTest
@ -133,6 +128,10 @@ int uORBTest::UnitTest::latency_test(orb_id_t T, bool print) @@ -133,6 +128,10 @@ int uORBTest::UnitTest::latency_test(orb_id_t T, bool print)
orb_advert_t pfd0 = orb_advertise(T, &t);
if (pfd0 == nullptr) {
return test_fail("orb_advertise failed (%i)", errno);
}
char *const args[1] = { NULL };
pubsubtest_print = print;

2
src/modules/uORB/uORB_tests/uORB_tests_main.cpp

@ -44,7 +44,7 @@ extern "C" { __EXPORT int uorb_tests_main(int argc, char *argv[]); } @@ -44,7 +44,7 @@ extern "C" { __EXPORT int uorb_tests_main(int argc, char *argv[]); }
static void usage()
{
PX4_INFO("Usage: uorb_test 'latency_test'");
PX4_INFO("Usage: uorb_tests [latency_test]");
}
int

Loading…
Cancel
Save