diff options
author | Masayoshi Mizuma <m.mizuma@jp.fujitsu.com> | 2019-04-18 09:59:43 -0400 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2019-04-18 11:25:13 -0400 |
commit | 37e1677330bdc2e96e70f18701e589876f054c67 (patch) | |
tree | 8ca7a0bca05bc2536d73727664c3c3af044c72f4 | |
parent | 68911069f509ba3bf0f513d9af00309e07932906 (diff) |
ktest: introduce REBOOT_RETURN_CODE to confirm the result of REBOOT
Unexpected power cycle occurs while the installation of the
kernel.
ssh root@Test sync ... [0 seconds] SUCCESS
ssh root@Test reboot ... [1 second] FAILED!
virsh destroy Test; sleep 5; virsh start Test ... [6 seconds] SUCCESS
That is because REBOOT, the default is "ssh $SSH_USER@$MACHINE
reboot", exits as 255 even if the reboot is successfully done,
like as:
]# ssh root@Test reboot
Connection to Test closed by remote host.
]# echo $?
255
]#
To avoid the unexpected power cycle, introduce a new parameter,
REBOOT_RETURN_CODE to judge whether REBOOT is successfully done
or not.
Link: http://lkml.kernel.org/r/20190418135943.12640-1-msys.mizuma@gmail.com
Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rwxr-xr-x | tools/testing/ktest/ktest.pl | 9 | ||||
-rw-r--r-- | tools/testing/ktest/sample.conf | 4 |
2 files changed, 13 insertions, 0 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 3bec099a6cf4..275ad8ac8872 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
@@ -58,6 +58,7 @@ my %default = ( | |||
58 | "SCP_TO_TARGET" => "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE", | 58 | "SCP_TO_TARGET" => "scp \$SRC_FILE \$SSH_USER\@\$MACHINE:\$DST_FILE", |
59 | "SCP_TO_TARGET_INSTALL" => "\${SCP_TO_TARGET}", | 59 | "SCP_TO_TARGET_INSTALL" => "\${SCP_TO_TARGET}", |
60 | "REBOOT" => "ssh \$SSH_USER\@\$MACHINE reboot", | 60 | "REBOOT" => "ssh \$SSH_USER\@\$MACHINE reboot", |
61 | "REBOOT_RETURN_CODE" => 255, | ||
61 | "STOP_AFTER_SUCCESS" => 10, | 62 | "STOP_AFTER_SUCCESS" => 10, |
62 | "STOP_AFTER_FAILURE" => 60, | 63 | "STOP_AFTER_FAILURE" => 60, |
63 | "STOP_TEST_AFTER" => 600, | 64 | "STOP_TEST_AFTER" => 600, |
@@ -105,6 +106,7 @@ my $reboot_type; | |||
105 | my $reboot_script; | 106 | my $reboot_script; |
106 | my $power_cycle; | 107 | my $power_cycle; |
107 | my $reboot; | 108 | my $reboot; |
109 | my $reboot_return_code; | ||
108 | my $reboot_on_error; | 110 | my $reboot_on_error; |
109 | my $switch_to_good; | 111 | my $switch_to_good; |
110 | my $switch_to_test; | 112 | my $switch_to_test; |
@@ -278,6 +280,7 @@ my %option_map = ( | |||
278 | "POST_BUILD_DIE" => \$post_build_die, | 280 | "POST_BUILD_DIE" => \$post_build_die, |
279 | "POWER_CYCLE" => \$power_cycle, | 281 | "POWER_CYCLE" => \$power_cycle, |
280 | "REBOOT" => \$reboot, | 282 | "REBOOT" => \$reboot, |
283 | "REBOOT_RETURN_CODE" => \$reboot_return_code, | ||
281 | "BUILD_NOCLEAN" => \$noclean, | 284 | "BUILD_NOCLEAN" => \$noclean, |
282 | "MIN_CONFIG" => \$minconfig, | 285 | "MIN_CONFIG" => \$minconfig, |
283 | "OUTPUT_MIN_CONFIG" => \$output_minconfig, | 286 | "OUTPUT_MIN_CONFIG" => \$output_minconfig, |
@@ -1749,6 +1752,7 @@ sub run_command { | |||
1749 | my $dord = 0; | 1752 | my $dord = 0; |
1750 | my $dostdout = 0; | 1753 | my $dostdout = 0; |
1751 | my $pid; | 1754 | my $pid; |
1755 | my $command_orig = $command; | ||
1752 | 1756 | ||
1753 | $command =~ s/\$SSH_USER/$ssh_user/g; | 1757 | $command =~ s/\$SSH_USER/$ssh_user/g; |
1754 | $command =~ s/\$MACHINE/$machine/g; | 1758 | $command =~ s/\$MACHINE/$machine/g; |
@@ -1803,6 +1807,11 @@ sub run_command { | |||
1803 | # shift 8 for real exit status | 1807 | # shift 8 for real exit status |
1804 | $run_command_status = $? >> 8; | 1808 | $run_command_status = $? >> 8; |
1805 | 1809 | ||
1810 | if ($command_orig eq $default{REBOOT} && | ||
1811 | $run_command_status == $reboot_return_code) { | ||
1812 | $run_command_status = 0; | ||
1813 | } | ||
1814 | |||
1806 | close(CMD); | 1815 | close(CMD); |
1807 | close(LOG) if ($dolog); | 1816 | close(LOG) if ($dolog); |
1808 | close(RD) if ($dord); | 1817 | close(RD) if ($dord); |
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf index 6ca6ca0ce695..8c893a58b68e 100644 --- a/tools/testing/ktest/sample.conf +++ b/tools/testing/ktest/sample.conf | |||
@@ -887,6 +887,10 @@ | |||
887 | # The variables SSH_USER and MACHINE are defined. | 887 | # The variables SSH_USER and MACHINE are defined. |
888 | #REBOOT = ssh $SSH_USER@$MACHINE reboot | 888 | #REBOOT = ssh $SSH_USER@$MACHINE reboot |
889 | 889 | ||
890 | # The return code of REBOOT | ||
891 | # (default 255) | ||
892 | #REBOOT_RETURN_CODE = 255 | ||
893 | |||
890 | # The way triple faults are detected is by testing the kernel | 894 | # The way triple faults are detected is by testing the kernel |
891 | # banner. If the kernel banner for the kernel we are testing is | 895 | # banner. If the kernel banner for the kernel we are testing is |
892 | # found, and then later a kernel banner for another kernel version | 896 | # found, and then later a kernel banner for another kernel version |