All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] cpuhotplug_hotplug.sh: fix the return of cpu number
@ 2015-08-24 10:04 Guangwen Feng
  2015-09-04  7:32 ` Guangwen Feng
  2015-09-07 17:19 ` Cyril Hrubis
  0 siblings, 2 replies; 3+ messages in thread
From: Guangwen Feng @ 2015-08-24 10:04 UTC (permalink / raw)
  To: ltp-list

In shell, function's return value can not exceed 255, if we run
the test on machines which have more than 255 cpus, the result
will be incorrect, so fix that by using global variable instead.

Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
---
 testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh   | 2 +-
 testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh   | 2 +-
 testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh   | 2 +-
 testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh   | 4 ++--
 testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh   | 2 +-
 testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug06.sh   | 2 +-
 testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh   | 2 +-
 .../kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh      | 8 ++++----
 8 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh
index 8ae1379..e75da21 100755
--- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh
@@ -112,7 +112,7 @@ LOOP_COUNT=1
 tst_check_cmds perl
 
 get_present_cpus_num
-if [ $? -lt 2 ]; then
+if [ $PRESENT_CPUS_NUM -lt 2 ]; then
 	tst_brkm TCONF "system doesn't have required CPU hotplug support"
 fi
 
diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh
index c42cc1b..f6b4345 100755
--- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh
@@ -55,7 +55,7 @@ done
 LOOP_COUNT=1
 
 get_present_cpus_num
-if [ $? -lt 2 ]; then
+if [ $PRESENT_CPUS_NUM -lt 2 ]; then
 	tst_brkm TCONF "system doesn't have required CPU hotplug support"
 fi
 
diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh
index 3469b10..a68ac7d 100755
--- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh
@@ -64,7 +64,7 @@ done
 LOOP_COUNT=1
 
 get_present_cpus_num
-cpus_num=$?
+cpus_num=${PRESENT_CPUS_NUM}
 if [ $cpus_num -lt 2 ]; then
 	tst_brkm TCONF "system doesn't have required CPU hotplug support"
 fi
diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh
index 58a822e..3ecbb36 100755
--- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh
@@ -49,13 +49,13 @@ done
 LOOP_COUNT=1
 
 get_present_cpus_num
-cpus_num=$?
+cpus_num=${PRESENT_CPUS_NUM}
 if [ $cpus_num -lt 2 ]; then
 	tst_brkm TCONF "system doesn't have required CPU hotplug support"
 fi
 
 get_hotplug_cpus_num
-if [ $? -lt 1 ]; then
+if [ $HOTPLUG_CPUS_NUM -lt 1 ]; then
 	tst_brkm TCONF "system doesn't have at least one hotpluggable CPU"
 fi
 
diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh
index 60382c8..8009af2 100755
--- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh
@@ -56,7 +56,7 @@ LOOP_COUNT=1
 tst_check_cmds sar
 
 get_present_cpus_num
-if [ $? -lt 2 ]; then
+if [ $PRESENT_CPUS_NUM -lt 2 ]; then
 	tst_brkm TCONF "system doesn't have required CPU hotplug support"
 fi
 
diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug06.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug06.sh
index 6710fad..5e71abf 100755
--- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug06.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug06.sh
@@ -50,7 +50,7 @@ done
 LOOP_COUNT=1
 
 get_present_cpus_num
-if [ $? -lt 2 ]; then
+if [ $PRESENT_CPUS_NUM -lt 2 ]; then
 	tst_brkm TCONF "system doesn't have required CPU hotplug support"
 fi
 
diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh
index 7edb3a9..81dc225 100755
--- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh
@@ -56,7 +56,7 @@ done
 LOOP_COUNT=1
 
 get_present_cpus_num
-if [ $? -lt 2 ]; then
+if [ $PRESENT_CPUS_NUM -lt 2 ]; then
 	tst_brkm TCONF "system doesn't have required CPU hotplug support"
 fi
 
diff --git a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
index 6920393..be8bce2 100644
--- a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
@@ -165,11 +165,11 @@ get_present_cpus()
 
 # get_present_cpus_num()
 #
-#  Prints the number of present CPUs
+#  Gets the number of present CPUs
 #
 get_present_cpus_num()
 {
-    return $(get_present_cpus | wc -w)
+	PRESENT_CPUS_NUM=`get_present_cpus | wc -w`
 }
 
 # get_hotplug_cpus()
@@ -192,11 +192,11 @@ get_hotplug_cpus()
 
 # get_hotplug_cpus_num()
 #
-#  Prints the number of hotpluggable CPUs
+#  Gets the number of hotpluggable CPUs
 #
 get_hotplug_cpus_num()
 {
-    return $(get_hotplug_cpus | wc -w)
+	HOTPLUG_CPUS_NUM=`get_hotplug_cpus | wc -w`
 }
 
 # get_all_cpu_states()
-- 
1.8.4.2


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] cpuhotplug_hotplug.sh: fix the return of cpu number
  2015-08-24 10:04 [LTP] [PATCH] cpuhotplug_hotplug.sh: fix the return of cpu number Guangwen Feng
@ 2015-09-04  7:32 ` Guangwen Feng
  2015-09-07 17:19 ` Cyril Hrubis
  1 sibling, 0 replies; 3+ messages in thread
From: Guangwen Feng @ 2015-09-04  7:32 UTC (permalink / raw)
  To: ltp-list

Hello!
    ping.

Best Regards,
Guangwen Feng

On 2015/08/24 18:04, Guangwen Feng wrote:
> In shell, function's return value can not exceed 255, if we run
> the test on machines which have more than 255 cpus, the result
> will be incorrect, so fix that by using global variable instead.
> 
> Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
> ---
>  testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh   | 2 +-
>  testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh   | 2 +-
>  testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh   | 2 +-
>  testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh   | 4 ++--
>  testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh   | 2 +-
>  testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug06.sh   | 2 +-
>  testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh   | 2 +-
>  .../kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh      | 8 ++++----
>  8 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh
> index 8ae1379..e75da21 100755
> --- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh
> +++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh
> @@ -112,7 +112,7 @@ LOOP_COUNT=1
>  tst_check_cmds perl
>  
>  get_present_cpus_num
> -if [ $? -lt 2 ]; then
> +if [ $PRESENT_CPUS_NUM -lt 2 ]; then
>  	tst_brkm TCONF "system doesn't have required CPU hotplug support"
>  fi
>  
> diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh
> index c42cc1b..f6b4345 100755
> --- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh
> +++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh
> @@ -55,7 +55,7 @@ done
>  LOOP_COUNT=1
>  
>  get_present_cpus_num
> -if [ $? -lt 2 ]; then
> +if [ $PRESENT_CPUS_NUM -lt 2 ]; then
>  	tst_brkm TCONF "system doesn't have required CPU hotplug support"
>  fi
>  
> diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh
> index 3469b10..a68ac7d 100755
> --- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh
> +++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh
> @@ -64,7 +64,7 @@ done
>  LOOP_COUNT=1
>  
>  get_present_cpus_num
> -cpus_num=$?
> +cpus_num=${PRESENT_CPUS_NUM}
>  if [ $cpus_num -lt 2 ]; then
>  	tst_brkm TCONF "system doesn't have required CPU hotplug support"
>  fi
> diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh
> index 58a822e..3ecbb36 100755
> --- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh
> +++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug04.sh
> @@ -49,13 +49,13 @@ done
>  LOOP_COUNT=1
>  
>  get_present_cpus_num
> -cpus_num=$?
> +cpus_num=${PRESENT_CPUS_NUM}
>  if [ $cpus_num -lt 2 ]; then
>  	tst_brkm TCONF "system doesn't have required CPU hotplug support"
>  fi
>  
>  get_hotplug_cpus_num
> -if [ $? -lt 1 ]; then
> +if [ $HOTPLUG_CPUS_NUM -lt 1 ]; then
>  	tst_brkm TCONF "system doesn't have at least one hotpluggable CPU"
>  fi
>  
> diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh
> index 60382c8..8009af2 100755
> --- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh
> +++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh
> @@ -56,7 +56,7 @@ LOOP_COUNT=1
>  tst_check_cmds sar
>  
>  get_present_cpus_num
> -if [ $? -lt 2 ]; then
> +if [ $PRESENT_CPUS_NUM -lt 2 ]; then
>  	tst_brkm TCONF "system doesn't have required CPU hotplug support"
>  fi
>  
> diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug06.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug06.sh
> index 6710fad..5e71abf 100755
> --- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug06.sh
> +++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug06.sh
> @@ -50,7 +50,7 @@ done
>  LOOP_COUNT=1
>  
>  get_present_cpus_num
> -if [ $? -lt 2 ]; then
> +if [ $PRESENT_CPUS_NUM -lt 2 ]; then
>  	tst_brkm TCONF "system doesn't have required CPU hotplug support"
>  fi
>  
> diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh
> index 7edb3a9..81dc225 100755
> --- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh
> +++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh
> @@ -56,7 +56,7 @@ done
>  LOOP_COUNT=1
>  
>  get_present_cpus_num
> -if [ $? -lt 2 ]; then
> +if [ $PRESENT_CPUS_NUM -lt 2 ]; then
>  	tst_brkm TCONF "system doesn't have required CPU hotplug support"
>  fi
>  
> diff --git a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
> index 6920393..be8bce2 100644
> --- a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
> +++ b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
> @@ -165,11 +165,11 @@ get_present_cpus()
>  
>  # get_present_cpus_num()
>  #
> -#  Prints the number of present CPUs
> +#  Gets the number of present CPUs
>  #
>  get_present_cpus_num()
>  {
> -    return $(get_present_cpus | wc -w)
> +	PRESENT_CPUS_NUM=`get_present_cpus | wc -w`
>  }
>  
>  # get_hotplug_cpus()
> @@ -192,11 +192,11 @@ get_hotplug_cpus()
>  
>  # get_hotplug_cpus_num()
>  #
> -#  Prints the number of hotpluggable CPUs
> +#  Gets the number of hotpluggable CPUs
>  #
>  get_hotplug_cpus_num()
>  {
> -    return $(get_hotplug_cpus | wc -w)
> +	HOTPLUG_CPUS_NUM=`get_hotplug_cpus | wc -w`
>  }
>  
>  # get_all_cpu_states()
> 

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] cpuhotplug_hotplug.sh: fix the return of cpu number
  2015-08-24 10:04 [LTP] [PATCH] cpuhotplug_hotplug.sh: fix the return of cpu number Guangwen Feng
  2015-09-04  7:32 ` Guangwen Feng
@ 2015-09-07 17:19 ` Cyril Hrubis
  1 sibling, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2015-09-07 17:19 UTC (permalink / raw)
  To: Guangwen Feng; +Cc: ltp-list

Hi!
> diff --git a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
> index 6920393..be8bce2 100644
> --- a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
> +++ b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
> @@ -165,11 +165,11 @@ get_present_cpus()
>  
>  # get_present_cpus_num()
>  #
> -#  Prints the number of present CPUs
> +#  Gets the number of present CPUs
>  #
>  get_present_cpus_num()
>  {
> -    return $(get_present_cpus | wc -w)
> +	PRESENT_CPUS_NUM=`get_present_cpus | wc -w`
>  }

Passing the value by global variable is ugly. Why don't we echo the
value here as:

echo $(get_present_cpus |wc -w), or even just call 'get_presnt_cpus |wc -w'

and do:

if [ $(get_present_cpus_num) -lt 2 ]; then
...
fi

in the testcases?

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2015-09-07 17:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-24 10:04 [LTP] [PATCH] cpuhotplug_hotplug.sh: fix the return of cpu number Guangwen Feng
2015-09-04  7:32 ` Guangwen Feng
2015-09-07 17:19 ` Cyril Hrubis

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.