[LTP] [PATCH v2] lib/tst_tmpdir: Add tst_default_rmdir() for old testcases

Zhao Gongyi zhaogongyi@huawei.com
Mon Nov 22 09:01:38 CET 2021


In some old testcases, cleanup() will not run since it exit
form tst_brk. For example, because of the calling of ltp_syscall
have no real cleanup when syscall not support, testcase ssetmask01
will leave tmp file.

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
v1->v2: add tst_default_rmdir() in tst_tmpdir.c

 lib/tst_tmpdir.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/tst_tmpdir.c b/lib/tst_tmpdir.c
index 6e38ae977..0045c7bb6 100644
--- a/lib/tst_tmpdir.c
+++ b/lib/tst_tmpdir.c
@@ -342,6 +342,8 @@ void tst_rmdir(void)
 		tst_resm(TWARN, "%s: rmobj(%s) failed: %s",
 			 __func__, TESTDIR, errmsg);
 	}
+
+	TESTDIR == NULL;
 }

 void tst_purge_dir(const char *path)
@@ -351,3 +353,8 @@ void tst_purge_dir(const char *path)
 	if (purge_dir(path, &err))
 		tst_brkm(TBROK, NULL, "%s: %s", __func__, err);
 }
+
+void __attribute__((destructor)) tst_default_rmdir(void)
+{
+	tst_rmdir();
+}
--
2.17.1



More information about the ltp mailing list