testing/fstest: add number of correct/incorrect tests

Verbose output for CI testing with OK and FAILED number of tests.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This commit is contained in:
Michal Lenc 2023-10-17 22:57:43 +02:00 committed by Alan Carvalho de Assis
parent cd1d855a71
commit a4ceb82d67

View File

@ -89,6 +89,10 @@ struct fstest_ctx_s
struct mallinfo mmprevious;
struct mallinfo mmafter;
};
static int tests_ok = 0;
static int tests_err = 0;
/****************************************************************************
* Private Functions
****************************************************************************/
@ -968,6 +972,8 @@ int main(int argc, FAR char *argv[])
int loop_num;
int option;
tests_ok = tests_err = 0;
ctx = malloc(sizeof(struct fstest_ctx_s));
if (ctx == NULL)
{
@ -1101,6 +1107,7 @@ int main(int argc, FAR char *argv[])
ret = fstest_delfiles(ctx);
if (ret < 0)
{
tests_err += 1;
printf("ERROR: Failed to delete files\n");
printf(" Number of files: %d\n", ctx->nfiles);
printf(" Number deleted: %d\n", ctx->ndeleted);
@ -1109,6 +1116,7 @@ int main(int argc, FAR char *argv[])
}
else
{
tests_ok += 1;
printf("Deleted some files\n");
printf(" Number of files: %d\n", ctx->nfiles);
printf(" Number deleted: %d\n", ctx->ndeleted);
@ -1128,6 +1136,7 @@ int main(int argc, FAR char *argv[])
ret = fstest_verifyfs(ctx);
if (ret < 0)
{
tests_err += 1;
printf("ERROR: Failed to verify files\n");
printf(" Number of files: %d\n", ctx->nfiles);
printf(" Number deleted: %d\n", ctx->ndeleted);
@ -1136,6 +1145,7 @@ int main(int argc, FAR char *argv[])
}
else
{
tests_ok += 1;
#if CONFIG_TESTING_FSTEST_VERBOSE != 0
printf("Verified!\n");
printf(" Number of files: %d\n", ctx->nfiles);
@ -1148,19 +1158,19 @@ int main(int argc, FAR char *argv[])
ret = statfs(ctx->mountdir, &buf);
if (ret < 0)
{
printf("ERROR: statfs failed: %d\n", errno);
free(ctx);
exit(ret);
printf("ERROR: statfs failed: %d\n", errno);
free(ctx);
exit(ret);
}
else
{
printf("File System:\n");
printf(" Block Size: %lu\n", (unsigned long)buf.f_bsize);
printf(" No. Blocks: %lu\n", (unsigned long)buf.f_blocks);
printf(" Free Blocks: %ld\n", (long)buf.f_bfree);
printf(" Avail. Blocks: %ld\n", (long)buf.f_bavail);
printf(" No. File Nodes: %ld\n", (long)buf.f_files);
printf(" Free File Nodes: %ld\n", (long)buf.f_ffree);
printf("File System:\n");
printf(" Block Size: %lu\n", (unsigned long)buf.f_bsize);
printf(" No. Blocks: %lu\n", (unsigned long)buf.f_blocks);
printf(" Free Blocks: %ld\n", (long)buf.f_bfree);
printf(" Avail. Blocks: %ld\n", (long)buf.f_bavail);
printf(" No. File Nodes: %ld\n", (long)buf.f_files);
printf(" Free File Nodes: %ld\n", (long)buf.f_ffree);
}
/* Perform garbage collection, integrity checks */
@ -1183,6 +1193,9 @@ int main(int argc, FAR char *argv[])
free(ctx->files);
free(ctx);
printf("File system tests done... OK: %d, FAILED: %d\n", tests_ok,
tests_err);
#ifdef CONFIG_TESTING_FSTEST_POWEROFF
/* Power down. This is useful when used with the simulator and gcov,
* as the graceful shutdown allows for the generation of the .gcda files.