Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6474ace9 authored by Steven Rostedt (VMware)'s avatar Steven Rostedt (VMware)
Browse files

ktest.pl: Powercycle the box on reboot if no connection can be made



When performing a reboot of the test box, try to ssh to it. If it can't
connect for 5 seconds, then powercycle the box. This is useful because the
reboot is done via ssh, and if you can't ssh to the box because it is hung,
the reboot fails to reboot.

Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent 6e98d1b4
Loading
Loading
Loading
Loading
+29 −11
Original line number Diff line number Diff line
@@ -1325,7 +1325,24 @@ sub wait_for_monitor;

sub reboot {
    my ($time) = @_;
    my $powercycle = 0;

    # test if the machine can be connected to within 5 seconds
    my $stat = run_ssh("echo check machine status", 5);
    if (!$stat) {
	doprint("power cycle\n");
	$powercycle = 1;
    }

    if ($powercycle) {
	run_command "$power_cycle";

	start_monitor;
	# flush out current monitor
	# May contain the reboot success line
	wait_for_monitor 1;

    } else {
	# Make sure everything has been written to disk
	run_ssh("sync");

@@ -1346,6 +1363,7 @@ sub reboot {
	    # nope? power cycle it.
	    run_command "$power_cycle";
	}
    }

    if (defined($time)) {