12545eb61SSteven Rostedt#!/usr/bin/perl -w 22545eb61SSteven Rostedt 32545eb61SSteven Rostedtuse strict; 42545eb61SSteven Rostedtuse IPC::Open2; 52545eb61SSteven Rostedtuse Fcntl qw(F_GETFL F_SETFL O_NONBLOCK); 62545eb61SSteven Rostedtuse FileHandle; 72545eb61SSteven Rostedt 82545eb61SSteven Rostedt$#ARGV >= 0 || die "usage: autotest.pl config-file\n"; 92545eb61SSteven Rostedt 102545eb61SSteven Rostedt$| = 1; 112545eb61SSteven Rostedt 122545eb61SSteven Rostedtmy %opt; 132545eb61SSteven Rostedt 142545eb61SSteven Rostedt#default opts 152545eb61SSteven Rostedt$opt{"NUM_BUILDS"} = 5; 162545eb61SSteven Rostedt$opt{"DEFAULT_BUILD_TYPE"} = "randconfig"; 172545eb61SSteven Rostedt$opt{"MAKE_CMD"} = "make"; 182545eb61SSteven Rostedt$opt{"TIMEOUT"} = 50; 192545eb61SSteven Rostedt$opt{"TMP_DIR"} = "/tmp/autotest"; 202545eb61SSteven Rostedt$opt{"SLEEP_TIME"} = 60; # sleep time between tests 215c42fc5bSSteven Rostedt$opt{"BUILD_NOCLEAN"} = 0; 22*75c3fda7SSteven Rostedt$opt{"REBOOT_ON_ERROR"} = 0; 235c42fc5bSSteven Rostedt$opt{"POWEROFF_ON_ERROR"} = 0; 245c42fc5bSSteven Rostedt$opt{"POWEROFF_ON_SUCCESS"} = 0; 25*75c3fda7SSteven Rostedt$opt{"BUILD_OPTIONS"} = ""; 262545eb61SSteven Rostedt 272545eb61SSteven Rostedtmy $version; 282545eb61SSteven Rostedtmy $install_mods; 292545eb61SSteven Rostedtmy $grub_number; 302545eb61SSteven Rostedtmy $target; 312545eb61SSteven Rostedtmy $make; 325c42fc5bSSteven Rostedtmy $noclean; 332545eb61SSteven Rostedt 342545eb61SSteven Rostedtsub read_config { 352545eb61SSteven Rostedt my ($config) = @_; 362545eb61SSteven Rostedt 372545eb61SSteven Rostedt open(IN, $config) || die "can't read file $config"; 382545eb61SSteven Rostedt 392545eb61SSteven Rostedt while (<IN>) { 402545eb61SSteven Rostedt 412545eb61SSteven Rostedt # ignore blank lines and comments 422545eb61SSteven Rostedt next if (/^\s*$/ || /\s*\#/); 432545eb61SSteven Rostedt 442545eb61SSteven Rostedt if (/^\s*(\S+)\s*=\s*(.*?)\s*$/) { 452545eb61SSteven Rostedt my $lvalue = $1; 462545eb61SSteven Rostedt my $rvalue = $2; 472545eb61SSteven Rostedt 482545eb61SSteven Rostedt $opt{$lvalue} = $rvalue; 492545eb61SSteven Rostedt } 502545eb61SSteven Rostedt } 512545eb61SSteven Rostedt 522545eb61SSteven Rostedt close(IN); 532545eb61SSteven Rostedt} 542545eb61SSteven Rostedt 552545eb61SSteven Rostedtsub doprint { 562545eb61SSteven Rostedt print @_; 572545eb61SSteven Rostedt 582545eb61SSteven Rostedt if (defined($opt{"LOG_FILE"})) { 592545eb61SSteven Rostedt open(OUT, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}"; 602545eb61SSteven Rostedt print OUT @_; 612545eb61SSteven Rostedt close(OUT); 622545eb61SSteven Rostedt } 632545eb61SSteven Rostedt} 642545eb61SSteven Rostedt 655c42fc5bSSteven Rostedtsub dodie { 665c42fc5bSSteven Rostedt doprint "CRITICAL FAILURE... ", @_; 675c42fc5bSSteven Rostedt 68*75c3fda7SSteven Rostedt if ($opt{"REBOOT_ON_ERROR"}) { 69*75c3fda7SSteven Rostedt doprint "REBOOTING\n"; 70*75c3fda7SSteven Rostedt `$opt{"POWER_CYCLE"}`; 71*75c3fda7SSteven Rostedt 72*75c3fda7SSteven Rostedt } elsif ($opt{"POWEROFF_ON_ERROR"} && defined($opt{"POWER_OFF"})) { 735c42fc5bSSteven Rostedt doprint "POWERING OFF\n"; 745c42fc5bSSteven Rostedt `$opt{"POWER_OFF"}`; 755c42fc5bSSteven Rostedt } 76*75c3fda7SSteven Rostedt 775c42fc5bSSteven Rostedt die @_; 785c42fc5bSSteven Rostedt} 795c42fc5bSSteven Rostedt 802545eb61SSteven Rostedtsub run_command { 812545eb61SSteven Rostedt my ($command) = @_; 822545eb61SSteven Rostedt my $redirect = ""; 832545eb61SSteven Rostedt 842545eb61SSteven Rostedt if (defined($opt{"LOG_FILE"})) { 852545eb61SSteven Rostedt $redirect = " >> $opt{LOG_FILE} 2>&1"; 862545eb61SSteven Rostedt } 872545eb61SSteven Rostedt 882545eb61SSteven Rostedt doprint "$command ... "; 892545eb61SSteven Rostedt `$command $redirect`; 902545eb61SSteven Rostedt 912545eb61SSteven Rostedt my $failed = $?; 922545eb61SSteven Rostedt 932545eb61SSteven Rostedt if ($failed) { 942545eb61SSteven Rostedt doprint "FAILED!\n"; 952545eb61SSteven Rostedt } else { 962545eb61SSteven Rostedt doprint "SUCCESS\n"; 972545eb61SSteven Rostedt } 982545eb61SSteven Rostedt 992545eb61SSteven Rostedt return $failed; 1002545eb61SSteven Rostedt} 1012545eb61SSteven Rostedt 1022545eb61SSteven Rostedtmy $timeout = $opt{"TIMEOUT"}; 1032545eb61SSteven Rostedt 1042545eb61SSteven Rostedtsub wait_for_input 1052545eb61SSteven Rostedt{ 1062545eb61SSteven Rostedt my ($fp, $time) = @_; 1072545eb61SSteven Rostedt my $rin; 1082545eb61SSteven Rostedt my $ready; 1092545eb61SSteven Rostedt my $line; 1102545eb61SSteven Rostedt my $ch; 1112545eb61SSteven Rostedt 1122545eb61SSteven Rostedt if (!defined($time)) { 1132545eb61SSteven Rostedt $time = $timeout; 1142545eb61SSteven Rostedt } 1152545eb61SSteven Rostedt 1162545eb61SSteven Rostedt $rin = ''; 1172545eb61SSteven Rostedt vec($rin, fileno($fp), 1) = 1; 1182545eb61SSteven Rostedt $ready = select($rin, undef, undef, $time); 1192545eb61SSteven Rostedt 1202545eb61SSteven Rostedt $line = ""; 1212545eb61SSteven Rostedt 1222545eb61SSteven Rostedt # try to read one char at a time 1232545eb61SSteven Rostedt while (sysread $fp, $ch, 1) { 1242545eb61SSteven Rostedt $line .= $ch; 1252545eb61SSteven Rostedt last if ($ch eq "\n"); 1262545eb61SSteven Rostedt } 1272545eb61SSteven Rostedt 1282545eb61SSteven Rostedt if (!length($line)) { 1292545eb61SSteven Rostedt return undef; 1302545eb61SSteven Rostedt } 1312545eb61SSteven Rostedt 1322545eb61SSteven Rostedt return $line; 1332545eb61SSteven Rostedt} 1342545eb61SSteven Rostedt 135*75c3fda7SSteven Rostedtsub reboot_to { 1362545eb61SSteven Rostedt run_command "ssh $target '(echo \"savedefault --default=$grub_number --once\" | grub --batch; reboot)'"; 1372545eb61SSteven Rostedt} 1382545eb61SSteven Rostedt 1392545eb61SSteven Rostedtsub monitor { 1402545eb61SSteven Rostedt my $flags; 1412545eb61SSteven Rostedt my $booted = 0; 1422545eb61SSteven Rostedt my $bug = 0; 1432545eb61SSteven Rostedt my $pid; 1442545eb61SSteven Rostedt my $doopen2 = 0; 1455c42fc5bSSteven Rostedt my $skip_call_trace = 0; 1462545eb61SSteven Rostedt 1472545eb61SSteven Rostedt if ($doopen2) { 148*75c3fda7SSteven Rostedt $pid = open2(\*IN, \*OUT, $opt{"CONSOLE"}); 1492545eb61SSteven Rostedt if ($pid < 0) { 1505c42fc5bSSteven Rostedt dodie "Failed to connect to the console"; 1512545eb61SSteven Rostedt } 1522545eb61SSteven Rostedt } else { 1532545eb61SSteven Rostedt $pid = open(IN, "$opt{CONSOLE} |"); 1542545eb61SSteven Rostedt } 1552545eb61SSteven Rostedt 1562545eb61SSteven Rostedt $flags = fcntl(IN, F_GETFL, 0) or 1575c42fc5bSSteven Rostedt dodie "Can't get flags for the socket: $!\n"; 1582545eb61SSteven Rostedt 1592545eb61SSteven Rostedt $flags = fcntl(IN, F_SETFL, $flags | O_NONBLOCK) or 1605c42fc5bSSteven Rostedt dodie "Can't set flags for the socket: $!\n"; 1612545eb61SSteven Rostedt 1622545eb61SSteven Rostedt my $line; 1632545eb61SSteven Rostedt my $full_line = ""; 1642545eb61SSteven Rostedt 1652545eb61SSteven Rostedt doprint "Wait for monitor to settle down.\n"; 1662545eb61SSteven Rostedt # read the monitor and wait for the system to calm down 1672545eb61SSteven Rostedt do { 1682545eb61SSteven Rostedt $line = wait_for_input(\*IN, 5); 1692545eb61SSteven Rostedt } while (defined($line)); 1702545eb61SSteven Rostedt 171*75c3fda7SSteven Rostedt reboot_to; 1722545eb61SSteven Rostedt 1732545eb61SSteven Rostedt for (;;) { 1742545eb61SSteven Rostedt 1752545eb61SSteven Rostedt $line = wait_for_input(\*IN); 1762545eb61SSteven Rostedt 1772545eb61SSteven Rostedt last if (!defined($line)); 1782545eb61SSteven Rostedt 1792545eb61SSteven Rostedt doprint $line; 1802545eb61SSteven Rostedt 1812545eb61SSteven Rostedt # we are not guaranteed to get a full line 1822545eb61SSteven Rostedt $full_line .= $line; 1832545eb61SSteven Rostedt 1842545eb61SSteven Rostedt if ($full_line =~ /login:/) { 1852545eb61SSteven Rostedt $booted = 1; 1862545eb61SSteven Rostedt } 1872545eb61SSteven Rostedt 1885c42fc5bSSteven Rostedt if ($full_line =~ /\[ backtrace testing \]/) { 1895c42fc5bSSteven Rostedt $skip_call_trace = 1; 1905c42fc5bSSteven Rostedt } 1915c42fc5bSSteven Rostedt 1922545eb61SSteven Rostedt if ($full_line =~ /call trace:/i) { 1935c42fc5bSSteven Rostedt $bug = 1 if (!$skip_call_trace); 1945c42fc5bSSteven Rostedt } 1955c42fc5bSSteven Rostedt 1965c42fc5bSSteven Rostedt if ($full_line =~ /\[ end of backtrace testing \]/) { 1975c42fc5bSSteven Rostedt $skip_call_trace = 0; 1985c42fc5bSSteven Rostedt } 1995c42fc5bSSteven Rostedt 2005c42fc5bSSteven Rostedt if ($full_line =~ /Kernel panic -/) { 2012545eb61SSteven Rostedt $bug = 1; 2022545eb61SSteven Rostedt } 2032545eb61SSteven Rostedt 2042545eb61SSteven Rostedt if ($line =~ /\n/) { 2052545eb61SSteven Rostedt $full_line = ""; 2062545eb61SSteven Rostedt } 2072545eb61SSteven Rostedt } 2082545eb61SSteven Rostedt 2092545eb61SSteven Rostedt doprint "kill child process $pid\n"; 2102545eb61SSteven Rostedt kill 2, $pid; 2112545eb61SSteven Rostedt 2122545eb61SSteven Rostedt print "closing!\n"; 2132545eb61SSteven Rostedt close(IN); 2142545eb61SSteven Rostedt 2152545eb61SSteven Rostedt if (!$booted) { 2165c42fc5bSSteven Rostedt dodie "failed - never got a boot prompt.\n"; 2172545eb61SSteven Rostedt } 2182545eb61SSteven Rostedt 2192545eb61SSteven Rostedt if ($bug) { 2205c42fc5bSSteven Rostedt dodie "failed - got a bug report\n"; 2212545eb61SSteven Rostedt } 2222545eb61SSteven Rostedt} 2232545eb61SSteven Rostedt 2242545eb61SSteven Rostedtsub install { 2252545eb61SSteven Rostedt 2262545eb61SSteven Rostedt if (run_command "scp $opt{OUTPUT_DIR}/$opt{BUILD_TARGET} $target:$opt{TARGET_IMAGE}") { 2275c42fc5bSSteven Rostedt dodie "failed to copy image"; 2282545eb61SSteven Rostedt } 2292545eb61SSteven Rostedt 2302545eb61SSteven Rostedt if ($install_mods) { 2312545eb61SSteven Rostedt my $modlib = "/lib/modules/$version"; 2325c42fc5bSSteven Rostedt my $modtar = "autotest-mods.tar.bz2"; 2332545eb61SSteven Rostedt 2342545eb61SSteven Rostedt if (run_command "ssh $target rm -rf $modlib") { 2355c42fc5bSSteven Rostedt dodie "failed to remove old mods: $modlib"; 2362545eb61SSteven Rostedt } 2372545eb61SSteven Rostedt 2385c42fc5bSSteven Rostedt # would be nice if scp -r did not follow symbolic links 239*75c3fda7SSteven Rostedt if (run_command "cd $opt{TMP_DIR} && tar -cjf $modtar lib/modules/$version") { 2405c42fc5bSSteven Rostedt dodie "making tarball"; 2412545eb61SSteven Rostedt } 2425c42fc5bSSteven Rostedt 2435c42fc5bSSteven Rostedt if (run_command "scp $opt{TMP_DIR}/$modtar $target:/tmp") { 2445c42fc5bSSteven Rostedt dodie "failed to copy modules"; 2455c42fc5bSSteven Rostedt } 2465c42fc5bSSteven Rostedt 2475c42fc5bSSteven Rostedt unlink "$opt{TMP_DIR}/$modtar"; 2485c42fc5bSSteven Rostedt 2495c42fc5bSSteven Rostedt if (run_command "ssh $target '(cd / && tar xf /tmp/$modtar)'") { 2505c42fc5bSSteven Rostedt dodie "failed to tar modules"; 2515c42fc5bSSteven Rostedt } 2525c42fc5bSSteven Rostedt 2535c42fc5bSSteven Rostedt run_command "ssh $target rm -f /tmp/$modtar"; 2542545eb61SSteven Rostedt } 2552545eb61SSteven Rostedt 2562545eb61SSteven Rostedt} 2572545eb61SSteven Rostedt 2582545eb61SSteven Rostedtsub build { 2592545eb61SSteven Rostedt my ($type) = @_; 2605c42fc5bSSteven Rostedt my $defconfig = ""; 2615c42fc5bSSteven Rostedt my $append = ""; 2622545eb61SSteven Rostedt 263*75c3fda7SSteven Rostedt if ($type =~ /^useconfig:(.*)/) { 264*75c3fda7SSteven Rostedt if (run_command "cp $1 $opt{OUTPUT_DIR}/.config") { 265*75c3fda7SSteven Rostedt dodie "could not copy $1 to .config"; 266*75c3fda7SSteven Rostedt } 267*75c3fda7SSteven Rostedt $type = "oldconfig"; 268*75c3fda7SSteven Rostedt } 269*75c3fda7SSteven Rostedt 2705c42fc5bSSteven Rostedt # old config can ask questions 2715c42fc5bSSteven Rostedt if ($type eq "oldconfig") { 2725c42fc5bSSteven Rostedt $append = "yes ''|"; 273*75c3fda7SSteven Rostedt 274*75c3fda7SSteven Rostedt # allow for empty configs 275*75c3fda7SSteven Rostedt run_command "touch $opt{OUTPUT_DIR}/.config"; 276*75c3fda7SSteven Rostedt 2775c42fc5bSSteven Rostedt if (run_command "mv $opt{OUTPUT_DIR}/.config $opt{OUTPUT_DIR}/config_temp") { 2785c42fc5bSSteven Rostedt dodie "moving .config"; 2795c42fc5bSSteven Rostedt } 2805c42fc5bSSteven Rostedt 2815c42fc5bSSteven Rostedt if (!$noclean && run_command "$make mrproper") { 2825c42fc5bSSteven Rostedt dodie "make mrproper"; 2835c42fc5bSSteven Rostedt } 2845c42fc5bSSteven Rostedt 2855c42fc5bSSteven Rostedt if (run_command "mv $opt{OUTPUT_DIR}/config_temp $opt{OUTPUT_DIR}/.config") { 2865c42fc5bSSteven Rostedt dodie "moving config_temp"; 2875c42fc5bSSteven Rostedt } 2885c42fc5bSSteven Rostedt 2895c42fc5bSSteven Rostedt } elsif (!$noclean) { 2902545eb61SSteven Rostedt unlink "$opt{OUTPUT_DIR}/.config"; 2915c42fc5bSSteven Rostedt if (run_command "$make mrproper") { 2925c42fc5bSSteven Rostedt dodie "make mrproper"; 2935c42fc5bSSteven Rostedt } 2945c42fc5bSSteven Rostedt } 2952545eb61SSteven Rostedt 2962545eb61SSteven Rostedt # add something to distinguish this build 2975c42fc5bSSteven Rostedt open(OUT, "> $opt{OUTPUT_DIR}/localversion") or dodie("Can't make localversion file"); 2982545eb61SSteven Rostedt print OUT "$opt{LOCALVERSION}\n"; 2992545eb61SSteven Rostedt close(OUT); 3002545eb61SSteven Rostedt 3015c42fc5bSSteven Rostedt if (defined($opt{"MIN_CONFIG"})) { 3025c42fc5bSSteven Rostedt $defconfig = "KCONFIG_ALLCONFIG=$opt{MIN_CONFIG}"; 3032545eb61SSteven Rostedt } 3042545eb61SSteven Rostedt 3055c42fc5bSSteven Rostedt if (run_command "$defconfig $append $make $type") { 3065c42fc5bSSteven Rostedt dodie "failed make config"; 3072545eb61SSteven Rostedt } 3082545eb61SSteven Rostedt 3092545eb61SSteven Rostedt if (run_command "$make $opt{BUILD_OPTIONS}") { 3105c42fc5bSSteven Rostedt dodie "failed build"; 3112545eb61SSteven Rostedt } 3122545eb61SSteven Rostedt} 3132545eb61SSteven Rostedt 314*75c3fda7SSteven Rostedtsub reboot { 315*75c3fda7SSteven Rostedt # try to reboot normally 316*75c3fda7SSteven Rostedt if (run_command "ssh $target reboot") { 317*75c3fda7SSteven Rostedt # nope? power cycle it. 318*75c3fda7SSteven Rostedt run_command "$opt{POWER_CYCLE}"; 319*75c3fda7SSteven Rostedt } 320*75c3fda7SSteven Rostedt} 321*75c3fda7SSteven Rostedt 322*75c3fda7SSteven Rostedtsub halt { 323*75c3fda7SSteven Rostedt if ((run_command "ssh $target halt") or defined($opt{"POWER_OFF"})) { 324*75c3fda7SSteven Rostedt # nope? the zap it! 325*75c3fda7SSteven Rostedt run_command "$opt{POWER_OFF}"; 326*75c3fda7SSteven Rostedt } 327*75c3fda7SSteven Rostedt} 328*75c3fda7SSteven Rostedt 3292545eb61SSteven Rostedtread_config $ARGV[0]; 3302545eb61SSteven Rostedt 3312545eb61SSteven Rostedt# mandatory configs 3322545eb61SSteven Rostedtdie "MACHINE not defined\n" if (!defined($opt{"MACHINE"})); 3332545eb61SSteven Rostedtdie "SSH_USER not defined\n" if (!defined($opt{"SSH_USER"})); 3342545eb61SSteven Rostedtdie "BUILD_DIR not defined\n" if (!defined($opt{"BUILD_DIR"})); 3352545eb61SSteven Rostedtdie "OUTPUT_DIR not defined\n" if (!defined($opt{"OUTPUT_DIR"})); 3362545eb61SSteven Rostedtdie "BUILD_TARGET not defined\n" if (!defined($opt{"BUILD_TARGET"})); 337*75c3fda7SSteven Rostedtdie "TARGET_IMAGE not defined\n" if (!defined($opt{"TARGET_IMAGE"})); 3382545eb61SSteven Rostedtdie "POWER_CYCLE not defined\n" if (!defined($opt{"POWER_CYCLE"})); 3392545eb61SSteven Rostedtdie "CONSOLE not defined\n" if (!defined($opt{"CONSOLE"})); 3402545eb61SSteven Rostedtdie "LOCALVERSION not defined\n" if (!defined($opt{"LOCALVERSION"})); 3412545eb61SSteven Rostedtdie "GRUB_MENU not defined\n" if (!defined($opt{"GRUB_MENU"})); 3422545eb61SSteven Rostedt 3432545eb61SSteven Rostedtchdir $opt{"BUILD_DIR"} || die "can't change directory to $opt{BUILD_DIR}"; 3442545eb61SSteven Rostedt 3452545eb61SSteven Rostedt$target = "$opt{SSH_USER}\@$opt{MACHINE}"; 3462545eb61SSteven Rostedt 3472545eb61SSteven Rostedtdoprint "\n\nSTARTING AUTOMATED TESTS\n"; 3482545eb61SSteven Rostedt 3492545eb61SSteven Rostedtdoprint "Find grub menu ... "; 3502545eb61SSteven Rostedt$grub_number = -1; 3512545eb61SSteven Rostedtopen(IN, "ssh $target cat /boot/grub/menu.lst |") 3522545eb61SSteven Rostedt or die "unable to get menu.lst"; 3532545eb61SSteven Rostedtwhile (<IN>) { 3542545eb61SSteven Rostedt if (/^\s*title\s+$opt{GRUB_MENU}\s*$/) { 3552545eb61SSteven Rostedt $grub_number++; 3562545eb61SSteven Rostedt last; 3572545eb61SSteven Rostedt } elsif (/^\s*title\s/) { 3582545eb61SSteven Rostedt $grub_number++; 3592545eb61SSteven Rostedt } 3602545eb61SSteven Rostedt} 3612545eb61SSteven Rostedtclose(IN); 3622545eb61SSteven Rostedtdie "Could not find '$opt{GRUB_MENU}' in /boot/grub/menu on $opt{MACHINE}" 3632545eb61SSteven Rostedt if ($grub_number < 0); 3642545eb61SSteven Rostedtdoprint "$grub_number\n"; 3652545eb61SSteven Rostedt 3662545eb61SSteven Rostedt$make = "$opt{MAKE_CMD} O=$opt{OUTPUT_DIR}"; 3672545eb61SSteven Rostedt 3682545eb61SSteven Rostedt# First we need to do is the builds 3692545eb61SSteven Rostedtfor (my $i = 1; $i <= $opt{"NUM_BUILDS"}; $i++) { 3702545eb61SSteven Rostedt my $type = "BUILD_TYPE[$i]"; 3712545eb61SSteven Rostedt 3725c42fc5bSSteven Rostedt if (defined($opt{"BUILD_NOCLEAN[$i]"}) && 3735c42fc5bSSteven Rostedt $opt{"BUILD_NOCLEAN[$i]"} != 0) { 3745c42fc5bSSteven Rostedt $noclean = 1; 3755c42fc5bSSteven Rostedt } else { 3765c42fc5bSSteven Rostedt $noclean = $opt{"BUILD_NOCLEAN"}; 3775c42fc5bSSteven Rostedt } 3785c42fc5bSSteven Rostedt 3792545eb61SSteven Rostedt if (!defined($opt{$type})) { 3802545eb61SSteven Rostedt $opt{$type} = $opt{"DEFAULT_BUILD_TYPE"}; 3812545eb61SSteven Rostedt } 3822545eb61SSteven Rostedt 3832545eb61SSteven Rostedt doprint "\n\n"; 3842545eb61SSteven Rostedt doprint "RUNNING TEST $i of $opt{NUM_BUILDS} with option $opt{$type}\n\n"; 3852545eb61SSteven Rostedt 3862545eb61SSteven Rostedt if ($opt{$type} ne "nobuild") { 3875c42fc5bSSteven Rostedt build $opt{$type}; 3882545eb61SSteven Rostedt } 3892545eb61SSteven Rostedt 3902545eb61SSteven Rostedt # get the release name 3912545eb61SSteven Rostedt doprint "$make kernelrelease ... "; 3922545eb61SSteven Rostedt $version = `$make kernelrelease | tail -1`; 3932545eb61SSteven Rostedt chomp($version); 3942545eb61SSteven Rostedt doprint "$version\n"; 3952545eb61SSteven Rostedt 3962545eb61SSteven Rostedt # should we process modules? 3972545eb61SSteven Rostedt $install_mods = 0; 3985c42fc5bSSteven Rostedt open(IN, "$opt{OUTPUT_DIR}/.config") or dodie("Can't read config file"); 3992545eb61SSteven Rostedt while (<IN>) { 4002545eb61SSteven Rostedt if (/CONFIG_MODULES(=y)?/) { 4012545eb61SSteven Rostedt $install_mods = 1 if (defined($1)); 4022545eb61SSteven Rostedt last; 4032545eb61SSteven Rostedt } 4042545eb61SSteven Rostedt } 4052545eb61SSteven Rostedt close(IN); 4062545eb61SSteven Rostedt 4072545eb61SSteven Rostedt if ($install_mods) { 4082545eb61SSteven Rostedt if (run_command "$make INSTALL_MOD_PATH=$opt{TMP_DIR} modules_install") { 4095c42fc5bSSteven Rostedt dodie "Failed to install modules"; 4102545eb61SSteven Rostedt } 4112545eb61SSteven Rostedt } else { 4122545eb61SSteven Rostedt doprint "No modules needed\n"; 4132545eb61SSteven Rostedt } 4142545eb61SSteven Rostedt 4152545eb61SSteven Rostedt install; 4162545eb61SSteven Rostedt 4172545eb61SSteven Rostedt monitor; 4182545eb61SSteven Rostedt 4192545eb61SSteven Rostedt doprint "\n\n*******************************************\n"; 4202545eb61SSteven Rostedt doprint "*******************************************\n"; 4212545eb61SSteven Rostedt doprint "** SUCCESS!!!! **\n"; 4222545eb61SSteven Rostedt doprint "*******************************************\n"; 4232545eb61SSteven Rostedt doprint "*******************************************\n"; 4242545eb61SSteven Rostedt 425*75c3fda7SSteven Rostedt if ($i != $opt{"NUM_BUILDS"}) { 426*75c3fda7SSteven Rostedt reboot; 4272545eb61SSteven Rostedt sleep "$opt{SLEEP_TIME}"; 4282545eb61SSteven Rostedt } 429*75c3fda7SSteven Rostedt} 4302545eb61SSteven Rostedt 4315c42fc5bSSteven Rostedtif ($opt{"POWEROFF_ON_SUCCESS"}) { 432*75c3fda7SSteven Rostedt halt; 433*75c3fda7SSteven Rostedt} else { 434*75c3fda7SSteven Rostedt reboot; 4355c42fc5bSSteven Rostedt} 436*75c3fda7SSteven Rostedt 4372545eb61SSteven Rostedtexit 0; 438