From cd1d855a714c19182a647bea1113aa23736f97de Mon Sep 17 00:00:00 2001 From: Michal Lenc Date: Tue, 17 Oct 2023 13:55:02 +0200 Subject: [PATCH] testing/scanftest: add number of correct/incorrect tests Verbose output for CI testing with OK and FAILED number of tests. File name is also now configurable with TESTING_SCANFTEST_FNAME. Signed-off-by: Michal Lenc --- testing/scanftest/Kconfig | 6 ++++++ testing/scanftest/scanftest_main.c | 22 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/testing/scanftest/Kconfig b/testing/scanftest/Kconfig index c625b63f6..beb935a6b 100644 --- a/testing/scanftest/Kconfig +++ b/testing/scanftest/Kconfig @@ -30,4 +30,10 @@ config TESTING_SCANFTEST_STACKSIZE int "Scanftest stack size" default DEFAULT_TASK_STACKSIZE +config TESTING_SCANFTEST_FNAME + string "Scanftest file name" + default "/mnt/fs/test.txt" + ---help--- + Path to the file for test writes/reads. + endif diff --git a/testing/scanftest/scanftest_main.c b/testing/scanftest/scanftest_main.c index b51bea89d..c957f44d0 100644 --- a/testing/scanftest/scanftest_main.c +++ b/testing/scanftest/scanftest_main.c @@ -1083,8 +1083,11 @@ int main(int argc, FAR char *argv[]) double d2; FAR FILE *fp; + int tests_ok = 0; + int tests_err = 0; + FAR const char *teststring = "teststring a"; - FAR const char *fname = "/mnt/fs/test.txt"; + FAR const char *fname = CONFIG_TESTING_SCANFTEST_FNAME; /* Test that scanf() can recognize percent-signs in the input. ** Test that * integer converters skip white-space. ** Test that "%i" can scan a single @@ -1129,20 +1132,24 @@ int main(int argc, FAR char *argv[]) if (strcmp(s1, teststring) != 0) { + tests_err += 1; printf("Error %s != %s.\n", teststring, s1); } else { + tests_ok += 1; printf("Test PASSED.\n"); } } else { + tests_err += 1; printf("Error opening %s for read.\n", fname); } } else { + tests_err += 1; printf("Error opening %s for write.\n", fname); } } @@ -1171,6 +1178,7 @@ int main(int argc, FAR char *argv[]) } else { + tests_err += 1; printf("Error opening %s for write.\n", fname); break; } @@ -1320,8 +1328,13 @@ int main(int argc, FAR char *argv[]) if (ok) { + tests_ok += 1; printf("Test #%u PASSED.\n", t + 1); } + else + { + tests_err += 1; + } } } @@ -1457,9 +1470,16 @@ int main(int argc, FAR char *argv[]) if (ok) { + tests_ok += 1; printf("Test #%u PASSED.\n", t + 1); } + else + { + tests_err += 1; + } } + printf("Scanf tests done... OK: %d, FAILED: %d\n", tests_ok, tests_err); + return OK; }