From 2dde296d4ff0eeca8ad9147bf80d9990cff9926c Mon Sep 17 00:00:00 2001 From: fanzhuyun Date: Fri, 15 Oct 2021 14:21:57 +0800 Subject: [PATCH] testing/fstest: add cleanup to fatutf8 Signed-off-by: fanzhuyun --- testing/fatutf8/fatutf8_main.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/testing/fatutf8/fatutf8_main.c b/testing/fatutf8/fatutf8_main.c index 8e11517c1..1ec56864f 100644 --- a/testing/fatutf8/fatutf8_main.c +++ b/testing/fatutf8/fatutf8_main.c @@ -60,7 +60,7 @@ int main(int argc, FAR char *argv[]) int len; char buf[128]; - char path[256]; + char path[PATH_MAX]; char *basepath = NULL; @@ -166,5 +166,33 @@ int main(int argc, FAR char *argv[]) exit(fd); } + printf("\n"); + + ret = remove(path); + if (ret == 0) + { + printf("removed %s\n", path); + basepath = strrchr(path, '/'); + if (basepath != NULL) + { + *basepath = '\0'; + ret = remove(path); + if (ret == 0) + { + printf("removed %s\n", path); + } + else + { + printf("remove failed: %d\n", errno); + exit(ret); + } + } + } + else + { + printf("remove failed: %d\n", errno); + exit(ret); + } + return EXIT_SUCCESS; }