ktest: New features: noclean, dodie, poweroff on error and success
Added dodie function to have a bit more control over die calls. BUILD_NOCLEAN to not run make mrproper or remove .config. POWEROFF_ON_{SUCCESS,ERROR} to turn off the power after tests. Skip backtrace calls that were done by the backtrace tests. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
Родитель
2545eb6198
Коммит
5c42fc5b97
|
@ -18,12 +18,16 @@ $opt{"MAKE_CMD"} = "make";
|
||||||
$opt{"TIMEOUT"} = 50;
|
$opt{"TIMEOUT"} = 50;
|
||||||
$opt{"TMP_DIR"} = "/tmp/autotest";
|
$opt{"TMP_DIR"} = "/tmp/autotest";
|
||||||
$opt{"SLEEP_TIME"} = 60; # sleep time between tests
|
$opt{"SLEEP_TIME"} = 60; # sleep time between tests
|
||||||
|
$opt{"BUILD_NOCLEAN"} = 0;
|
||||||
|
$opt{"POWEROFF_ON_ERROR"} = 0;
|
||||||
|
$opt{"POWEROFF_ON_SUCCESS"} = 0;
|
||||||
|
|
||||||
my $version;
|
my $version;
|
||||||
my $install_mods;
|
my $install_mods;
|
||||||
my $grub_number;
|
my $grub_number;
|
||||||
my $target;
|
my $target;
|
||||||
my $make;
|
my $make;
|
||||||
|
my $noclean;
|
||||||
|
|
||||||
sub read_config {
|
sub read_config {
|
||||||
my ($config) = @_;
|
my ($config) = @_;
|
||||||
|
@ -56,6 +60,16 @@ sub doprint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub dodie {
|
||||||
|
doprint "CRITICAL FAILURE... ", @_;
|
||||||
|
|
||||||
|
if ($opt{"POWEROFF_ON_ERROR"} && defined($opt{"POWER_OFF"})) {
|
||||||
|
doprint "POWERING OFF\n";
|
||||||
|
`$opt{"POWER_OFF"}`;
|
||||||
|
}
|
||||||
|
die @_;
|
||||||
|
}
|
||||||
|
|
||||||
sub run_command {
|
sub run_command {
|
||||||
my ($command) = @_;
|
my ($command) = @_;
|
||||||
my $redirect = "";
|
my $redirect = "";
|
||||||
|
@ -121,21 +135,22 @@ sub monitor {
|
||||||
my $bug = 0;
|
my $bug = 0;
|
||||||
my $pid;
|
my $pid;
|
||||||
my $doopen2 = 0;
|
my $doopen2 = 0;
|
||||||
|
my $skip_call_trace = 0;
|
||||||
|
|
||||||
if ($doopen2) {
|
if ($doopen2) {
|
||||||
$pid = open2(\*IN, \*OUT, $opt{CONSOLE});
|
$pid = open2(\*IN, \*OUT, $opt{CONSOLE});
|
||||||
if ($pid < 0) {
|
if ($pid < 0) {
|
||||||
die "Failed to connect to the console";
|
dodie "Failed to connect to the console";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$pid = open(IN, "$opt{CONSOLE} |");
|
$pid = open(IN, "$opt{CONSOLE} |");
|
||||||
}
|
}
|
||||||
|
|
||||||
$flags = fcntl(IN, F_GETFL, 0) or
|
$flags = fcntl(IN, F_GETFL, 0) or
|
||||||
die "Can't get flags for the socket: $!\n";
|
dodie "Can't get flags for the socket: $!\n";
|
||||||
|
|
||||||
$flags = fcntl(IN, F_SETFL, $flags | O_NONBLOCK) or
|
$flags = fcntl(IN, F_SETFL, $flags | O_NONBLOCK) or
|
||||||
die "Can't set flags for the socket: $!\n";
|
dodie "Can't set flags for the socket: $!\n";
|
||||||
|
|
||||||
my $line;
|
my $line;
|
||||||
my $full_line = "";
|
my $full_line = "";
|
||||||
|
@ -163,7 +178,19 @@ sub monitor {
|
||||||
$booted = 1;
|
$booted = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($full_line =~ /\[ backtrace testing \]/) {
|
||||||
|
$skip_call_trace = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if ($full_line =~ /call trace:/i) {
|
if ($full_line =~ /call trace:/i) {
|
||||||
|
$bug = 1 if (!$skip_call_trace);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($full_line =~ /\[ end of backtrace testing \]/) {
|
||||||
|
$skip_call_trace = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($full_line =~ /Kernel panic -/) {
|
||||||
$bug = 1;
|
$bug = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,57 +206,90 @@ sub monitor {
|
||||||
close(IN);
|
close(IN);
|
||||||
|
|
||||||
if (!$booted) {
|
if (!$booted) {
|
||||||
die "failed - never got a boot prompt.\n";
|
dodie "failed - never got a boot prompt.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($bug) {
|
if ($bug) {
|
||||||
die "failed - got a bug report\n";
|
dodie "failed - got a bug report\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub install {
|
sub install {
|
||||||
|
|
||||||
if (run_command "scp $opt{OUTPUT_DIR}/$opt{BUILD_TARGET} $target:$opt{TARGET_IMAGE}") {
|
if (run_command "scp $opt{OUTPUT_DIR}/$opt{BUILD_TARGET} $target:$opt{TARGET_IMAGE}") {
|
||||||
die "failed to copy image";
|
dodie "failed to copy image";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($install_mods) {
|
if ($install_mods) {
|
||||||
my $modlib = "/lib/modules/$version";
|
my $modlib = "/lib/modules/$version";
|
||||||
|
my $modtar = "autotest-mods.tar.bz2";
|
||||||
|
|
||||||
if (run_command "ssh $target rm -rf $modlib") {
|
if (run_command "ssh $target rm -rf $modlib") {
|
||||||
die "failed to remove old mods: $modlib";
|
dodie "failed to remove old mods: $modlib";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (run_command "scp -r $opt{TMP_DIR}/lib $target:/lib/modules/$version") {
|
# would be nice if scp -r did not follow symbolic links
|
||||||
die "failed to copy modules";
|
if (run_command "cd $opt{TMP_DIR}; tar -cjf $modtar lib/modules/$version") {
|
||||||
|
dodie "making tarball";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (run_command "scp $opt{TMP_DIR}/$modtar $target:/tmp") {
|
||||||
|
dodie "failed to copy modules";
|
||||||
|
}
|
||||||
|
|
||||||
|
unlink "$opt{TMP_DIR}/$modtar";
|
||||||
|
|
||||||
|
if (run_command "ssh $target '(cd / && tar xf /tmp/$modtar)'") {
|
||||||
|
dodie "failed to tar modules";
|
||||||
|
}
|
||||||
|
|
||||||
|
run_command "ssh $target rm -f /tmp/$modtar";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub build {
|
sub build {
|
||||||
my ($type) = @_;
|
my ($type) = @_;
|
||||||
|
my $defconfig = "";
|
||||||
|
my $append = "";
|
||||||
|
|
||||||
unlink "$opt{OUTPUT_DIR}/.config";
|
# old config can ask questions
|
||||||
|
if ($type eq "oldconfig") {
|
||||||
|
$append = "yes ''|";
|
||||||
|
if (run_command "mv $opt{OUTPUT_DIR}/.config $opt{OUTPUT_DIR}/config_temp") {
|
||||||
|
dodie "moving .config";
|
||||||
|
}
|
||||||
|
|
||||||
run_command "$make mrproper";
|
if (!$noclean && run_command "$make mrproper") {
|
||||||
|
dodie "make mrproper";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (run_command "mv $opt{OUTPUT_DIR}/config_temp $opt{OUTPUT_DIR}/.config") {
|
||||||
|
dodie "moving config_temp";
|
||||||
|
}
|
||||||
|
|
||||||
|
} elsif (!$noclean) {
|
||||||
|
unlink "$opt{OUTPUT_DIR}/.config";
|
||||||
|
if (run_command "$make mrproper") {
|
||||||
|
dodie "make mrproper";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# add something to distinguish this build
|
# add something to distinguish this build
|
||||||
open(OUT, "> $opt{OUTPUT_DIR}/localversion") or die("Can't make localversion file");
|
open(OUT, "> $opt{OUTPUT_DIR}/localversion") or dodie("Can't make localversion file");
|
||||||
print OUT "$opt{LOCALVERSION}\n";
|
print OUT "$opt{LOCALVERSION}\n";
|
||||||
close(OUT);
|
close(OUT);
|
||||||
|
|
||||||
if (run_command "$make $opt{$type}") {
|
if (defined($opt{"MIN_CONFIG"})) {
|
||||||
die "failed make config";
|
$defconfig = "KCONFIG_ALLCONFIG=$opt{MIN_CONFIG}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined($opt{"MIN_CONFIG"})) {
|
if (run_command "$defconfig $append $make $type") {
|
||||||
run_command "cat $opt{MIN_CONFIG} >> $opt{OUTPUT_DIR}/.config";
|
dodie "failed make config";
|
||||||
run_command "yes '' | $make oldconfig";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (run_command "$make $opt{BUILD_OPTIONS}") {
|
if (run_command "$make $opt{BUILD_OPTIONS}") {
|
||||||
die "failed build";
|
dodie "failed build";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,6 +335,13 @@ $make = "$opt{MAKE_CMD} O=$opt{OUTPUT_DIR}";
|
||||||
for (my $i = 1; $i <= $opt{"NUM_BUILDS"}; $i++) {
|
for (my $i = 1; $i <= $opt{"NUM_BUILDS"}; $i++) {
|
||||||
my $type = "BUILD_TYPE[$i]";
|
my $type = "BUILD_TYPE[$i]";
|
||||||
|
|
||||||
|
if (defined($opt{"BUILD_NOCLEAN[$i]"}) &&
|
||||||
|
$opt{"BUILD_NOCLEAN[$i]"} != 0) {
|
||||||
|
$noclean = 1;
|
||||||
|
} else {
|
||||||
|
$noclean = $opt{"BUILD_NOCLEAN"};
|
||||||
|
}
|
||||||
|
|
||||||
if (!defined($opt{$type})) {
|
if (!defined($opt{$type})) {
|
||||||
$opt{$type} = $opt{"DEFAULT_BUILD_TYPE"};
|
$opt{$type} = $opt{"DEFAULT_BUILD_TYPE"};
|
||||||
}
|
}
|
||||||
|
@ -283,7 +350,7 @@ for (my $i = 1; $i <= $opt{"NUM_BUILDS"}; $i++) {
|
||||||
doprint "RUNNING TEST $i of $opt{NUM_BUILDS} with option $opt{$type}\n\n";
|
doprint "RUNNING TEST $i of $opt{NUM_BUILDS} with option $opt{$type}\n\n";
|
||||||
|
|
||||||
if ($opt{$type} ne "nobuild") {
|
if ($opt{$type} ne "nobuild") {
|
||||||
build $type;
|
build $opt{$type};
|
||||||
}
|
}
|
||||||
|
|
||||||
# get the release name
|
# get the release name
|
||||||
|
@ -294,7 +361,7 @@ for (my $i = 1; $i <= $opt{"NUM_BUILDS"}; $i++) {
|
||||||
|
|
||||||
# should we process modules?
|
# should we process modules?
|
||||||
$install_mods = 0;
|
$install_mods = 0;
|
||||||
open(IN, "$opt{OUTPUT_DIR}/.config") or die("Can't read config file");
|
open(IN, "$opt{OUTPUT_DIR}/.config") or dodie("Can't read config file");
|
||||||
while (<IN>) {
|
while (<IN>) {
|
||||||
if (/CONFIG_MODULES(=y)?/) {
|
if (/CONFIG_MODULES(=y)?/) {
|
||||||
$install_mods = 1 if (defined($1));
|
$install_mods = 1 if (defined($1));
|
||||||
|
@ -305,7 +372,7 @@ for (my $i = 1; $i <= $opt{"NUM_BUILDS"}; $i++) {
|
||||||
|
|
||||||
if ($install_mods) {
|
if ($install_mods) {
|
||||||
if (run_command "$make INSTALL_MOD_PATH=$opt{TMP_DIR} modules_install") {
|
if (run_command "$make INSTALL_MOD_PATH=$opt{TMP_DIR} modules_install") {
|
||||||
die "Failed to install modules";
|
dodie "Failed to install modules";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
doprint "No modules needed\n";
|
doprint "No modules needed\n";
|
||||||
|
@ -331,4 +398,10 @@ for (my $i = 1; $i <= $opt{"NUM_BUILDS"}; $i++) {
|
||||||
sleep "$opt{SLEEP_TIME}";
|
sleep "$opt{SLEEP_TIME}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($opt{"POWEROFF_ON_SUCCESS"}) {
|
||||||
|
if (run_command "ssh $target halt" && defined($opt{"POWER_OFF"})) {
|
||||||
|
# nope? the zap it!
|
||||||
|
run_command "$opt{POWER_OFF}";
|
||||||
|
}
|
||||||
|
}
|
||||||
exit 0;
|
exit 0;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче