aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRabin Vincent <rabin@rab.in>2011-11-18 06:35:31 -0500
committerSteven Rostedt <rostedt@goodmis.org>2011-11-18 12:04:33 -0500
commitde5b6e3bf5e71532057fb4f1eb8ee29c5c7f11db (patch)
tree20298f12a66934b84bdbd9a0830c78148c005039
parenta9dd5d631729eea8686703fbb25a7a9d4c75a724 (diff)
ktest: Allow success logs to be stored
Add a STORE_SUCCESSES option, to allow success logs to be stored, for example to double-check or otherwise post-process the test logs. Link: http://lkml.kernel.org/r/1321616131-21352-3-git-send-email-rabin@rab.in Signed-off-by: Rabin Vincent <rabin@rab.in> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rwxr-xr-xtools/testing/ktest/ktest.pl80
-rw-r--r--tools/testing/ktest/sample.conf6
2 files changed, 52 insertions, 34 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index e93c21cc0aa9..6ef104e87ab0 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -113,6 +113,7 @@ my $bisect_sleep_time;
113my $patchcheck_sleep_time; 113my $patchcheck_sleep_time;
114my $ignore_warnings; 114my $ignore_warnings;
115my $store_failures; 115my $store_failures;
116my $store_successes;
116my $test_name; 117my $test_name;
117my $timeout; 118my $timeout;
118my $booted_timeout; 119my $booted_timeout;
@@ -976,6 +977,43 @@ sub wait_for_monitor {
976 print "** Monitor flushed **\n"; 977 print "** Monitor flushed **\n";
977} 978}
978 979
980sub save_logs {
981 my ($result, $basedir) = @_;
982 my @t = localtime;
983 my $date = sprintf "%04d%02d%02d%02d%02d%02d",
984 1900+$t[5],$t[4],$t[3],$t[2],$t[1],$t[0];
985
986 my $type = $build_type;
987 if ($type =~ /useconfig/) {
988 $type = "useconfig";
989 }
990
991 my $dir = "$machine-$test_type-$type-$result-$date";
992
993 $dir = "$basedir/$dir";
994
995 if (!-d $dir) {
996 mkpath($dir) or
997 die "can't create $dir";
998 }
999
1000 my %files = (
1001 "config" => $output_config,
1002 "buildlog" => $buildlog,
1003 "dmesg" => $dmesg,
1004 "testlog" => $testlog,
1005 );
1006
1007 while (my ($name, $source) = each(%files)) {
1008 if (-f "$source") {
1009 cp "$source", "$dir/$name" or
1010 die "failed to copy $source";
1011 }
1012 }
1013
1014 doprint "*** Saved info to $dir ***\n";
1015}
1016
979sub fail { 1017sub fail {
980 1018
981 if ($die_on_failure) { 1019 if ($die_on_failure) {
@@ -1004,40 +1042,9 @@ sub fail {
1004 doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"; 1042 doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
1005 doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"; 1043 doprint "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
1006 1044
1007 return 1 if (!defined($store_failures)); 1045 if (defined($store_failures)) {
1008 1046 save_logs "fail", $store_failures;
1009 my @t = localtime; 1047 }
1010 my $date = sprintf "%04d%02d%02d%02d%02d%02d",
1011 1900+$t[5],$t[4],$t[3],$t[2],$t[1],$t[0];
1012
1013 my $type = $build_type;
1014 if ($type =~ /useconfig/) {
1015 $type = "useconfig";
1016 }
1017
1018 my $dir = "$machine-$test_type-$type-fail-$date";
1019 my $faildir = "$store_failures/$dir";
1020
1021 if (!-d $faildir) {
1022 mkpath($faildir) or
1023 die "can't create $faildir";
1024 }
1025
1026 my %files = (
1027 "config" => $output_config,
1028 "buildlog" => $buildlog,
1029 "dmesg" => $dmesg,
1030 "testlog" => $testlog,
1031 );
1032
1033 while (my ($name, $source) = each(%files)) {
1034 if (-f "$source") {
1035 cp "$source", "$faildir/$name" or
1036 die "failed to copy $source";
1037 }
1038 }
1039
1040 doprint "*** Saved info to $faildir ***\n";
1041 1048
1042 return 1; 1049 return 1;
1043} 1050}
@@ -1643,6 +1650,10 @@ sub success {
1643 doprint "*******************************************\n"; 1650 doprint "*******************************************\n";
1644 doprint "*******************************************\n"; 1651 doprint "*******************************************\n";
1645 1652
1653 if (defined($store_successes)) {
1654 save_logs "success", $store_successes;
1655 }
1656
1646 if ($i != $opt{"NUM_TESTS"} && !do_not_reboot) { 1657 if ($i != $opt{"NUM_TESTS"} && !do_not_reboot) {
1647 doprint "Reboot and wait $sleep_time seconds\n"; 1658 doprint "Reboot and wait $sleep_time seconds\n";
1648 reboot $sleep_time; 1659 reboot $sleep_time;
@@ -3137,6 +3148,7 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
3137 $bisect_skip = set_test_option("BISECT_SKIP", $i); 3148 $bisect_skip = set_test_option("BISECT_SKIP", $i);
3138 $config_bisect_good = set_test_option("CONFIG_BISECT_GOOD", $i); 3149 $config_bisect_good = set_test_option("CONFIG_BISECT_GOOD", $i);
3139 $store_failures = set_test_option("STORE_FAILURES", $i); 3150 $store_failures = set_test_option("STORE_FAILURES", $i);
3151 $store_successes = set_test_option("STORE_SUCCESSES", $i);
3140 $test_name = set_test_option("TEST_NAME", $i); 3152 $test_name = set_test_option("TEST_NAME", $i);
3141 $timeout = set_test_option("TIMEOUT", $i); 3153 $timeout = set_test_option("TIMEOUT", $i);
3142 $booted_timeout = set_test_option("BOOTED_TIMEOUT", $i); 3154 $booted_timeout = set_test_option("BOOTED_TIMEOUT", $i);
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf
index dbedfa196727..42e0eb9442e3 100644
--- a/tools/testing/ktest/sample.conf
+++ b/tools/testing/ktest/sample.conf
@@ -589,6 +589,12 @@
589# (default undefined) 589# (default undefined)
590#STORE_FAILURES = /home/test/failures 590#STORE_FAILURES = /home/test/failures
591 591
592# Directory to store success directories on success. If this is not
593# set, the .config, dmesg and bootlog will not be saved if a
594# test succeeds.
595# (default undefined)
596#STORE_SUCCESSES = /home/test/successes
597
592# Build without doing a make mrproper, or removing .config 598# Build without doing a make mrproper, or removing .config
593# (default 0) 599# (default 0)
594#BUILD_NOCLEAN = 0 600#BUILD_NOCLEAN = 0