All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3]  memcg_stress_test.sh: ported to newlib
Date: Tue, 29 Jan 2019 18:50:19 +0100	[thread overview]
Message-ID: <20190129175019.GA14252@dell5510> (raw)
In-Reply-To: <20190128163207.GA26834@dell5510>

Hi Cristian,

I suggest following cleanup of your patch (see bellow).

This change, with my other cleanup patch [1] + your patch [2] can be seen on [3].

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/patch/1032923/
[2] https://patchwork.ozlabs.org/patch/1020887/
[3] https://github.com/pevik/ltp/commits/christian/memcg_stress_test.sh.v3.fixes

diff --git testcases/kernel/controllers/cgroup_lib.sh testcases/kernel/controllers/cgroup_lib.sh
index c164932fa..7918b5636 100644
--- testcases/kernel/controllers/cgroup_lib.sh
+++ testcases/kernel/controllers/cgroup_lib.sh
@@ -33,7 +33,7 @@ is_cgroup_subsystem_available_and_enabled()
 	[ $# -eq 0 ] && tst_brk TBROK "is_cgroup_subsystem_available_and_enabled: subsystem not defined"
 
 	val=$(grep -w $subsystem /proc/cgroups | awk '{ print $4 }')
-	[ "x$val" = "x1" ] && return 0
+	[ "$val" = "1" ] && return 0
 
 	return 1
 }
diff --git testcases/kernel/controllers/memcg/stress/Makefile testcases/kernel/controllers/memcg/stress/Makefile
index 773363cfc..a9678bf3b 100644
--- testcases/kernel/controllers/memcg/stress/Makefile
+++ testcases/kernel/controllers/memcg/stress/Makefile
@@ -1,9 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 # Copyright (C) 2009, Cisco Systems Inc.
 # Author: Ngie Cooper, September 2009
-#
-#    kernel/controllers/memcg/stress testcase suite Makefile.
-#
 
 top_srcdir		?= ../../../../..
 
diff --git testcases/kernel/controllers/memcg/stress/memcg_process_stress.c testcases/kernel/controllers/memcg/stress/memcg_process_stress.c
index 6af550012..422deaeee 100644
--- testcases/kernel/controllers/memcg/stress/memcg_process_stress.c
+++ testcases/kernel/controllers/memcg/stress/memcg_process_stress.c
@@ -1,7 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) 2009 FUJITSU LIMITED
- *
  * Author: Li Zefan <lizf@cn.fujitsu.com>
  */
 
diff --git testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
index 652d99e55..9972b6c45 100755
--- testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
+++ testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
@@ -7,25 +7,23 @@
 # Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>
 # Added memcg enable/disable functionality: Rishikesh K Rajak <risrajak@linux.vnet.ibm.com
 
-TST_TESTFUNC=testcase_
-TST_SETUP=do_setup
-TST_CLEANUP=do_cleanup
+TST_TESTFUNC=test
+TST_SETUP=setup
+TST_CLEANUP=cleanup
 TST_CNT=2
 TST_NEEDS_ROOT=1
 TST_NEEDS_CMDS="mount umount cat kill mkdir rmdir grep awk cut"
 
-# Each test case runs for 900 secs when everything fine...
-# ...so the default 5mins timeout is not enough.
+# Each test case runs for 900 secs when everything fine
+# therefore the default 5 mins timeout is not enough.
 LTP_TIMEOUT_MUL=7
 
-. tst_test.sh
 . cgroup_lib.sh
 
-do_setup()
+setup()
 {
-	if ! is_cgroup_subsystem_available_and_enabled "memory";then
-		tst_res TWARN "Either Kernel does not support MEMORY resource controller or feature not enabled"
-		tst_brk TCONF ignored "Skipping all memory cgroup testcases...."
+	if ! is_cgroup_subsystem_available_and_enabled "memory"; then
+		tst_brk TCONF "Either kernel does not support Memory Resource Controller or feature not enabled"
 	fi
 
 	echo 3 > /proc/sys/vm/drop_caches
@@ -40,7 +38,7 @@ do_setup()
 	tst_res TINFO "Calculated available memory $MEM MB"
 }
 
-do_cleanup()
+cleanup()
 {
 	if [ -e /dev/memcg ]; then
 		umount /dev/memcg 2> /dev/null
@@ -50,15 +48,12 @@ do_cleanup()
 
 do_mount()
 {
-	do_cleanup
+	cleanup
 
 	mkdir /dev/memcg 2> /dev/null
 	mount -t cgroup -omemory memcg /dev/memcg
 }
 
-
-# Run the stress test
-#
 # $1 - Number of cgroups
 # $2 - Allocated how much memory in one process? in MB
 # $3 - The interval to touch memory in a process
@@ -69,34 +64,31 @@ run_stress()
 
 	do_mount
 
-	for i in $(seq 0 $(($1-1)))
-	do
+	for i in $(seq 0 $(($1-1))); do
 		mkdir /dev/memcg/$i 2> /dev/null
 		memcg_process_stress $2 $3 &
-		eval local pid$i=$!
+		eval pid$i=$!
 
 		eval echo \$pid$i > /dev/memcg/$i/tasks
 	done
 
-	for i in $(seq 0 $(($1-1)))
-	do
+	for i in $(seq 0 $(($1-1))); do
 		eval kill -USR1 \$pid$i 2> /dev/null
 	done
 
 	sleep $4
 
-	for i in $(seq 0 $(($1-1)))
-	do
+	for i in $(seq 0 $(($1-1))); do
 		eval kill -KILL \$pid$i 2> /dev/null
 		eval wait \$pid$i
 
 		rmdir /dev/memcg/$i 2> /dev/null
 	done
 
-	do_cleanup
+	cleanup
 }
 
-testcase_1()
+test1()
 {
 	tst_res TINFO "testcase 1 started...it will run for $RUN_TIME secs"
 
@@ -105,7 +97,7 @@ testcase_1()
 	tst_res TPASS "stress test 1 passed"
 }
 
-testcase_2()
+test2()
 {
 	tst_res TINFO "testcase 2 started...it will run for $RUN_TIME secs"
 

  reply	other threads:[~2019-01-29 17:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-04 10:54 [LTP] [PATCH v3 0/1] memcg_stress newlib porting Cristian Marussi
2019-01-04 10:54 ` [LTP] [PATCH v3] memcg_stress_test.sh: ported to newlib Cristian Marussi
2019-01-28 16:32   ` Petr Vorel
2019-01-29 17:50     ` Petr Vorel [this message]
2019-01-29 19:25       ` Cristian Marussi
2019-02-01 13:45         ` Petr Vorel
2019-02-04 11:56           ` Cristian Marussi
2019-02-04 23:34             ` Petr Vorel
2019-02-05 17:46               ` Cristian Marussi
2019-02-14  8:32               ` Xiao Yang
2019-02-15 10:09                 ` Cristian Marussi

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=20190129175019.GA14252@dell5510 \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    /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.