app/system/uorb: modify unit test to support data persist
Signed-off-by: jihandong <jihandong@xiaomi.com>
This commit is contained in:
parent
874ed7654d
commit
2b8bfc5be7
@ -183,6 +183,7 @@ static int latency_test(bool print)
|
|||||||
FAR char *const args[1];
|
FAR char *const args[1];
|
||||||
struct orb_test_medium_s sample;
|
struct orb_test_medium_s sample;
|
||||||
int pubsub_task;
|
int pubsub_task;
|
||||||
|
int instance = 0;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
test_note("---------------- LATENCY TEST ------------------");
|
test_note("---------------- LATENCY TEST ------------------");
|
||||||
@ -190,7 +191,8 @@ static int latency_test(bool print)
|
|||||||
sample.val = 308;
|
sample.val = 308;
|
||||||
sample.timestamp = orb_absolute_time();
|
sample.timestamp = orb_absolute_time();
|
||||||
|
|
||||||
fd = orb_advertise(ORB_ID(orb_test_medium), &sample);
|
fd = orb_advertise_multi_queue_persist(ORB_ID(orb_test_medium),
|
||||||
|
&sample, &instance, 1);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
return test_fail("orb_advertise failed (%i)", errno);
|
return test_fail("orb_advertise failed (%i)", errno);
|
||||||
@ -239,6 +241,7 @@ static int test_single(void)
|
|||||||
{
|
{
|
||||||
struct orb_test_s sample;
|
struct orb_test_s sample;
|
||||||
struct orb_test_s sub_sample;
|
struct orb_test_s sub_sample;
|
||||||
|
int instance = 0;
|
||||||
bool updated;
|
bool updated;
|
||||||
int afd;
|
int afd;
|
||||||
int sfd;
|
int sfd;
|
||||||
@ -250,7 +253,8 @@ static int test_single(void)
|
|||||||
|
|
||||||
sample.val = 0;
|
sample.val = 0;
|
||||||
|
|
||||||
afd = orb_advertise(ORB_ID(orb_test), &sample);
|
afd = orb_advertise_multi_queue_persist(ORB_ID(orb_test),
|
||||||
|
&sample, &instance, 1);
|
||||||
if (afd < 0)
|
if (afd < 0)
|
||||||
{
|
{
|
||||||
return test_fail("advertise failed: %d", errno);
|
return test_fail("advertise failed: %d", errno);
|
||||||
@ -361,7 +365,8 @@ static int test_multi_inst10(void)
|
|||||||
|
|
||||||
for (i = 0; i < max_inst; i++)
|
for (i = 0; i < max_inst; i++)
|
||||||
{
|
{
|
||||||
afd[i] = orb_advertise_multi_queue(ORB_ID(orb_test), NULL, &i, 1);
|
afd[i] = orb_advertise_multi_queue_persist(ORB_ID(orb_test),
|
||||||
|
NULL, &i, 1);
|
||||||
if (OK != orb_exists(ORB_ID(orb_test), i))
|
if (OK != orb_exists(ORB_ID(orb_test), i))
|
||||||
{
|
{
|
||||||
return test_fail("sub %d advertise failed", i);
|
return test_fail("sub %d advertise failed", i);
|
||||||
@ -438,14 +443,16 @@ static int test_multi(int *afds, int *sfds)
|
|||||||
|
|
||||||
test_note("try multi-topic support");
|
test_note("try multi-topic support");
|
||||||
|
|
||||||
afds[0] = orb_advertise_multi(ORB_ID(orb_multitest), &sample, &instance0);
|
afds[0] = orb_advertise_multi_queue_persist(ORB_ID(orb_multitest),
|
||||||
|
&sample, &instance0, 1);
|
||||||
|
|
||||||
if (instance0 != 0)
|
if (instance0 != 0)
|
||||||
{
|
{
|
||||||
return test_fail("mult. id0: %d", instance0);
|
return test_fail("mult. id0: %d", instance0);
|
||||||
}
|
}
|
||||||
|
|
||||||
afds[1] = orb_advertise_multi(ORB_ID(orb_multitest), &sample, &instance1);
|
afds[1] = orb_advertise_multi_queue_persist(ORB_ID(orb_multitest),
|
||||||
|
&sample, &instance1, 1);
|
||||||
|
|
||||||
if (instance1 != 1)
|
if (instance1 != 1)
|
||||||
{
|
{
|
||||||
@ -524,14 +531,16 @@ static int test_multi_reversed(int *afds, int *sfds)
|
|||||||
return test_fail("sub. id2: ret: %d", sfds[2]);
|
return test_fail("sub. id2: ret: %d", sfds[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
afds[2] = orb_advertise_multi(ORB_ID(orb_multitest), &sample, &instance2);
|
afds[2] = orb_advertise_multi_queue_persist(ORB_ID(orb_multitest),
|
||||||
|
&sample, &instance2, 1);
|
||||||
|
|
||||||
if (instance2 != 2)
|
if (instance2 != 2)
|
||||||
{
|
{
|
||||||
return test_fail("mult. id2: %d", instance2);
|
return test_fail("mult. id2: %d", instance2);
|
||||||
}
|
}
|
||||||
|
|
||||||
afds[3] = orb_advertise_multi(ORB_ID(orb_multitest), &sample, &instance3);
|
afds[3] = orb_advertise_multi_queue_persist(ORB_ID(orb_multitest),
|
||||||
|
&sample, &instance3, 1);
|
||||||
|
|
||||||
if (instance3 != 3)
|
if (instance3 != 3)
|
||||||
{
|
{
|
||||||
@ -615,8 +624,8 @@ static int pub_test_multi2_entry(int argc, char *argv[])
|
|||||||
memset(&data_topic, '\0', sizeof(data_topic));
|
memset(&data_topic, '\0', sizeof(data_topic));
|
||||||
for (i = 0; i < num_instances; ++i)
|
for (i = 0; i < num_instances; ++i)
|
||||||
{
|
{
|
||||||
orb_pub[i] = orb_advertise_multi(ORB_ID(orb_test_medium_multi),
|
orb_pub[i] = orb_advertise_multi_queue_persist(
|
||||||
&data_topic, &i);
|
ORB_ID(orb_test_medium_multi), &data_topic, &i, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(100 * 1000);
|
usleep(100 * 1000);
|
||||||
@ -728,6 +737,7 @@ int test_queue(void)
|
|||||||
struct orb_test_medium_s sample;
|
struct orb_test_medium_s sample;
|
||||||
struct orb_test_medium_s sub_sample;
|
struct orb_test_medium_s sub_sample;
|
||||||
bool updated;
|
bool updated;
|
||||||
|
int instance = 0;
|
||||||
int ptopic;
|
int ptopic;
|
||||||
int sfd;
|
int sfd;
|
||||||
int i;
|
int i;
|
||||||
@ -755,8 +765,8 @@ int test_queue(void)
|
|||||||
}
|
}
|
||||||
while (updated);
|
while (updated);
|
||||||
|
|
||||||
ptopic = orb_advertise_queue(ORB_ID(orb_test_medium_queue),
|
ptopic = orb_advertise_multi_queue_persist(
|
||||||
&sample, queue_size);
|
ORB_ID(orb_test_medium_queue), &sample, &instance, queue_size);
|
||||||
if (ptopic < 0)
|
if (ptopic < 0)
|
||||||
{
|
{
|
||||||
return test_fail("advertise failed: %d", errno);
|
return test_fail("advertise failed: %d", errno);
|
||||||
@ -872,11 +882,12 @@ static int pub_test_queue_entry(int argc, char *argv[])
|
|||||||
struct orb_test_medium_s t;
|
struct orb_test_medium_s t;
|
||||||
int num_messages = 20 * queue_size;
|
int num_messages = 20 * queue_size;
|
||||||
int message_counter = 0;
|
int message_counter = 0;
|
||||||
|
int instance = 0;
|
||||||
int ptopic;
|
int ptopic;
|
||||||
|
|
||||||
memset(&t, '\0', sizeof(t));
|
memset(&t, '\0', sizeof(t));
|
||||||
ptopic = orb_advertise_queue(ORB_ID(orb_test_medium_queue_poll),
|
ptopic = orb_advertise_multi_queue_persist(
|
||||||
&t, queue_size);
|
ORB_ID(orb_test_medium_queue_poll), &t, &instance, queue_size);
|
||||||
if (ptopic < 0)
|
if (ptopic < 0)
|
||||||
{
|
{
|
||||||
g_thread_should_exit = true;
|
g_thread_should_exit = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user