Skip to content

Commit 5739438

Browse files
committed
ktest: Add variable run_command_status to save status of commands executed
Create a variable called run_command_status that saves the status of the executed commands and can be used by other functions later to test for status. Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 6474ace commit 5739438

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tools/testing/ktest/ktest.pl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
my $iteration = 0;
180180
my $successes = 0;
181181
my $stty_orig;
182+
my $run_command_status = 0;
182183

183184
my $bisect_good;
184185
my $bisect_bad;
@@ -1736,11 +1737,8 @@ sub run_command {
17361737
}
17371738

17381739
waitpid($pid, 0);
1739-
my $failed = $?;
1740-
1741-
if ($hit_timeout) {
1742-
$failed = 1;
1743-
}
1740+
# shift 8 for real exit status
1741+
$run_command_status = $? >> 8;
17441742

17451743
close(CMD);
17461744
close(LOG) if ($dolog);
@@ -1755,13 +1753,17 @@ sub run_command {
17551753
doprint "[$delta seconds] ";
17561754
}
17571755

1758-
if ($failed) {
1756+
if ($hit_timeout) {
1757+
$run_command_status = 1;
1758+
}
1759+
1760+
if ($run_command_status) {
17591761
doprint "FAILED!\n";
17601762
} else {
17611763
doprint "SUCCESS\n";
17621764
}
17631765

1764-
return !$failed;
1766+
return !$run_command_status;
17651767
}
17661768

17671769
sub run_ssh {
@@ -2578,16 +2580,15 @@ sub answer_bisect {
25782580
}
25792581

25802582
sub child_run_test {
2581-
my $failed = 0;
25822583

25832584
# child should have no power
25842585
$reboot_on_error = 0;
25852586
$poweroff_on_error = 0;
25862587
$die_on_failure = 1;
25872588

2588-
run_command $run_test, $testlog or $failed = 1;
2589+
run_command $run_test, $testlog;
25892590

2590-
exit $failed;
2591+
exit $run_command_status;
25912592
}
25922593

25932594
my $child_done;
@@ -3371,7 +3372,6 @@ sub config_bisect {
33713372
save_config \%good_configs, $good_config;
33723373
save_config \%bad_configs, $bad_config;
33733374

3374-
33753375
if (defined($config_bisect_check) && $config_bisect_check ne "0") {
33763376
if ($config_bisect_check ne "good") {
33773377
doprint "Testing bad config\n";

0 commit comments

Comments
 (0)