aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/ktest
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-11-02 14:57:33 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-11-18 11:23:06 -0500
commit5f9b6ced04a4e9c3ee6b4d4042ac5935ef5a8dbd (patch)
tree9394e66ce8a2306b360433d5c9dad2b10cd12ffa /tools/testing/ktest
parent75c3fda79e97b1e2c390e3623f19476e1e78ca0c (diff)
ktest: Bisecting, install modules, add logging
Added bisecting, modules, logging of the output. Banners that show success. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing/ktest')
-rw-r--r--tools/testing/ktest/ktest.pl321
1 files changed, 227 insertions, 94 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 79da57f3023b..a34f6f4193df 100644
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -25,11 +25,13 @@ $opt{"POWEROFF_ON_SUCCESS"} = 0;
25$opt{"BUILD_OPTIONS"} = ""; 25$opt{"BUILD_OPTIONS"} = "";
26 26
27my $version; 27my $version;
28my $install_mods;
29my $grub_number; 28my $grub_number;
30my $target; 29my $target;
31my $make; 30my $make;
32my $noclean; 31my $noclean;
32my $minconfig;
33my $in_bisect = 0;
34my $bisect_bad = "";
33 35
34sub read_config { 36sub read_config {
35 my ($config) = @_; 37 my ($config) = @_;
@@ -52,9 +54,7 @@ sub read_config {
52 close(IN); 54 close(IN);
53} 55}
54 56
55sub doprint { 57sub logit {
56 print @_;
57
58 if (defined($opt{"LOG_FILE"})) { 58 if (defined($opt{"LOG_FILE"})) {
59 open(OUT, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}"; 59 open(OUT, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}";
60 print OUT @_; 60 print OUT @_;
@@ -62,6 +62,11 @@ sub doprint {
62 } 62 }
63} 63}
64 64
65sub doprint {
66 print @_;
67 logit @_;
68}
69
65sub dodie { 70sub dodie {
66 doprint "CRITICAL FAILURE... ", @_; 71 doprint "CRITICAL FAILURE... ", @_;
67 72
@@ -96,7 +101,30 @@ sub run_command {
96 doprint "SUCCESS\n"; 101 doprint "SUCCESS\n";
97 } 102 }
98 103
99 return $failed; 104 return !$failed;
105}
106
107sub get_grub_index {
108
109 return if ($grub_number >= 0);
110
111 doprint "Find grub menu ... ";
112 $grub_number = -1;
113 open(IN, "ssh $target cat /boot/grub/menu.lst |")
114 or die "unable to get menu.lst";
115 while (<IN>) {
116 if (/^\s*title\s+$opt{GRUB_MENU}\s*$/) {
117 $grub_number++;
118 last;
119 } elsif (/^\s*title\s/) {
120 $grub_number++;
121 }
122 }
123 close(IN);
124
125 die "Could not find '$opt{GRUB_MENU}' in /boot/grub/menu on $opt{MACHINE}"
126 if ($grub_number < 0);
127 doprint "$grub_number\n";
100} 128}
101 129
102my $timeout = $opt{"TIMEOUT"}; 130my $timeout = $opt{"TIMEOUT"};
@@ -213,46 +241,63 @@ sub monitor {
213 close(IN); 241 close(IN);
214 242
215 if (!$booted) { 243 if (!$booted) {
244 return 1 if (!$in_bisect);
216 dodie "failed - never got a boot prompt.\n"; 245 dodie "failed - never got a boot prompt.\n";
217 } 246 }
218 247
219 if ($bug) { 248 if ($bug) {
249 return 1 if (!$in_bisect);
220 dodie "failed - got a bug report\n"; 250 dodie "failed - got a bug report\n";
221 } 251 }
252
253 return 0;
222} 254}
223 255
224sub install { 256sub install {
225 257
226 if (run_command "scp $opt{OUTPUT_DIR}/$opt{BUILD_TARGET} $target:$opt{TARGET_IMAGE}") { 258 run_command "scp $opt{OUTPUT_DIR}/$opt{BUILD_TARGET} $target:$opt{TARGET_IMAGE}" or
227 dodie "failed to copy image"; 259 dodie "failed to copy image";
228 }
229 260
230 if ($install_mods) { 261 my $install_mods = 0;
231 my $modlib = "/lib/modules/$version";
232 my $modtar = "autotest-mods.tar.bz2";
233 262
234 if (run_command "ssh $target rm -rf $modlib") { 263 # should we process modules?
235 dodie "failed to remove old mods: $modlib"; 264 $install_mods = 0;
265 open(IN, "$opt{OUTPUT_DIR}/.config") or dodie("Can't read config file");
266 while (<IN>) {
267 if (/CONFIG_MODULES(=y)?/) {
268 $install_mods = 1 if (defined($1));
269 last;
236 } 270 }
271 }
272 close(IN);
237 273
238 # would be nice if scp -r did not follow symbolic links 274 if (!$install_mods) {
239 if (run_command "cd $opt{TMP_DIR} && tar -cjf $modtar lib/modules/$version") { 275 doprint "No modules needed\n";
240 dodie "making tarball"; 276 return;
241 } 277 }
242 278
243 if (run_command "scp $opt{TMP_DIR}/$modtar $target:/tmp") { 279 run_command "$make INSTALL_MOD_PATH=$opt{TMP_DIR} modules_install" or
244 dodie "failed to copy modules"; 280 dodie "Failed to install modules";
245 }
246 281
247 unlink "$opt{TMP_DIR}/$modtar"; 282 my $modlib = "/lib/modules/$version";
283 my $modtar = "autotest-mods.tar.bz2";
248 284
249 if (run_command "ssh $target '(cd / && tar xf /tmp/$modtar)'") { 285 run_command "ssh $target rm -rf $modlib" or
250 dodie "failed to tar modules"; 286 dodie "failed to remove old mods: $modlib";
251 }
252 287
253 run_command "ssh $target rm -f /tmp/$modtar"; 288 # would be nice if scp -r did not follow symbolic links
254 } 289 run_command "cd $opt{TMP_DIR} && tar -cjf $modtar lib/modules/$version" or
290 dodie "making tarball";
291
292 run_command "scp $opt{TMP_DIR}/$modtar $target:/tmp" or
293 dodie "failed to copy modules";
294
295 unlink "$opt{TMP_DIR}/$modtar";
296
297 run_command "ssh $target '(cd / && tar xf /tmp/$modtar)'" or
298 dodie "failed to tar modules";
255 299
300 run_command "ssh $target rm -f /tmp/$modtar";
256} 301}
257 302
258sub build { 303sub build {
@@ -261,9 +306,9 @@ sub build {
261 my $append = ""; 306 my $append = "";
262 307
263 if ($type =~ /^useconfig:(.*)/) { 308 if ($type =~ /^useconfig:(.*)/) {
264 if (run_command "cp $1 $opt{OUTPUT_DIR}/.config") { 309 run_command "cp $1 $opt{OUTPUT_DIR}/.config" or
265 dodie "could not copy $1 to .config"; 310 dodie "could not copy $1 to .config";
266 } 311
267 $type = "oldconfig"; 312 $type = "oldconfig";
268 } 313 }
269 314
@@ -274,23 +319,20 @@ sub build {
274 # allow for empty configs 319 # allow for empty configs
275 run_command "touch $opt{OUTPUT_DIR}/.config"; 320 run_command "touch $opt{OUTPUT_DIR}/.config";
276 321
277 if (run_command "mv $opt{OUTPUT_DIR}/.config $opt{OUTPUT_DIR}/config_temp") { 322 run_command "mv $opt{OUTPUT_DIR}/.config $opt{OUTPUT_DIR}/config_temp" or
278