All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiao Yang <yangx.jy@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] runpwtests03: use expr to calculate total_cpus for runpwtests03
Date: Tue, 25 Jun 2019 18:59:51 +0800	[thread overview]
Message-ID: <5D11FEA7.1000104@cn.fujitsu.com> (raw)
In-Reply-To: <20190625100351.19800-1-po-hsu.lin@canonical.com>

On 2019/06/25 18:03, Po-Hsu Lin wrote:
> The arithmetic operation (( total_cpus-=1 )) does not work for dash,
> which was symbolic linked to /bin/sh on some OS like Ubuntu.
>
> In such case, people will see error like:
>    runpwtests03.sh: total_cpus-=1: not found
>
> And this further leads to access for a non-existing file and cause
> false-positive result in the end:
>    runpwtests03.sh: cannot create
>    /sys/devices/system/cpu/cpu8/cpufreq/scaling_governor: Directory nonexistent
>    runpwtests03.sh: FAIL: Unable to set governor -- powersave for cpu8
>    Power_Management03 2 TFAIL: Changing governors
>
> Use expr instead for fix this issue.
>
> Signed-off-by: Po-Hsu Lin<po-hsu.lin@canonical.com>
> ---
>   testcases/kernel/power_management/runpwtests03.sh | 9 +++------
>   1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/testcases/kernel/power_management/runpwtests03.sh b/testcases/kernel/power_management/runpwtests03.sh
> index 11197937f..3fb85d273 100755
> --- a/testcases/kernel/power_management/runpwtests03.sh
> +++ b/testcases/kernel/power_management/runpwtests03.sh
> @@ -25,8 +25,7 @@ export TST_TOTAL=4
>   . pm_include.sh
>
>   check_cpufreq_sysfs_files() {
> -	total_cpus=$(tst_ncpus)
> -	(( total_cpus-=1 ))
> +	total_cpus=`expr $(tst_ncpus) - 1`

Hi,

It's wrong for single variable to use $(), did you mean ${tst_ncpus}?

Best Regards,
Xiao Yang
>   	RC=0
>
>   	for cpu in $(seq 0 "${total_cpus}" )
> @@ -51,8 +50,7 @@ check_cpufreq_sysfs_files() {
>   change_govr() {
>   	available_govr=$(get_supporting_govr)
>
> -	total_cpus=$(tst_ncpus)
> -	(( total_cpus-=1 ))
> +	total_cpus=`expr $(tst_ncpus) - 1`
>   	RC=0
>
>   	for cpu in $(seq 0 "${total_cpus}" )
> @@ -79,8 +77,7 @@ change_freq() {
>   	available_govr=$(get_supporting_govr)
>   	RC=0
>
> -	total_cpus=$(tst_ncpus)
> -	(( total_cpus-=1 ))
> +	total_cpus=`expr $(tst_ncpus) - 1`
>
>   	if ( echo ${available_govr} | grep -i "userspace" \
>   		>/dev/null 2>&1 ); then




  reply	other threads:[~2019-06-25 10:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-25 10:03 [LTP] [PATCH] runpwtests03: use expr to calculate total_cpus for runpwtests03 Po-Hsu Lin
2019-06-25 10:59 ` Xiao Yang [this message]
2019-06-25 16:13   ` Po-Hsu Lin
2019-06-26  2:54     ` Xiao Yang
2019-06-26  3:45       ` Po-Hsu Lin
2019-06-27  8:04         ` Xiao Yang

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=5D11FEA7.1000104@cn.fujitsu.com \
    --to=yangx.jy@cn.fujitsu.com \
    --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.