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

ktest: Show name and iteration on errors



If a test has an error, display not only the what type of test failed, but
if the test was giving a name, display that too, as well as the current
iteration of the tests. Each test has an iteration number associated to it.
For error messages display that iteration number along with the test type
and test name. This includes the message that gets sent via email.

Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent 9e98c678
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -1437,16 +1437,27 @@ sub do_not_reboot {

my $in_die = 0;

sub get_test_name() {
    my $name;

    if (defined($test_name)) {
	$name = "$test_name:$test_type";
    } else {
	$name = $test_type;
    }
    return $name;
}

sub dodie {

    # avoid recusion
    return if ($in_die);
    $in_die = 1;

    doprint "CRITICAL FAILURE... ", @_, "\n";

    my $i = $iteration;

    doprint "CRITICAL FAILURE... [TEST $i] ", @_, "\n";

    if ($reboot_on_error && !do_not_reboot) {

	doprint "REBOOTING\n";
@@ -1462,7 +1473,8 @@ sub dodie {
    }

    if ($email_on_error) {
        send_email("KTEST: critical failure for your [$test_type] test",
	my $name = get_test_name;
        send_email("KTEST: critical failure for test $i [$name]",
                "Your test started at $script_start_time has failed with:\n@_\n");
    }

@@ -4193,7 +4205,8 @@ sub send_email {

sub cancel_test {
    if ($email_when_canceled) {
        send_email("KTEST: Your [$test_type] test was cancelled",
	my $name = get_test_name;
        send_email("KTEST: Your [$name] test was cancelled",
                "Your test started at $script_start_time was cancelled: sig int");
    }
    die "\nCaught Sig Int, test interrupted: $!\n"
@@ -4247,7 +4260,8 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
            run_command $pre_ktest;
        }
        if ($email_when_started) {
            send_email("KTEST: Your [$test_type] test was started",
	    my $name = get_test_name;
            send_email("KTEST: Your [$name] test was started",
                "Your test was started on $script_start_time");
        }
    }
@@ -4414,7 +4428,7 @@ if ($opt{"POWEROFF_ON_SUCCESS"}) {
doprint "\n    $successes of $opt{NUM_TESTS} tests were successful\n\n";

if ($email_when_finished) {
    send_email("KTEST: Your [$test_type] test has finished!",
    send_email("KTEST: Your test has finished!",
            "$successes of $opt{NUM_TESTS} tests started at $script_start_time were successful!");
}
exit 0;