From: Wake Liu via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Cc: Wake Liu <wakel@google.com>
Subject: [LTP] [PATCH] cgroup_fj: Check start_path before removing directories in cleanup
Date: Fri, 28 Aug 2026 12:02:42 +0000 [thread overview]
Message-ID: <20260828120242.2367797-1-wakel@google.com> (raw)
When setup() fails early (for example, when a cgroup controller is not
available and cgroup_require triggers TCONF), start_path has not yet
been assigned.
In this case, cleanup() in cgroup_fj_function.sh unconditionally runs
rmdir "$start_path/ltp_1", which evaluates to rmdir /ltp_1 and fails.
Similarly, common_cleanup() prints a message about removing all ltp
subgroups even when none were created.
Add checks to verify that start_path is non-empty and the directory
exists before attempting removal.
Signed-off-by: Wake Liu <wakel@google.com>
---
testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh | 7 ++++---
.../kernel/controllers/cgroup_fj/cgroup_fj_function.sh | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh
index 8b5e73466..03e416f55 100755
--- a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh
+++ b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh
@@ -79,9 +79,10 @@ common_cleanup()
{
killall -9 cgroup_fj_proc >/dev/null 2>&1
- tst_res TINFO "Removing all ltp subgroups..."
-
- [ -d "$start_path" ] && find "$start_path" -depth -type d -exec rmdir '{}' \;
+ if [ -n "$start_path" ] && [ -d "$start_path" ]; then
+ tst_res TINFO "Removing all ltp subgroups..."
+ find "$start_path" -depth -type d -exec rmdir '{}' \;
+ fi
cgroup_cleanup
diff --git a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh
index b0c9410ca..61b7a0415 100755
--- a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh
+++ b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh
@@ -231,7 +231,7 @@ cleanup()
wait $pid >/dev/null 2>&1
fi
- rmdir "$start_path/ltp_1" >/dev/null 2>&1
+ [ -n "$start_path" ] && [ -d "$start_path/ltp_1" ] && rmdir "$start_path/ltp_1" >/dev/null 2>&1
common_cleanup
}
--
2.55.0.897.gb25b4bd76c-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2026-08-28 12:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 12:02 Wake Liu via ltp [this message]
2026-08-28 21:08 ` [LTP] cgroup_fj: Check start_path before removing directories in cleanup linuxtestproject.agent
2026-09-04 9:45 ` [LTP] [PATCH] " Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260828120242.2367797-1-wakel@google.com \
--to=ltp@lists.linux.it \
--cc=wakel@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.