[LTP] [PATCH] lib/default_cleanup: add default_cleanup() for old testcases
Zhao Gongyi
zhaogongyi@huawei.com
Mon Nov 22 04:54:53 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>
---
include/old/test.h | 2 ++
lib/default_cleanup.c | 11 +++++++++++
2 files changed, 13 insertions(+)
create mode 100644 lib/default_cleanup.c
diff --git a/include/old/test.h b/include/old/test.h
index 2ae7dba71..752c9628d 100644
--- a/include/old/test.h
+++ b/include/old/test.h
@@ -218,4 +218,6 @@ const char *tst_strerrno(int err);
#endif
#define TCID_DEFINE(ID) char *TCID = (#ID TCID_BIT_SUFFIX)
+void __attribute__((destructor)) default_cleanup(void);
+
#endif /* __TEST_H__ */
diff --git a/lib/default_cleanup.c b/lib/default_cleanup.c
new file mode 100644
index 000000000..fca394a04
--- /dev/null
+++ b/lib/default_cleanup.c
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2021 Zhao gongyi <zhaogongyi@huawei.com>
+ */
+
+#include "test.h"
+
+void __attribute__((destructor)) default_cleanup(void)
+{
+ tst_rmdir();
+}
--
2.17.1
More information about the ltp
mailing list