All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] cpuset/cpuset_memory_pressure_test: Check whether the swap partition is configured
Date: Tue, 14 Sep 2021 10:31:12 +0100	[thread overview]
Message-ID: <87v933jyfz.fsf@suse.de> (raw)
In-Reply-To: <1617707717-63693-1-git-send-email-zou_wei@huawei.com>

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.

WARNING: multiple messages have this Message-ID (diff)
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Zou Wei <zou_wei@huawei.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] cpuset/cpuset_memory_pressure_test: Check whether the swap partition is configured
Date: Tue, 14 Sep 2021 10:31:12 +0100	[thread overview]
Message-ID: <87v933jyfz.fsf@suse.de> (raw)
Message-ID: <20210914093112.7JBbZYiv9ZgZpg4I1o-bj8Eua137flBqqqzQKkEK3-g@z> (raw)
In-Reply-To: <1617707717-63693-1-git-send-email-zou_wei@huawei.com>

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

  parent reply	other threads:[~2021-09-14  9:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2021-09-14  9:31   ` Richard Palethorpe

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=87v933jyfz.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --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.