All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] cpuset/cpuset_memory_pressure_test: Check whether the swap partition is configured
@ 2021-04-06 11:15 Zou Wei
  2021-06-30  2:07 ` Samuel Zou
  2021-09-14  9:31   ` Richard Palethorpe
  0 siblings, 2 replies; 4+ messages in thread
From: Zou Wei @ 2021-04-06 11:15 UTC (permalink / raw)
  To: ltp

--------------------------

1. Fixed a bug where a null value is obtained because swap is not in
   the fourth line of the free result
free -m
        total        used        free      shared  buff/cache   available
Mem:   128135        3857      120633         158        3644      123219
Swap:    8191          82        8109

free -m
        total       used       free     shared    buffers     cached
Mem:   419694       9464     410230        234        435       6005
-/+ buffers/cache:       3022     416671
Swap:    2053          0       2053

2. If no swap partition is configured in the test environment,
   the testcase will be failed:

cpuset_memory_pressure 7 TFAIL: sub group's memory_pressure
didn't have memory pressure rate.
cpuset_memory_pressure 9 TFAIL: root group's memory_pressure
didn't have memory pressure rate.
cpuset_memory_pressure 11 TFAIL: root group's memory_pressure
didn't have memory pressure rate.

Signed-off-by: Zou Wei <zou_wei@huawei.com>
---
 .../cpuset_memory_pressure_testset.sh                        | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh
index eddd7f6..2a2d2a1 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh
@@ -35,8 +35,16 @@ exit_status=0
 # usable physical memory
 py_mem=$(free -m | awk '{if(NR==2) print $4 + $6 + $7}')
 
-# free swap space
-sw_mem=$(free -m | awk '{if(NR==4) print $4}')
+# total swap space
+sw_mem=$(free -m | awk '{if(NR==4) print $2}')
+if [ -z $sw_mem ]; then
+	sw_mem=$(free -m | awk '{if(NR==3) print $2}')
+fi
+
+if [ $sw_mem -eq 0 ]; then
+	tst_resm TCONF "The size of the swap partition is zero."
+	exit 32
+fi
 
 # the memory which is going to be used
 usemem=$((py_mem - 20))
-- 
2.6.2


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

end of thread, other threads:[~2021-09-14  9:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-06 11:15 [LTP] [PATCH] cpuset/cpuset_memory_pressure_test: Check whether the swap partition is configured Zou Wei
2021-06-30  2:07 ` Samuel Zou
2021-09-14  9:31 ` Richard Palethorpe
2021-09-14  9:31   ` Richard Palethorpe

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.