diff mbox series

[OSSTEST] examine/cpu: fix fetching number of threads

Message ID 20200423144303.55251-1-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show
Series [OSSTEST] examine/cpu: fix fetching number of threads | expand

Commit Message

Roger Pau Monné April 23, 2020, 2:43 p.m. UTC
The way to fetch the number of threads from the output of xl info is
wrong, as the result of =~ is either true or false, but will never be a
numeric value.

Fix the regex to have a capture group in order to fetch the number of
threads, and store the capture in the threads variable.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
 ts-examine-cpu | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ian Jackson April 23, 2020, 3:02 p.m. UTC | #1
Roger Pau Monne writes ("[PATCH OSSTEST] examine/cpu: fix fetching number of threads"):
> The way to fetch the number of threads from the output of xl info is
> wrong, as the result of =~ is either true or false, but will never be a
> numeric value.
> 
> Fix the regex to have a capture group in order to fetch the number of
> threads, and store the capture in the threads variable.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

I will push this to pretest.  Hopefully it will go through quickly...
diff mbox series

Patch

diff --git a/ts-examine-cpu b/ts-examine-cpu
index 81cf7544..fbf01dfb 100755
--- a/ts-examine-cpu
+++ b/ts-examine-cpu
@@ -26,7 +26,8 @@  our ($whhost) = @ARGV;
 $whhost ||= 'host';
 our $ho= selecthost($whhost);
 our $info = target_cmd_output_root($ho, 'xl info', 10);
-our $threads = $info =~ /^threads_per_core\s*:\s.*/m;
+$info =~ /^threads_per_core\s*:\s(.*)$/m or die "missing or malformed info";
+our $threads = $1;
 
 logm("$ho->{Ident} threads per core: $threads");
 hostflag_putative_record($ho, "hw-smt", $threads > 1);