diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2013-01-12 23:26:26 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-01-12 23:26:26 +0100 |
commit | acbfd66e6726ec9dd8a4af53cfb47144a54c7e6f (patch) | |
tree | a4d5242093d872e46dd252c0ee41338b00c4241d /apps/px4 | |
parent | 8d6e0bc968030617580049ae29bf6e6858da5f9b (diff) | |
download | px4-firmware-acbfd66e6726ec9dd8a4af53cfb47144a54c7e6f.tar.gz px4-firmware-acbfd66e6726ec9dd8a4af53cfb47144a54c7e6f.tar.bz2 px4-firmware-acbfd66e6726ec9dd8a4af53cfb47144a54c7e6f.zip |
Cleaned up tests further, in anticipation of merges with other branches
Diffstat (limited to 'apps/px4')
-rw-r--r-- | apps/px4/tests/test_sleep.c | 3 | ||||
-rw-r--r-- | apps/px4/tests/tests_main.c | 19 |
2 files changed, 14 insertions, 8 deletions
diff --git a/apps/px4/tests/test_sleep.c b/apps/px4/tests/test_sleep.c index c7b9d2833..ae682b542 100644 --- a/apps/px4/tests/test_sleep.c +++ b/apps/px4/tests/test_sleep.c @@ -90,9 +90,8 @@ int test_sleep(int argc, char *argv[]) printf("\t %d 100ms sleeps\n", nsleeps); fflush(stdout); - for (int i = 0; i < nsleeps; i++) { + for (unsigned int i = 0; i < nsleeps; i++) { usleep(100000); - //printf("\ttick\n"); } printf("\t Sleep test successful.\n"); diff --git a/apps/px4/tests/tests_main.c b/apps/px4/tests/tests_main.c index 5c3b0b0c2..c392d0c4b 100644 --- a/apps/px4/tests/tests_main.c +++ b/apps/px4/tests/tests_main.c @@ -78,11 +78,10 @@ static int test_jig(int argc, char *argv[]); * Private Data ****************************************************************************/ -struct { +const struct { const char *name; int (* fn)(int argc, char *argv[]); unsigned options; - int passed; #define OPT_NOHELP (1<<0) #define OPT_NOALLTEST (1<<1) #define OPT_NOJIGTEST (1<<2) @@ -135,6 +134,10 @@ test_all(int argc, char *argv[]) unsigned int failcount = 0; unsigned int testscount = 0; + /* store test results */ + bool passed[(sizeof(tests) / sizeof(tests[0]))]; + memset(&passed, 0, sizeof(passed)); + printf("\nRunning all tests...\n\n"); for (i = 0; tests[i].name; i++) { @@ -150,7 +153,7 @@ test_all(int argc, char *argv[]) failcount++; } else { - tests[i].passed = 1; + passed[i] = true; printf(" [%s] \t\t\tPASS\n", tests[i].name); fflush(stdout); } @@ -198,7 +201,7 @@ test_all(int argc, char *argv[]) unsigned int k; for (k = 0; k < i; k++) { - if ((tests[k].passed == 0) && !(tests[k].options & OPT_NOALLTEST)) { + if (!passed[k] && !(tests[k].options & OPT_NOALLTEST)) { printf(" [%s] to obtain details, please re-run with\n\t nsh> tests %s\n\n", tests[k].name, tests[k].name); } } @@ -247,6 +250,10 @@ int test_jig(int argc, char *argv[]) unsigned int failcount = 0; unsigned int testscount = 0; + /* store test results */ + bool passed[(sizeof(tests) / sizeof(tests[0]))]; + memset(&passed, 0, sizeof(passed)); + printf("\nRunning all tests...\n\n"); for (i = 0; tests[i].name; i++) { /* Only run tests that are not excluded */ @@ -259,7 +266,7 @@ int test_jig(int argc, char *argv[]) fflush(stderr); failcount++; } else { - tests[i].passed = 1; + passed[i] = true; printf(" [%s] \t\t\tPASS\n", tests[i].name); fflush(stdout); } @@ -302,7 +309,7 @@ int test_jig(int argc, char *argv[]) unsigned int k; for (k = 0; k < i; k++) { - if ((tests[k].passed == 0) && !(tests[k].options & OPT_NOJIGTEST)) + if (!passed[k] && !(tests[k].options & OPT_NOJIGTEST)) { printf(" [%s] to obtain details, please re-run with\n\t nsh> tests %s\n\n", tests[k].name, tests[k].name); } |