public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] memcg_lib.sh: fix the shmmax value comparison
@ 2017-11-22  7:38 Li Wang
  2017-11-22  7:38 ` [LTP] [PATCH 2/2] cgroup: fix mount errors in cgroup subsys Li Wang
  2017-11-30 14:07 ` [LTP] [PATCH 1/2] memcg_lib.sh: fix the shmmax value comparison Cyril Hrubis
  0 siblings, 2 replies; 4+ messages in thread
From: Li Wang @ 2017-11-22  7:38 UTC (permalink / raw)
  To: ltp

The value of /proc/sys/kernel/shmmax is 18446744073692774399 which Dash/Bash
fails to compare to the $HUGEPAGESIZE value and report error:

  memcg_lib.sh: line 81: [: 18446744073692774399: integer expression expected

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/controllers/memcg/functional/memcg_lib.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
index d4724c3..6a6af85 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
@@ -78,7 +78,7 @@ TST_CLEANUP=cleanup
 shmmax_setup()
 {
 	shmmax=`cat /proc/sys/kernel/shmmax`
-	if [ $shmmax -lt $HUGEPAGESIZE ]; then
+	if [ $(echo "$shmmax < $HUGEPAGESIZE" |bc) -eq 1 ]; then
 		ROD echo "$HUGEPAGESIZE" \> /proc/sys/kernel/shmmax
 	fi
 }
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [LTP] [PATCH 2/2] cgroup: fix mount errors in cgroup subsys
  2017-11-22  7:38 [LTP] [PATCH 1/2] memcg_lib.sh: fix the shmmax value comparison Li Wang
@ 2017-11-22  7:38 ` Li Wang
  2018-12-13 16:24   ` Petr Vorel
  2017-11-30 14:07 ` [LTP] [PATCH 1/2] memcg_lib.sh: fix the shmmax value comparison Cyril Hrubis
  1 sibling, 1 reply; 4+ messages in thread
From: Li Wang @ 2017-11-22  7:38 UTC (permalink / raw)
  To: ltp

It is very easy to get failures when running these cgroup regression
tests on the newer kernel. Maybe the cases should be rewriten in LTP
new API someday, but currently this fix just as a workaround for it.

Errors:
  cgroup_regression_test    3  TFAIL  :  ltpapicmd.c:190: Failed to mount cpu subsys
  cgroup_regression_test    5  TFAIL  :  ltpapicmd.c:190: mount net_prio and pids failed
  cgroup_regression_test    7  TFAIL  :  ltpapicmd.c:190: failed to mount net_prio

Signed-off-by: Li Wang <liwang@redhat.com>
---
 .../controllers/cgroup/cgroup_regression_test.sh   | 63 ++++++++++++++--------
 testcases/kernel/controllers/cgroup/test_3_1.sh    |  8 +--
 2 files changed, 46 insertions(+), 25 deletions(-)

diff --git a/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh b/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
index 30d0dbf..d333d73 100755
--- a/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
+++ b/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
@@ -175,21 +175,25 @@ test_3()
 		return
 	fi
 
-	grep -q -w "cpu" /proc/cgroups
-	if [ $? -ne 0 ]; then
+	if grep -q -w "cpu" /proc/cgroups ; then
+		cpu_subsys_path=$(grep -w cpu /proc/mounts | cut -d ' ' -f 2)
+	else
 		tst_resm TCONF "CONFIG_CGROUP_SCHED is not enabled"
 		return
 	fi
 
 	# Run the test for 30 secs
-	mount -t cgroup -o cpu xxx cgroup/
-	if [ $? -ne 0 ]; then
-		tst_resm TFAIL "Failed to mount cpu subsys"
-		failed=1
-		return
+	if [ -z "$cpu_subsys_path" ]; then
+		mount -t cgroup -o cpu xxx cgroup/
+		if [ $? -ne 0 ]; then
+			tst_resm TFAIL "Failed to mount cpu subsys"
+			failed=1
+			return
+		fi
+		cpu_subsys_path=cgroup
 	fi
 
-	./test_3_1.sh &
+	./test_3_1.sh $cpu_subsys_path &
 	pid1=$!
 	./test_3_2.sh &
 	pid2=$!
@@ -204,8 +208,9 @@ test_3()
 		tst_resm TPASS "no kernel bug was found"
 	fi
 
-	rmdir cgroup/* 2> /dev/null
-	umount cgroup/
+	rmdir $cpu_subsys_path/* 2> /dev/null
+
+	umount cgroup/ 2> /dev/null
 }
 
 #---------------------------------------------------------------------------
@@ -260,7 +265,14 @@ test_5()
 	fi
 
 	subsys1=`tail -n 1 /proc/cgroups | awk '{ print $1 }'`
+	subsys1_mount=$(basename $(grep -w $subsys1 /proc/mounts | cut -d ' ' -f 2))
 	subsys2=`tail -n 2 /proc/cgroups | head -1 | awk '{ print $1 }'`
+	subsys2_mount=$(basename $(grep -w $subsys2 /proc/mounts | cut -d ' ' -f 2))
+
+	if [ -n "$subsys1_mount" ] || [ -n "$subsys2_mount" ]; then
+		tst_resm TCONF "$subsys1 or $subsys2 has been mounted, skip"
+		return
+	fi
 
 	mount -t cgroup -o $subsys1,$subsys2 xxx cgroup/
 	if [ $? -ne 0 ]; then
@@ -347,23 +359,30 @@ test_6()
 #---------------------------------------------------------------------------
 test_7_1()
 {
-	mount -t cgroup -o $subsys xxx cgroup/
-	if [ $? -ne 0 ]; then
-		tst_resm TFAIL "failed to mount $subsys"
-		failed=1
-		return
+	subsys_path=$(grep -w $subsys /proc/mounts | cut -d ' ' -f 2)
+	if [ -z "$subsys_path" ]; then
+		mount -t cgroup -o $subsys xxx cgroup/
+		if [ $? -ne 0 ]; then
+			tst_resm TFAIL "failed to mount $subsys"
+			failed=1
+			return
+		fi
+		subsys_path=cgroup
 	fi
 
-	mkdir cgroup/0
-	sleep 100 < cgroup/0 &	# add refcnt to this dir
-	rmdir cgroup/0
+	mkdir $subsys_path/0
+	sleep 100 < $subsys_path/0 &	# add refcnt to this dir
+	rmdir $subsys_path/0
 
 	# remount with new subsystems added
 	# since 2.6.28, this remount will fail
-	mount -t cgroup -o remount xxx cgroup/ 2> /dev/null
-	/bin/kill -SIGTERM $!
-	wait $!
-	umount cgroup/
+
+	if [ "$subsys_path" == "cgroup" ]; then
+		mount -t cgroup -o remount xxx cgroup/ 2> /dev/null
+		/bin/kill -SIGTERM $!
+		wait $!
+		umount cgroup/
+	fi
 }
 
 test_7_2()
diff --git a/testcases/kernel/controllers/cgroup/test_3_1.sh b/testcases/kernel/controllers/cgroup/test_3_1.sh
index a1a4943..dcc78a6 100755
--- a/testcases/kernel/controllers/cgroup/test_3_1.sh
+++ b/testcases/kernel/controllers/cgroup/test_3_1.sh
@@ -23,9 +23,11 @@
 ################################################################################
 
 trap exit SIGUSR1
+
+path=$1
+
 for ((; ;))
 {
-	mkdir cgroup/0
-	rmdir cgroup/0
+	mkdir $path/0
+	rmdir $path/0
 }
-
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [LTP] [PATCH 1/2] memcg_lib.sh: fix the shmmax value comparison
  2017-11-22  7:38 [LTP] [PATCH 1/2] memcg_lib.sh: fix the shmmax value comparison Li Wang
  2017-11-22  7:38 ` [LTP] [PATCH 2/2] cgroup: fix mount errors in cgroup subsys Li Wang
@ 2017-11-30 14:07 ` Cyril Hrubis
  1 sibling, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2017-11-30 14:07 UTC (permalink / raw)
  To: ltp

Hi!
This is obviously correct, applied, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [LTP] [PATCH 2/2] cgroup: fix mount errors in cgroup subsys
  2017-11-22  7:38 ` [LTP] [PATCH 2/2] cgroup: fix mount errors in cgroup subsys Li Wang
@ 2018-12-13 16:24   ` Petr Vorel
  0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2018-12-13 16:24 UTC (permalink / raw)
  To: ltp

Hi Li, Cristian,

> It is very easy to get failures when running these cgroup regression
> tests on the newer kernel. Maybe the cases should be rewriten in LTP
> new API someday, but currently this fix just as a workaround for it.

> Errors:
>   cgroup_regression_test    3  TFAIL  :  ltpapicmd.c:190: Failed to mount cpu subsys
>   cgroup_regression_test    5  TFAIL  :  ltpapicmd.c:190: mount net_prio and pids failed
>   cgroup_regression_test    7  TFAIL  :  ltpapicmd.c:190: failed to mount net_prio

Li, I pushed your old patch with some changes (see diff bellow):
* remove fix for 5th test (already fixed by Cristian 877c1228d)
* use awk for consistency (although I prefer using cut, I have feeling it's more
common than awk on embedded devices)
* remove bashism
* add local

@Cristian: some of issues, which needs to be addressed when rewriting into new API:
* remove bashisms, use #!/bin/sh
* Remove absolute (/bin/kill) and relative paths and cd into $LTPROOT/testcases/bin
* function for parsing /proc/mounts
* use local in functions, don't use global variables (failed)
* maybe shell code can be generated on the fly into tmp files. If not it'd be
better to use more obvious names than "test_10_2.sh"
* ...

Kind regards,
Petr


diff --git testcases/kernel/controllers/cgroup/cgroup_regression_test.sh testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
index 8b2918c3a..6cfc63866 100755
--- testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
+++ testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
@@ -170,13 +170,15 @@ test_2()
 #---------------------------------------------------------------------------
 test_3()
 {
+	local cpu_subsys_path
+
 	if [ ! -e /proc/sched_debug ]; then
 		tst_resm TCONF "CONFIG_SCHED_DEBUG is not enabled"
 		return
 	fi
 
 	if grep -q -w "cpu" /proc/cgroups ; then
-		cpu_subsys_path=$(grep -w cpu /proc/mounts | cut -d ' ' -f 2)
+		cpu_subsys_path=$(grep -w cpu /proc/mounts | awk '{ print $2 }')
 	else
 		tst_resm TCONF "CONFIG_CGROUP_SCHED is not enabled"
 		return
@@ -269,14 +271,7 @@ test_5()
 	fi
 
 	subsys1=`tail -n 1 /proc/cgroups | awk '{ print $1 }'`
-	subsys1_mount=$(basename $(grep -w $subsys1 /proc/mounts | cut -d ' ' -f 2))
 	subsys2=`tail -n 2 /proc/cgroups | head -1 | awk '{ print $1 }'`
-	subsys2_mount=$(basename $(grep -w $subsys2 /proc/mounts | cut -d ' ' -f 2))
-
-	if [ -n "$subsys1_mount" ] || [ -n "$subsys2_mount" ]; then
-		tst_resm TCONF "$subsys1 or $subsys2 has been mounted, skip"
-		return
-	fi
 
 	# Accounting here for the fact that the chosen subsystems could
 	# have been already previously mounted at boot time: in such a
@@ -402,7 +397,7 @@ test_7_1()
 	# remount with new subsystems added
 	# since 2.6.28, this remount will fail
 
-	if [ "$subsys_path" == "cgroup" ]; then
+	if [ "$subsys_path" = "cgroup" ]; then
 		mount -t cgroup -o remount xxx cgroup/ 2> /dev/null
 		/bin/kill -SIGTERM $!
 		wait $!

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-13 16:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-22  7:38 [LTP] [PATCH 1/2] memcg_lib.sh: fix the shmmax value comparison Li Wang
2017-11-22  7:38 ` [LTP] [PATCH 2/2] cgroup: fix mount errors in cgroup subsys Li Wang
2018-12-13 16:24   ` Petr Vorel
2017-11-30 14:07 ` [LTP] [PATCH 1/2] memcg_lib.sh: fix the shmmax value comparison Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox