From bb71aa5b642ddfba1f23ddc9abba5fdbaa196a63 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Fri, 23 Sep 2016 09:11:27 -1000 Subject: [PATCH] Revive test_dataman.c --- src/systemcmds/tests/CMakeLists.txt | 1 + src/systemcmds/tests/test_dataman.c | 11 ++++++++--- src/systemcmds/tests/tests_main.c | 1 + src/systemcmds/tests/tests_main.h | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/systemcmds/tests/CMakeLists.txt b/src/systemcmds/tests/CMakeLists.txt index e7f153ed9a..2c734b1ba0 100644 --- a/src/systemcmds/tests/CMakeLists.txt +++ b/src/systemcmds/tests/CMakeLists.txt @@ -34,6 +34,7 @@ set(srcs test_adc.c test_autodeclination.cpp + test_dataman.c test_hysteresis.cpp test_bson.c test_conv.cpp diff --git a/src/systemcmds/tests/test_dataman.c b/src/systemcmds/tests/test_dataman.c index 3478077b21..c7ae811f1e 100644 --- a/src/systemcmds/tests/test_dataman.c +++ b/src/systemcmds/tests/test_dataman.c @@ -37,6 +37,7 @@ ****************************************************************************/ #include +#include #include @@ -60,6 +61,8 @@ #include "dataman/dataman.h" static px4_sem_t *sems; +int test_dataman(int argc, char *argv[]); + static int task_main(int argc, char *argv[]) @@ -91,7 +94,7 @@ task_main(int argc, char *argv[]) memset(buffer, my_id, sizeof(buffer)); buffer[1] = i; unsigned hash = i ^ my_id; - unsigned len = (hash & 63) + 2; + unsigned len = (hash % (DM_MAX_DATA_SIZE / 2)) + 2; int ret = dm_write(DM_KEY_WAYPOINTS_OFFBOARD_1, hash, DM_PERSIST_IN_FLIGHT_RESET, buffer, len); warnx("ret: %d", ret); @@ -109,7 +112,9 @@ task_main(int argc, char *argv[]) for (unsigned i = 0; i < NUM_MISSIONS_SUPPORTED; i++) { unsigned hash = i ^ my_id; - unsigned len2, len = (hash & 63) + 2; + unsigned len2; + unsigned len = (hash % (DM_MAX_DATA_SIZE / 2)) + 2; + ; if ((len2 = dm_read(DM_KEY_WAYPOINTS_OFFBOARD_1, hash, buffer, sizeof(buffer))) < 2) { warnx("%d read failed length test, index %d", my_id, hash); @@ -168,7 +173,7 @@ int test_dataman(int argc, char *argv[]) px4_sem_init(sems + i, 1, 0); /* start the task */ - if ((task = px4_task_spawn_cmd("dataman", SCHED_DEFAULT, SCHED_PRIORITY_MAX - 5, 2048, task_main, av)) <= 0) { + if ((task = px4_task_spawn_cmd("dataman", SCHED_DEFAULT, SCHED_PRIORITY_MAX - 5, 2048, task_main, (void *)av)) <= 0) { warn("task start failed"); } } diff --git a/src/systemcmds/tests/tests_main.c b/src/systemcmds/tests/tests_main.c index dd647b3e8c..01e0518bca 100644 --- a/src/systemcmds/tests/tests_main.c +++ b/src/systemcmds/tests/tests_main.c @@ -101,6 +101,7 @@ const struct { {"autodeclination", test_autodeclination, 0}, {"bson", test_bson, 0}, {"conv", test_conv, 0}, + {"dataman", test_dataman, 0}, {"file", test_file, OPT_NOJIGTEST | OPT_NOALLTEST}, {"file2", test_file2, OPT_NOJIGTEST}, {"float", test_float, 0}, diff --git a/src/systemcmds/tests/tests_main.h b/src/systemcmds/tests/tests_main.h index 3d1adc1096..65b77e1c5d 100644 --- a/src/systemcmds/tests/tests_main.h +++ b/src/systemcmds/tests/tests_main.h @@ -57,6 +57,7 @@ extern int test_autodeclination(int argc, char *argv[]); extern int test_hysteresis(int argc, char *argv[]); extern int test_bson(int argc, char *argv[]); extern int test_conv(int argc, char *argv[]); +extern int test_dataman(int argc, char *argv[]); extern int test_file(int argc, char *argv[]); extern int test_file2(int argc, char *argv[]); extern int test_float(int argc, char *argv[]);