diff mbox series

[v2] controllers: skip test when cgroup v2 is loaded

Message ID CA+B+MYT=RRPEUQ8WydQWeQkB02xO5=EJd=gqOTXB1F5OUWj9HQ@mail.gmail.com
State Changes Requested
Headers show
Series [v2] controllers: skip test when cgroup v2 is loaded | expand

Commit Message

Jin Guojie Dec. 19, 2024, 6:36 a.m. UTC
V2:
* Correction of comments

V1:
* Initial check for cgroup v2

When running "controllers" case on some newer Linux distributions, there
will be 10 ERROR messages during the setup phase, and several TFAIL
results at the end.

Current "controllers" cases only implement tests for cgroup v1 file interface.
It's better to skip the test after checking that v2 hierarchy has
already been loaded.

[1] https://lists.linux.it/pipermail/ltp/2024-December/041082.html

Signed-off-by: Jin Guojie <guojie.jin@gmail.com>
---
 testcases/kernel/controllers/test_controllers.sh | 9 +++++++++
 1 file changed, 9 insertions(+)

 then
        CPU_CONTROLLER=`grep -w cpu /proc/cgroups | cut -f1`;
--
2.34.1

Comments

Jin Guojie Feb. 17, 2025, 7:25 a.m. UTC | #1
Hi Li Wang,

This patch fixes the judgment of controllers in the cgroup v2 system
and improves the error message.
This is the second version I've made.
Would you please review it?

Regards,
Jin

On Thu, Dec 19, 2024 at 2:36 PM Jin Guojie <guojie.jin@gmail.com> wrote:
>
> V2:
> * Correction of comments
>
> V1:
> * Initial check for cgroup v2
>
> When running "controllers" case on some newer Linux distributions, there
> will be 10 ERROR messages during the setup phase, and several TFAIL
> results at the end.
>
> Current "controllers" cases only implement tests for cgroup v1 file interface.
> It's better to skip the test after checking that v2 hierarchy has
> already been loaded.
>
> [1] https://lists.linux.it/pipermail/ltp/2024-December/041082.html
>
> Signed-off-by: Jin Guojie <guojie.jin@gmail.com>
> ---
>  testcases/kernel/controllers/test_controllers.sh | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/testcases/kernel/controllers/test_controllers.sh
> b/testcases/kernel/controllers/test_controllers.sh
> index 7aa974ff2..0b67387ec 100755
> --- a/testcases/kernel/controllers/test_controllers.sh
> +++ b/testcases/kernel/controllers/test_controllers.sh
> @@ -37,6 +37,15 @@
>  #
>            #
>  ##################################################################################
>
> +# Currently only cgroup v1 interface can be tested.
> +# When the v2 hierarchy is already loaded in the system, skip the test.
> +mount | grep  " type cgroup2 " &>/dev/null
> +if [ $? == 0 ]
> +then
> +       tst_brkm TCONF "" "test_controllers.sh: V1 controller
> required, but mounted on V2"
> +       exit 32
> +fi
> +
>  if [ -f /proc/cgroups ]
>  then
>         CPU_CONTROLLER=`grep -w cpu /proc/cgroups | cut -f1`;
> --
> 2.34.1
Li Wang Feb. 17, 2025, 8:48 a.m. UTC | #2
Hi Guojie,

On Mon, Feb 17, 2025 at 3:25 PM Jin Guojie <guojie.jin@gmail.com> wrote:

> Hi Li Wang,
>
> This patch fixes the judgment of controllers in the cgroup v2 system
> and improves the error message.
> This is the second version I've made.
> Would you please review it?
>

Sure, we do now have a new cgroup_lib.sh to replace the outdated shell
CGroup API, can we include that new to update test_controllers.sh?



>
> Regards,
> Jin
>
> On Thu, Dec 19, 2024 at 2:36 PM Jin Guojie <guojie.jin@gmail.com> wrote:
> >
> > V2:
> > * Correction of comments
> >
> > V1:
> > * Initial check for cgroup v2
> >
> > When running "controllers" case on some newer Linux distributions, there
> > will be 10 ERROR messages during the setup phase, and several TFAIL
> > results at the end.
> >
> > Current "controllers" cases only implement tests for cgroup v1 file
> interface.
> > It's better to skip the test after checking that v2 hierarchy has
> > already been loaded.
> >
> > [1] https://lists.linux.it/pipermail/ltp/2024-December/041082.html
> >
> > Signed-off-by: Jin Guojie <guojie.jin@gmail.com>
> > ---
> >  testcases/kernel/controllers/test_controllers.sh | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> >
> > diff --git a/testcases/kernel/controllers/test_controllers.sh
> > b/testcases/kernel/controllers/test_controllers.sh
> > index 7aa974ff2..0b67387ec 100755
> > --- a/testcases/kernel/controllers/test_controllers.sh
> > +++ b/testcases/kernel/controllers/test_controllers.sh
> > @@ -37,6 +37,15 @@
> >  #
> >            #
> >
> ##################################################################################
> >
> > +# Currently only cgroup v1 interface can be tested.
> > +# When the v2 hierarchy is already loaded in the system, skip the test.
> > +mount | grep  " type cgroup2 " &>/dev/null
> > +if [ $? == 0 ]
> > +then
> > +       tst_brkm TCONF "" "test_controllers.sh: V1 controller
> > required, but mounted on V2"
> > +       exit 32
> > +fi
> > +
> >  if [ -f /proc/cgroups ]
> >  then
> >         CPU_CONTROLLER=`grep -w cpu /proc/cgroups | cut -f1`;
> > --
> > 2.34.1
>
>
Ricardo B. Marlière May 12, 2025, 1:50 p.m. UTC | #3
On Thu Dec 19, 2024 at 3:36 AM -03, Jin Guojie wrote:
> V2:
> * Correction of comments
>
> V1:
> * Initial check for cgroup v2
>
> When running "controllers" case on some newer Linux distributions, there
> will be 10 ERROR messages during the setup phase, and several TFAIL
> results at the end.
>
> Current "controllers" cases only implement tests for cgroup v1 file interface.
> It's better to skip the test after checking that v2 hierarchy has
> already been loaded.
>
> [1] https://lists.linux.it/pipermail/ltp/2024-December/041082.html
>
> Signed-off-by: Jin Guojie <guojie.jin@gmail.com>
> ---
>  testcases/kernel/controllers/test_controllers.sh | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/testcases/kernel/controllers/test_controllers.sh
> b/testcases/kernel/controllers/test_controllers.sh
> index 7aa974ff2..0b67387ec 100755
> --- a/testcases/kernel/controllers/test_controllers.sh
> +++ b/testcases/kernel/controllers/test_controllers.sh
> @@ -37,6 +37,15 @@
>  #
>            #
>  ##################################################################################
>
> +# Currently only cgroup v1 interface can be tested.
> +# When the v2 hierarchy is already loaded in the system, skip the test.
> +mount | grep  " type cgroup2 " &>/dev/null
> +if [ $? == 0 ]
> +then
> +       tst_brkm TCONF "" "test_controllers.sh: V1 controller
> required, but mounted on V2"
> +       exit 32
> +fi
> +

Tested-by: Ricardo B. Marlière <rbm@suse.com>

FYI This test was excluded from Tumbleweed but now is being tested
again:

https://openqa.opensuse.org/tests/5053017#step/controllers/8

With this patch, the test is correctly skipped:

https://openqa.opensuse.org/tests/5054200#step/controllers/8

IMHO it should be merged.

Thanks,
-	Ricardo.


>  if [ -f /proc/cgroups ]
>  then
>         CPU_CONTROLLER=`grep -w cpu /proc/cgroups | cut -f1`;
> --
> 2.34.1
diff mbox series

Patch

diff --git a/testcases/kernel/controllers/test_controllers.sh
b/testcases/kernel/controllers/test_controllers.sh
index 7aa974ff2..0b67387ec 100755
--- a/testcases/kernel/controllers/test_controllers.sh
+++ b/testcases/kernel/controllers/test_controllers.sh
@@ -37,6 +37,15 @@ 
 #
           #
 ##################################################################################

+# Currently only cgroup v1 interface can be tested.
+# When the v2 hierarchy is already loaded in the system, skip the test.
+mount | grep  " type cgroup2 " &>/dev/null
+if [ $? == 0 ]
+then
+       tst_brkm TCONF "" "test_controllers.sh: V1 controller
required, but mounted on V2"
+       exit 32
+fi
+
 if [ -f /proc/cgroups ]