From 0cda6dafcd27ebe2c55d2ab9cf7cf4d262d0fc46 Mon Sep 17 00:00:00 2001 From: Morris Jette <jette@schedmd.com> Date: Fri, 25 Mar 2016 13:20:50 -0700 Subject: [PATCH] Harden test for node names without numeric suffix --- testsuite/expect/globals | 8 +++++++- testsuite/expect/test1.83 | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/testsuite/expect/globals b/testsuite/expect/globals index 890821a7108..d229ddb0d97 100755 --- a/testsuite/expect/globals +++ b/testsuite/expect/globals @@ -2414,13 +2414,19 @@ proc make_bash_script { script_name script_contents } { # # Purpose: Given a hostname, return it's numeric suffix # -# Returns: numerical suffix for input 'hostname' +# Returns: numerical suffix for input 'hostname' or -1 if not a number # # Input: hostname -- hostname for which to return suffix # ################################################################ proc get_suffix { hostname } { set host_len [string length $hostname] + set host_inx [expr $host_len-1] + set host_char [string index $hostname $host_inx] + if {[string compare $host_char "0"] < 0 || [string compare $host_char "9"] > 0} { + return -1 + } + for {set host_inx [expr $host_len-1]} {$host_inx >= 0} {incr host_inx -1} { set host_char [string index $hostname $host_inx] if {[string compare $host_char "0"] < 0} { break } diff --git a/testsuite/expect/test1.83 b/testsuite/expect/test1.83 index 5cbd451bd4a..9274038636c 100755 --- a/testsuite/expect/test1.83 +++ b/testsuite/expect/test1.83 @@ -143,6 +143,11 @@ set host_0_num [get_suffix $host_0_name] set host_1_num [get_suffix $host_1_name] set host_2_num [get_suffix $host_2_name] +if {$host_0_num == -1 || $host_1_num == -1 || $host_2_num == -1} { + send_user "\nWARNING: node names lack numeric suffix\n" + exit $exit_code +} + if {$host_1_num != [expr $host_0_num + 1]} { send_user "\nFAILURE: node sequence number not contiguous\n" set exit_code 1 -- GitLab