Skip to content

Commit

Permalink
systemcmds: dataman: Check for errors in tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
zehortigoza committed Apr 5, 2017
1 parent 467cdf3 commit 5dbf45f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/systemcmds/tests/test_dataman.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include "dataman/dataman.h"

static px4_sem_t *sems;
static bool *task_returned_error;
int test_dataman(int argc, char *argv[]);

#define NUM_MISSIONS_TEST 50
Expand Down Expand Up @@ -152,6 +153,7 @@ task_main(int argc, char *argv[])
PX4_ERR("test_dataman FAILED: task %d, buffer %02x %02x %02x %02x %02x %02x",
my_id, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]);
px4_sem_post(sems + my_id);
task_returned_error[my_id] = true;
return -1;
}

Expand All @@ -166,6 +168,7 @@ int test_dataman(int argc, char *argv[])
}

sems = (px4_sem_t *)malloc(num_tasks * sizeof(px4_sem_t));
task_returned_error = (bool *)calloc(num_tasks, sizeof(bool));
PX4_INFO("Running %d tasks", num_tasks);

for (i = 0; i < num_tasks; i++) {
Expand All @@ -192,6 +195,22 @@ int test_dataman(int argc, char *argv[])
}

free(sems);

bool got_error = false;

for (i = 0; i < num_tasks; i++) {
if (task_returned_error[i]) {
got_error = true;
break;
}
}

free(task_returned_error);

if (got_error) {
return -1;
}

dm_restart(DM_INIT_REASON_IN_FLIGHT);

for (i = 0; i < NUM_MISSIONS_TEST; i++) {
Expand Down

0 comments on commit 5dbf45f

Please sign in to comment.