tst_cgroup: fix tst_cgroup_version to cover more situations
PATCH v2 1/1 tst_cgroup: fix tst_cgroup_version to cover more situations
* system doesn't support any cgroup(v1, v2): TCONF
* system only support cgroup v1: choose v1
* system only support cgroup v2: choose v2
* system support v1 & v2 but mounting v1: chosse v1
* systep support v1 & v2 but mounting v2: choose v2
--- lib/tst_cgroup.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
lib/tst_cgroup.c +10 -9
@@ -38,18 +38,19 @@ static int tst_cgroup_check(const char *cgroup)enum tst_cgroup_ver tst_cgroup_version (void ) { -if (tst_cgroup_check ("cgroup2" )) { -if (!tst_is_mounted ("cgroup2" ) &&tst_is_mounted ("cgroup" )) -return TST_CGROUP_V1 ; -else -return TST_CGROUP_V2 ; - } +enum tst_cgroup_ver cg_ver;if (tst_cgroup_check ("cgroup" )) -return TST_CGROUP_V1 ; + cg_ver =TST_CGROUP_V1 ; + +if (tst_cgroup_check ("cgroup2" )) +if (!cg_ver ||tst_is_mounted ("cgroup2" )) + cg_ver =TST_CGROUP_V2 ; + +if (!cg_ver) +tst_brk (TCONF ,"Cgroup is not configured" ); -tst_brk (TCONF ,"Cgroup is not configured" ); -return TST_CGROUP_V1 ;/* fix -Werror=return-type */ +return cg_ver; } static void tst_cgroup1_mount(const char *name, const char *option,
Signature · 1 line
2.21.1
PATCH v2 1/1 tst_cgroup: fix tst_cgroup_version to cover more situations
Quoted 21 lines · Li Wang
* system doesn't support any
cgroup(v1, v2): TCONF
* system only support cgroup v1: choose v1
* system only support cgroup v2: choose v2
* system support v1 & v2 but mounting v1: chosse v1
* systep support v1 & v2 but mounting v2: choose v2Signed-off-by Li Wang <[email protected]>--- lib/tst_cgroup.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)lib/tst_cgroup.c +0
-2@@ -38,18 +38,19 @@ static int tst_cgroup_check(const char *cgroup)enum tst_cgroup_ver tst_cgroup_version (void ) { -if (tst_cgroup_check ("cgroup2" )) { -if (!tst_is_mounted ("cgroup2" ) &&tst_is_mounted ("cgroup" ))
lib/tst_cgroup.c static int tst_cgroup_check(const char *cgroup) · line 45
Quoted 10 lines
lib/tst_cgroup.c +2
-5-return TST_CGROUP_V1 ; - else - return TST_CGROUP_V2; - } +enum tst_cgroup_ver cg_ver;if (tst_cgroup_check ("cgroup" )) -return TST_CGROUP_V1 ; + cg_ver =TST_CGROUP_V1 ;
Ah sorry, it seems we shouldn't searching "cgroup" first, because that will be misled by "cgroup2" too. Plz ignore this patch
This is a little bit tricky, let me think over.
Quoted 22 lines
lib/tst_cgroup.c +8
-2+ +if (tst_cgroup_check ("cgroup2" )) +if (!cg_ver ||tst_is_mounted ("cgroup2" )) + cg_ver =TST_CGROUP_V2 ; + +if (!cg_ver) +tst_brk (TCONF ,"Cgroup is not configured" ); -tst_brk (TCONF ,"Cgroup is not configured" ); -return TST_CGROUP_V1 ;/* fix -Werror=return-type */ +return cg_ver; }static void tst_cgroup1_mount(const char *name, const char *option,
--
2.21.1--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20200622/8c535eb1/attachment.htm>