aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2015-01-28 09:43:01 -0500
committerSteven Rostedt <rostedt@goodmis.org>2015-01-29 09:02:06 -0500
commit38fa3dc15c6948135977d50ecf90061f21cebc15 (patch)
treec8639b638466bf8cd876e32e49c6782800fb0374
parent988427829bcd230c78106d28dbfa85d45d182909 (diff)
ktest: Show times for build, install, boot and test
Seeing the times for how long a build, install, reboot and the test takes is helpful for analyzing the test process. Seeing how different changes affect the timings. Show the build, install, boot and test times when at the end of the test, or between each interval for tests that do those mulitple times (like bisect and patchcheck). Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rwxr-xr-xtools/testing/ktest/ktest.pl109
1 files changed, 105 insertions, 4 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 1dae000f79f8..177319822401 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -198,6 +198,11 @@ my $patchcheck_start;
198my $patchcheck_cherry; 198my $patchcheck_cherry;
199my $patchcheck_end; 199my $patchcheck_end;
200 200
201my $build_time;
202my $install_time;
203my $reboot_time;
204my $test_time;
205
201# set when a test is something other that just building or install 206# set when a test is something other that just building or install
202# which would require more options. 207# which would require more options.
203my $buildonly = 1; 208my $buildonly = 1;
@@ -555,6 +560,66 @@ sub get_mandatory_config {
555 } 560 }
556} 561}
557 562
563sub show_time {
564 my ($time) = @_;
565
566 my $hours = 0;
567 my $minutes = 0;
568
569 if ($time > 3600) {
570 $hours = int($time / 3600);
571 $time -= $hours * 3600;
572 }
573 if ($time > 60) {
574 $minutes = int($time / 60);
575 $time -= $minutes * 60;
576 }
577
578 if ($hours > 0) {
579 doprint "$hours hour";
580 doprint "s" if ($hours > 1);
581 doprint " ";
582 }
583
584 if ($minutes > 0) {
585 doprint "$minutes minute";
586 doprint "s" if ($minutes > 1);
587 doprint " ";
588 }
589
590 doprint "$time second";
591 doprint "s" if ($time != 1);
592}
593
594sub print_times {
595 doprint "\n";
596 if ($build_time) {
597 doprint "Build time: ";
598 show_time($build_time);
599 doprint "\n";
600 }
601 if ($install_time) {
602 doprint "Install time: ";
603 show_time($install_time);
604 doprint "\n";
605 }
606 if ($reboot_time) {
607 doprint "Reboot time: ";
608 show_time($reboot_time);
609 doprint "\n";
610 }
611 if ($test_time) {
612 doprint "Test time: ";
613 show_time($test_time);
614 doprint "\n";
615 }
616 # reset for iterations like bisect
617 $build_time = 0;
618 $install_time = 0;
619 $reboot_time = 0;
620 $test_time = 0;
621}
622
558sub get_mandatory_configs { 623sub get_mandatory_configs {
559 get_mandatory_config("MACHINE"); 624 get_mandatory_config("MACHINE");
560 get_mandatory_config("BUILD_DIR"); 625 get_mandatory_config("BUILD_DIR");
@@ -1786,6 +1851,8 @@ sub monitor {
1786 my $skip_call_trace = 0; 1851 my $skip_call_trace = 0;
1787 my $loops; 1852 my $loops;
1788 1853
1854 my $start_time = time;
1855
1789 wait_for_monitor 5; 1856 wait_for_monitor 5;
1790 1857
1791 my $line; 1858 my $line;
@@ -1910,6 +1977,9 @@ sub monitor {
1910 } 1977 }
1911 } 1978 }
1912 1979
1980 my $end_time = time;
1981 $reboot_time = $end_time - $start_time;
1982
1913 close(DMESG); 1983 close(DMESG);
1914 1984
1915 if ($bug) { 1985 if ($bug) {
@@ -1958,6 +2028,8 @@ sub install {
1958 2028
1959 return if ($no_install); 2029 return if ($no_install);
1960 2030
2031 my $start_time = time;
2032
1961 if (defined($pre_install)) { 2033 if (defined($pre_install)) {
1962 my $cp_pre_install = eval_kernel_version $pre_install; 2034 my $cp_pre_install = eval_kernel_version $pre_install;
1963 run_command "$cp_pre_install" or 2035 run_command "$cp_pre_install" or
@@ -1989,6 +2061,8 @@ sub install {
1989 if (!$install_mods) { 2061 if (!$install_mods) {
1990 do_post_install; 2062 do_post_install;
1991 doprint "No modules needed\n"; 2063 doprint "No modules needed\n";
2064 my $end_time = time;
2065 $install_time = $end_time - $start_time;
1992 return; 2066 return;
1993 } 2067 }
1994 2068
@@ -2016,6 +2090,9 @@ sub install {
2016 run_ssh "rm -f /tmp/$modtar"; 2090 run_ssh "rm -f /tmp/$modtar";
2017 2091
2018 do_post_install; 2092 do_post_install;
2093
2094 my $end_time = time;
2095 $install_time = $end_time - $start_time;
2019} 2096}
2020 2097
2021sub get_version { 2098sub get_version {
@@ -2228,6 +2305,8 @@ sub build {
2228 2305
2229 unlink $buildlog; 2306 unlink $buildlog;
2230 2307
2308 my $start_time = time;
2309
2231 # Failed builds should not reboot the target 2310 # Failed builds should not reboot the target
2232 my $save_no_reboot = $no_reboot; 2311 my $save_no_reboot = $no_reboot;
2233 $no_reboot = 1; 2312 $no_reboot = 1;
@@ -2313,6 +2392,9 @@ sub build {
2313 2392
2314 $no_reboot = $save_no_reboot; 2393 $no_reboot = $save_no_reboot;
2315 2394
2395 my $end_time = time;
2396 $build_time = $end_time - $start_time;
2397
2316 return 1; 2398 return 1;
2317} 2399}
2318 2400
@@ -2403,6 +2485,8 @@ sub do_run_test {
2403 my $bug = 0; 2485 my $bug = 0;
2404 my $bug_ignored = 0; 2486 my $bug_ignored = 0;
2405 2487
2488 my $start_time = time;
2489
2406 wait_for_monitor 1; 2490 wait_for_monitor 1;
2407 2491
2408 doprint "run test $run_test\n"; 2492 doprint "run test $run_test\n";
@@ -2469,6 +2553,9 @@ sub do_run_test {
2469 waitpid $child_pid, 0; 2553 waitpid $child_pid, 0;
2470 $child_exit = $?; 2554 $child_exit = $?;
2471 2555
2556 my $end_time = time;
2557 $test_time = $end_time - $start_time;
2558
2472 if (!$bug && $in_bisect) { 2559 if (!$bug && $in_bisect) {
2473 if (defined($bisect_ret_good)) { 2560 if (defined($bisect_ret_good)) {
2474 if ($child_exit == $bisect_ret_good) { 2561 if ($child_exit == $bisect_ret_good) {
@@ -2775,6 +2862,7 @@ sub bisect {
2775 do { 2862 do {
2776 $result = run_bisect $type; 2863 $result = run_bisect $type;
2777 $test = run_git_bisect "git bisect $result"; 2864 $test = run_git_bisect "git bisect $result";
2865 print_times;
2778 } while ($test); 2866 } while ($test);
2779 2867
2780 run_command "git bisect log" or 2868 run_command "git bisect log" or
@@ -3188,6 +3276,7 @@ sub config_bisect {
3188 3276
3189 do { 3277 do {
3190 $ret = run_config_bisect \%good_configs, \%bad_configs; 3278 $ret = run_config_bisect \%good_configs, \%bad_configs;
3279 print_times;
3191 } while (!$ret); 3280 } while (!$ret);
3192 3281
3193 return $ret if ($ret < 0); 3282 return $ret if ($ret < 0);
@@ -3317,10 +3406,12 @@ sub patchcheck {
3317 do_run_test or $failed = 1; 3406 do_run_test or $failed = 1;
3318 } 3407 }
3319 end_monitor; 3408 end_monitor;
3320 return 0 if ($failed); 3409 if ($failed) {
3321 3410 print_times;
3411 return 0;
3412 }
3322 patchcheck_reboot; 3413 patchcheck_reboot;
3323 3414 print_times;
3324 } 3415 }
3325 $in_patchcheck = 0; 3416 $in_patchcheck = 0;
3326 success $i; 3417 success $i;
@@ -4020,6 +4111,11 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
4020 4111
4021 $iteration = $i; 4112 $iteration = $i;
4022 4113
4114 $build_time = 0;
4115 $install_time = 0;
4116 $reboot_time = 0;
4117 $test_time = 0;
4118
4023 undef %force_config; 4119 undef %force_config;
4024 4120
4025 my $makecmd = set_test_option("MAKE_CMD", $i); 4121 my $makecmd = set_test_option("MAKE_CMD", $i);
@@ -4183,9 +4279,14 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
4183 do_run_test or $failed = 1; 4279 do_run_test or $failed = 1;
4184 } 4280 }
4185 end_monitor; 4281 end_monitor;
4186 next if ($failed); 4282 if ($failed) {
4283 print_times;
4284 next;
4285 }
4187 } 4286 }
4188 4287
4288 print_times;
4289
4189 success $i; 4290 success $i;
4190} 4291}
4191 4292