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; 3+ 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] 3+ messages in thread

* [LTP] [PATCH] cpuset/cpuset_memory_pressure_test: Check whether the swap partition is configured
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Samuel Zou @ 2021-06-30  2:07 UTC (permalink / raw)
  To: ltp

ping, and has anybody met the same issue?

On 2021/4/6 19:15, Zou Wei wrote:
> --------------------------
> 
> 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))
> 

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

* Re: [LTP] [PATCH] cpuset/cpuset_memory_pressure_test: Check whether the swap partition is configured
@ 2021-09-14  9:31   ` Richard Palethorpe
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Palethorpe @ 2021-09-14  9:31 UTC (permalink / raw)
  To: Zou Wei; +Cc: ltp

Hello,

Zou Wei <zou_wei@huawei.com> writes:

> --------------------------
>
> 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

The original use of awk and free looks error prone. Perhaps it would be
better to do?

sw_mem=$(cat /proc/meminfo | awk '/SwapTotal/ { print $2 }')


> +
> +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


-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

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

Thread overview: 3+ 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.