Tests: Fix code style on system tests

This commit is contained in:
Lorenz Meier
2015-03-28 19:51:15 +01:00
parent b24af0f402
commit 32e790110e
17 changed files with 424 additions and 237 deletions
+23 -10
View File
@@ -126,8 +126,9 @@ test_help(int argc, char *argv[])
printf("Available tests:\n");
for (i = 0; tests[i].name; i++)
for (i = 0; tests[i].name; i++) {
printf(" %s\n", tests[i].name);
}
return 0;
}
@@ -155,11 +156,13 @@ test_all(int argc, char *argv[])
fflush(stderr);
failcount++;
passed[i] = false;
} else {
printf(" [%s] \t\t\tPASS\n", tests[i].name);
fflush(stdout);
passed[i] = true;
}
testcount++;
}
}
@@ -198,7 +201,7 @@ test_all(int argc, char *argv[])
printf("\n");
/* Print failed tests */
if (failcount > 0) printf(" Failed tests:\n\n");
if (failcount > 0) { printf(" Failed tests:\n\n"); }
unsigned int k;
@@ -254,22 +257,26 @@ int test_jig(int argc, char *argv[])
bool passed[NTESTS];
printf("\nRunning all tests...\n\n");
for (i = 0; tests[i].name; i++) {
/* Only run tests that are not excluded */
if (!(tests[i].options & OPT_NOJIGTEST)) {
printf(" [%s] \t\t\tSTARTING TEST\n", tests[i].name);
fflush(stdout);
/* Execute test */
if (tests[i].fn(1, args) != 0) {
fprintf(stderr, " [%s] \t\t\tFAIL\n", tests[i].name);
fflush(stderr);
failcount++;
passed[i] = false;
} else {
printf(" [%s] \t\t\tPASS\n", tests[i].name);
fflush(stdout);
passed[i] = true;
}
testcount++;
}
}
@@ -277,13 +284,15 @@ int test_jig(int argc, char *argv[])
/* Print summary */
printf("\n");
int j;
for (j = 0; j < 40; j++)
{
for (j = 0; j < 40; j++) {
printf("-");
}
printf("\n\n");
printf(" T E S T S U M M A R Y\n\n");
if (failcount == 0) {
printf(" ______ __ __ ______ __ __ \n");
printf(" /\\ __ \\ /\\ \\ /\\ \\ /\\ __ \\ /\\ \\/ / \n");
@@ -292,6 +301,7 @@ int test_jig(int argc, char *argv[])
printf(" \\/_/\\/_/ \\/_____/ \\/_____/ \\/_____/ \\/_/\\/_/ \n");
printf("\n");
printf(" All tests passed (%d of %d)\n", testcount, testcount);
} else {
printf(" ______ ______ __ __ \n");
printf(" /\\ ___\\ /\\ __ \\ /\\ \\ /\\ \\ \n");
@@ -301,18 +311,20 @@ int test_jig(int argc, char *argv[])
printf("\n");
printf(" Some tests failed (%d of %d)\n", failcount, testcount);
}
printf("\n");
/* Print failed tests */
if (failcount > 0) printf(" Failed tests:\n\n");
if (failcount > 0) { printf(" Failed tests:\n\n"); }
unsigned int k;
for (k = 0; k < i; k++)
{
if (!passed[i] && !(tests[k].options & OPT_NOJIGTEST))
{
for (k = 0; k < i; k++) {
if (!passed[i] && !(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);
}
}
fflush(stdout);
return 0;
@@ -333,8 +345,9 @@ int tests_main(int argc, char *argv[])
}
for (i = 0; tests[i].name; i++) {
if (!strcmp(tests[i].name, argv[1]))
if (!strcmp(tests[i].name, argv[1])) {
return tests[i].fn(argc - 1, argv + 1);
}
}
printf("tests: no test called '%s' - 'tests help' for a list of tests\n", argv[1]);