2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-03 03:50:08 +00:00

Merge pull request #7151 from besawn/xcattest

Improve xcattest check:output syntax checking
This commit is contained in:
besawn 2022-04-25 12:44:33 -04:00 committed by GitHub
commit 1e88fdc4b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 92 additions and 5 deletions

View File

@ -152,7 +152,7 @@ check:rc==0
#Remove last generated dump
cmd: rspconfig $$CN dump -l | tail -1 | cut -d ' ' -f2 | tr -d "[]" | xargs -i{} rspconfig $$CN dump -c {}
check:rc==0
check:output=clear
check:output==clear
end
start:openbmc_rspconfig_ntpservers

View File

@ -27,7 +27,7 @@ cmd:gettab -H groups=master site.key
check:rc!=0
cmd:gettab -H key=master site.groups
check:rc==0
check:output=site.groups:
check:output==site.groups:
end

View File

@ -0,0 +1,77 @@
start:xcattest_checkoutput_exactmatch
description:check:output== match an exact string
label:mn_only,ci_test
cmd:echo "Test"
check:output==Test
end
start:xcattest_checkoutput_not_exactmatch
description:check:output!= check that the output does not match an exact string
label:mn_only,ci_test
cmd:echo "Test"
check:output!=Tes
end
start:xcattest_checkoutput_regexmatch_full
description:check:output=~ matching a full string
label:mn_only,ci_test
cmd:echo "Running test now"
check:output=~Running test now
end
start:xcattest_checkoutput_regexmatch_start
description:checkoutput=~ matching a partial string from the start of the output
label:mn_only,ci_test
cmd:echo "Running test now"
check:output=~Running te
end
start:xcattest_checkoutput_regexmatch_middle
description:checkoutput=~ matching a partial string in the middle of the output
label:mn_only,ci_test
cmd:echo "Running test now"
check:output=~ing test
end
start:xcattest_checkoutput_regexmatch_end
description:checkoutput=~ matching a partial string up to the end of the output
label:mn_only,ci_test
cmd:echo "Running test now"
check:output=~ now
end
start:xcattest_checkoutput_not_regexmatch_independent
description:check:output!~ two unrelated strings
label:mn_only,ci_test
cmd:echo "Running test now"
check:output!~uptime
end
start:xcattest_checkoutput_not_regexmatch_superstring
description:check:output!~ where the tested string is larger than the output
label:mn_only,ci_test
cmd:echo "Running test now"
check:output!~Running test now, please wait
end
start:xcattest_checkoutput_not_regexmatch_start
description:check:output!~ where the tested string fails near the start
label:mn_only,ci_test
cmd:echo "Running test now"
check:output!~Running tess
end
start:xcattest_checkoutput_not_regexmatch_middle
description:check:output!~ where the tested string fails in the middle
label:mn_only,ci_test
cmd:echo "Running test now"
check:output!~ing test
end
start:xcattest_checkoutput_not_regexmatch_end
description:check:output!~ where the tested string fails near the end
label:mn_only,ci_test
cmd:echo "Running test now"
check:output!~est now pl
end

View File

@ -1435,8 +1435,7 @@ sub run_case {
log_this($running_log_fd, "CHECK:rc $op $rvalue\t[Pass]");
push(@caselog, "CHECK:rc $op $rvalue\t[Pass]");
}
} elsif ($check =~ /output\s*([=!~]+)\s*(\S.*)/
&& $check !~ /output\s*([=!~])\1/) {
} elsif ($check =~ /output\s*(==|!=|=~|!~)\s*(\S.*)/) {
my $lvalue = join("\n", @output);
my $op = $1;
my $rvalue = $2;
@ -1447,6 +1446,11 @@ sub run_case {
|| (($op eq '==') && ($lvalue ne $rvalue))
|| (($op eq '!=') && ($lvalue eq $rvalue))) {
$failflag = 1;
} elsif (($op ne '=~') && ($op ne '!~') && ($op ne '==') && ($op ne '!=')) {
$failflag = 1;
log_this($running_log_fd, "CHECK:output unrecognized operator: $op\t[Failed]");
push(@caselog, "CHECK:output unrecognized operator: $op\t[Failed]");
last;
}
if ($failflag) {
log_this($running_log_fd, "CHECK:output $op $rvalue\t[Failed]");
@ -1491,7 +1495,13 @@ sub run_case {
} else {
log_this($running_log_fd, "CHECK:output $op $rvalue\t[Pass]");
push(@caselog, "CHECK:output $op $rvalue\t[Pass]");
} } }
}
} else {
$failflag = 1;
log_this($running_log_fd, "Unrecognized testcase syntax: CHECK:$check\t[Failed]");
push(@caselog, "Unrecognized testcase syntax: CHECK:$check\t[Failed]");
}
}
foreach my $cmdcheck (@{ $cases_ref->[ $case_name_index_map_ref->{$case} ]->{cmdcheck}->[$j] }) {
if ($cmdcheck) {
&runcmd($cmdcheck);