[LTP] [PATCH 3/3] quotactl06: Fix TESTDIR1 cleanup if setup() exits early
Martin Doucha
mdoucha@suse.cz
Thu Mar 3 16:31:31 CET 2022
When setup() exits with TCONF before TESTDIR1 gets created, cleanup() will
trigger TWARN when it tries to delete it. Check whether the directory exists
before calling SAFE_RMDIR().
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
testcases/kernel/syscalls/quotactl/quotactl06.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/quotactl/quotactl06.c b/testcases/kernel/syscalls/quotactl/quotactl06.c
index 8e9a17393..d470486d5 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl06.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl06.c
@@ -207,7 +207,9 @@ static void setup(void)
static void cleanup(void)
{
SAFE_UNLINK(USRPATH);
- SAFE_RMDIR(TESTDIR1);
+
+ if (!access(TESTDIR1, F_OK))
+ SAFE_RMDIR(TESTDIR1);
}
static struct tst_test test = {
--
2.35.1
More information about the ltp
mailing list