Linux Test Project
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Wake Liu <wakel@google.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] cgroup_fj: Check start_path before removing directories in cleanup
Date: Fri, 4 Sep 2026 11:45:33 +0200	[thread overview]
Message-ID: <20260904094533.GA1206368@pevik> (raw)
In-Reply-To: <20260828120242.2367797-1-wakel@google.com>

Hi Wake Liu,

Thanks, merged with minor changes.

> +++ 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..."
Let's remove dots.

> +        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
Now we don't need to mask errors, right?
And a bit long line.

Also, I'm not sure if ... && ... can't bring problems on 'set -e' setup,
because if code is not executed $? gets 1. That's why I use only ... || ...
or if/then/else after which $? is always 0.

>      common_cleanup
>  }

Merged with following diff.

Kind regards,
Petr

+++ 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 testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh
index b0c9410ca3..2b0dafc544 100755
--- testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh
+++ testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh
@@ -231,7 +231,10 @@ cleanup()
         wait $pid >/dev/null 2>&1
     fi
 
-    rmdir "$start_path/ltp_1" >/dev/null 2>&1
+    if [ -n "$start_path" ] && [ -d "$start_path/ltp_1" ]; then
+        rmdir "$start_path/ltp_1"
+    fi
+
     common_cleanup
 }
 

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

      parent reply	other threads:[~2026-09-04  9:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28 12:02 [LTP] [PATCH] cgroup_fj: Check start_path before removing directories in cleanup Wake Liu via ltp
2026-08-28 21:08 ` [LTP] " linuxtestproject.agent
2026-09-04  9:45 ` Petr Vorel [this message]

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=20260904094533.GA1206368@pevik \
    --to=pvorel@suse.cz \
    --cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox