Skip to content

Commit df46fce

Browse files
Tim Tianyang Chenrostedt
authored andcommitted
Ktest: Use dodie for critical falures
Users should get emails when the script dies because of a critical failure. Critical failures are defined as any errors that could abnormally terminate the script. In order to add email support, this patch converts all die() to dodie() except: * when '-v' is used as an option to get the version of the script. * in Sig-Int handeler because it's not a fatal error to cancel the script. * errors happen during parsing config Link: http://lkml.kernel.org/r/1522094884-22718-4-git-send-email-tianyang.chen@oracle.com Suggested-by: Dhaval Giani <dhaval.giani@oracle.com> Signed-off-by: Tim Tianyang Chen <tianyang.chen@oracle.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 92db453 commit df46fce

1 file changed

Lines changed: 27 additions & 27 deletions

File tree

‎tools/testing/ktest/ktest.pl‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ sub exec_console {
15061506
close($pts);
15071507

15081508
exec $console or
1509-
die "Can't open console $console";
1509+
dodie "Can't open console $console";
15101510
}
15111511

15121512
sub open_console {
@@ -1657,7 +1657,7 @@ sub save_logs {
16571657

16581658
if (!-d $dir) {
16591659
mkpath($dir) or
1660-
die "can't create $dir";
1660+
dodie "can't create $dir";
16611661
}
16621662

16631663
my %files = (
@@ -1670,7 +1670,7 @@ sub save_logs {
16701670
while (my ($name, $source) = each(%files)) {
16711671
if (-f "$source") {
16721672
cp "$source", "$dir/$name" or
1673-
die "failed to copy $source";
1673+
dodie "failed to copy $source";
16741674
}
16751675
}
16761676

@@ -1852,7 +1852,7 @@ sub get_grub2_index {
18521852
$ssh_grub =~ s,\$SSH_COMMAND,cat $grub_file,g;
18531853

18541854
open(IN, "$ssh_grub |")
1855-
or die "unable to get $grub_file";
1855+
or dodie "unable to get $grub_file";
18561856

18571857
my $found = 0;
18581858

@@ -1867,7 +1867,7 @@ sub get_grub2_index {
18671867
}
18681868
close(IN);
18691869

1870-
die "Could not find '$grub_menu' in $grub_file on $machine"
1870+
dodie "Could not find '$grub_menu' in $grub_file on $machine"
18711871
if (!$found);
18721872
doprint "$grub_number\n";
18731873
$last_grub_menu = $grub_menu;
@@ -1895,7 +1895,7 @@ sub get_grub_index {
18951895
$ssh_grub =~ s,\$SSH_COMMAND,cat /boot/grub/menu.lst,g;
18961896

18971897
open(IN, "$ssh_grub |")
1898-
or die "unable to get menu.lst";
1898+
or dodie "unable to get menu.lst";
18991899

19001900
my $found = 0;
19011901

@@ -1910,7 +1910,7 @@ sub get_grub_index {
19101910
}
19111911
close(IN);
19121912

1913-
die "Could not find '$grub_menu' in /boot/grub/menu on $machine"
1913+
dodie "Could not find '$grub_menu' in /boot/grub/menu on $machine"
19141914
if (!$found);
19151915
doprint "$grub_number\n";
19161916
$last_grub_menu = $grub_menu;
@@ -2023,7 +2023,7 @@ sub monitor {
20232023
my $full_line = "";
20242024

20252025
open(DMESG, "> $dmesg") or
2026-
die "unable to write to $dmesg";
2026+
dodie "unable to write to $dmesg";
20272027

20282028
reboot_to;
20292029

@@ -2902,7 +2902,7 @@ sub run_bisect {
29022902
sub update_bisect_replay {
29032903
my $tmp_log = "$tmpdir/ktest_bisect_log";
29042904
run_command "git bisect log > $tmp_log" or
2905-
die "can't create bisect log";
2905+
dodie "can't create bisect log";
29062906
return $tmp_log;
29072907
}
29082908

@@ -2911,9 +2911,9 @@ sub bisect {
29112911

29122912
my $result;
29132913

2914-
die "BISECT_GOOD[$i] not defined\n" if (!defined($bisect_good));
2915-
die "BISECT_BAD[$i] not defined\n" if (!defined($bisect_bad));
2916-
die "BISECT_TYPE[$i] not defined\n" if (!defined($bisect_type));
2914+
dodie "BISECT_GOOD[$i] not defined\n" if (!defined($bisect_good));
2915+
dodie "BISECT_BAD[$i] not defined\n" if (!defined($bisect_bad));
2916+
dodie "BISECT_TYPE[$i] not defined\n" if (!defined($bisect_type));
29172917

29182918
my $good = $bisect_good;
29192919
my $bad = $bisect_bad;
@@ -2976,7 +2976,7 @@ sub bisect {
29762976
if ($check ne "good") {
29772977
doprint "TESTING BISECT BAD [$bad]\n";
29782978
run_command "git checkout $bad" or
2979-
die "Failed to checkout $bad";
2979+
dodie "Failed to checkout $bad";
29802980

29812981
$result = run_bisect $type;
29822982

@@ -2988,7 +2988,7 @@ sub bisect {
29882988
if ($check ne "bad") {
29892989
doprint "TESTING BISECT GOOD [$good]\n";
29902990
run_command "git checkout $good" or
2991-
die "Failed to checkout $good";
2991+
dodie "Failed to checkout $good";
29922992

29932993
$result = run_bisect $type;
29942994

@@ -2999,7 +2999,7 @@ sub bisect {
29992999

30003000
# checkout where we started
30013001
run_command "git checkout $head" or
3002-
die "Failed to checkout $head";
3002+
dodie "Failed to checkout $head";
30033003
}
30043004

30053005
run_command "git bisect start$start_files" or
@@ -3316,9 +3316,9 @@ sub patchcheck_reboot {
33163316
sub patchcheck {
33173317
my ($i) = @_;
33183318

3319-
die "PATCHCHECK_START[$i] not defined\n"
3319+
dodie "PATCHCHECK_START[$i] not defined\n"
33203320
if (!defined($patchcheck_start));
3321-
die "PATCHCHECK_TYPE[$i] not defined\n"
3321+
dodie "PATCHCHECK_TYPE[$i] not defined\n"
33223322
if (!defined($patchcheck_type));
33233323

33243324
my $start = $patchcheck_start;
@@ -3332,7 +3332,7 @@ sub patchcheck {
33323332
if (defined($patchcheck_end)) {
33333333
$end = $patchcheck_end;
33343334
} elsif ($cherry) {
3335-
die "PATCHCHECK_END must be defined with PATCHCHECK_CHERRY\n";
3335+
dodie "PATCHCHECK_END must be defined with PATCHCHECK_CHERRY\n";
33363336
}
33373337

33383338
# Get the true sha1's since we can use things like HEAD~3
@@ -3396,7 +3396,7 @@ sub patchcheck {
33963396
doprint "\nProcessing commit \"$item\"\n\n";
33973397

33983398
run_command "git checkout $sha1" or
3399-
die "Failed to checkout $sha1";
3399+
dodie "Failed to checkout $sha1";
34003400

34013401
# only clean on the first and last patch
34023402
if ($item eq $list[0] ||
@@ -3487,7 +3487,7 @@ sub read_kconfig {
34873487
}
34883488

34893489
open(KIN, "$kconfig")
3490-
or die "Can't open $kconfig";
3490+
or dodie "Can't open $kconfig";
34913491
while (<KIN>) {
34923492
chomp;
34933493

@@ -3648,7 +3648,7 @@ sub get_depends {
36483648

36493649
$dep =~ s/^[^$valid]*[$valid]+//;
36503650
} else {
3651-
die "this should never happen";
3651+
dodie "this should never happen";
36523652
}
36533653
}
36543654

@@ -3909,7 +3909,7 @@ sub make_min_config {
39093909
# update new ignore configs
39103910
if (defined($ignore_config)) {
39113911
open (OUT, ">$temp_config")
3912-
or die "Can't write to $temp_config";
3912+
or dodie "Can't write to $temp_config";
39133913
foreach my $config (keys %save_configs) {
39143914
print OUT "$save_configs{$config}\n";
39153915
}
@@ -3937,7 +3937,7 @@ sub make_min_config {
39373937

39383938
# Save off all the current mandatory configs
39393939
open (OUT, ">$temp_config")
3940-
or die "Can't write to $temp_config";
3940+
or dodie "Can't write to $temp_config";
39413941
foreach my $config (keys %keep_configs) {
39423942
print OUT "$keep_configs{$config}\n";
39433943
}
@@ -4177,11 +4177,11 @@ sub cancel_test {
41774177
$outputdir = set_test_option("OUTPUT_DIR", $i);
41784178
$builddir = set_test_option("BUILD_DIR", $i);
41794179

4180-
chdir $builddir || die "can't change directory to $builddir";
4180+
chdir $builddir || dodie "can't change directory to $builddir";
41814181

41824182
if (!-d $outputdir) {
41834183
mkpath($outputdir) or
4184-
die "can't create $outputdir";
4184+
dodie "can't create $outputdir";
41854185
}
41864186

41874187
$make = "$makecmd O=$outputdir";
@@ -4218,7 +4218,7 @@ sub cancel_test {
42184218

42194219
if (!-d $tmpdir) {
42204220
mkpath($tmpdir) or
4221-
die "can't create $tmpdir";
4221+
dodie "can't create $tmpdir";
42224222
}
42234223

42244224
$ENV{"SSH_USER"} = $ssh_user;
@@ -4291,7 +4291,7 @@ sub cancel_test {
42914291

42924292
if (defined($checkout)) {
42934293
run_command "git checkout $checkout" or
4294-
die "failed to checkout $checkout";
4294+
dodie "failed to checkout $checkout";
42954295
}
42964296

42974297
$no_reboot = 0;

0 commit comments

Comments
 (0)