}
proc examine-host-examine {install} {
+ global ok
catching-otherwise fail {
examine-host-install-$install
+ run-ts . = ts-examine-serial-pre + host
run-ts . reboot ts-host-reboot + host
}
run-ts !broken capture-logs ts-logs-capture + host
+ if {$ok} {
+ run-ts -. = ts-examine-serial-post + host
+ }
}
proc need-hosts/host-examine-xen {} { return {} }
--- /dev/null
+#!/usr/bin/perl -w
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2009-2013 Citrix Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# usage
+# ./ts-examine-serial-pre [host]
+# creates some random cookies to be printed to the serial console
+# $r{examine_serial_cookie_kernel} printed once by this script
+# $r{examine_serial_cookie_bootloader} will be printed on later boots
+#
+# These are later used by ts-examine-serial-post
+
+use strict qw(vars);
+use DBI;
+unshift @INC, qw(.);
+use Osstest;
+use POSIX;
+use Osstest::TestSupport;
+
+tsreadconfig();
+
+our ($whhost) = @ARGV;
+$whhost ||= 'host';
+our $ho= selecthost($whhost);
+
+our @cookies;
+
+sub cookies () {
+ foreach my $rv (sort keys %r) {
+ next unless $rv =~ /^examine_serial_cookie_(\w+)$/;
+ my $key = $1;
+ my $substep = "examine-serial/$key";
+ my $ci = { K => $key, C => $r{$rv}, Substep => $substep };
+ substep_start($ci->{Substep}, 'ts-examine-serial-post');
+ push @cookies, $ci;
+ }
+}
+
+sub scan () {
+ foreach my $lf (<$stash/serial-*>) {
+ if ($lf =~ m/\.gz$/) {
+ open L, '-|', qw(zcat --), $lf or die $!;
+ } else {
+ open L, '<', $lf or die "$lf $!";
+ }
+ logm("examining logfile $lf");
+ while (<L>) {
+ foreach my $ci (@cookies) {
+ next if $ci->{Found};
+ next unless index($_,$ci->{C}) >= 0;
+ logm("found cookie for $ci->{K}");
+ $ci->{Found} = 1;
+ }
+ }
+ $!=0; $?=0; close L or die "$lf $? $!";
+ }
+}
+
+sub report () {
+ foreach my $ci (@cookies) {
+ substep_finish($ci->{Substep},
+ $ci->{Found} ? 'pass' : 'fail');
+ }
+}
+
+cookies();
+scan();
+report();
--- /dev/null
+#!/usr/bin/perl -w
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2009-2013 Citrix Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# usage
+# ./ts-examine-serial-pre [host]
+# creates some random cookies to be printed to the serial console
+# $r{examine_serial_cookie_kernel} printed once by this script
+# $r{examine_serial_cookie_bootloader} will be printed on later boots
+
+use strict qw(vars);
+use DBI;
+unshift @INC, qw(.);
+use Osstest;
+use POSIX;
+use Osstest::TestSupport;
+use Osstest::Debian;
+
+tsreadconfig();
+
+our ($whhost) = @ARGV;
+$whhost ||= 'host';
+our $ho= selecthost($whhost);
+
+die "do not want to mess up a shared host" if
+ $ho->{SharedReady} or
+ $ho->{Flags}{'no-reinstall'};
+
+sub get_cookie ($) {
+ my ($key) = @_;
+ my $rname = "examine_serial_cookie_$key";
+ return $r{$rname} if defined $r{$rname};
+ open R, "/dev/urandom";
+ my $v;
+ my $l = 16;
+ read(R, $v, $l) == $l or die;
+ $v = unpack "H*", $v;
+ store_runvar($rname, $v);
+ return $v;
+}
+
+sub ordinary_console () {
+ my $c = get_cookie('kernel');
+ target_cmd_root($ho, <<END);
+ echo 'osstest kernel cookie $c' >/dev/console
+END
+}
+
+sub bootloader () {
+ my $c = get_cookie('bootloader');
+ my $ed = sub {
+ my ($file,$script) = @_;
+ my $cmd = <<END;
+ ed $file <<EOF
+$script
+w
+q
+EOF
+END
+ $cmd .= setupboot_bootloader_edited_rune($ho);
+ target_cmd_root($ho, $cmd, 200);
+ };
+ my $edscript;
+ if ($ho->{Flags}{'need-uboot-bootscr'}) {
+ $ed->('/boot/boot.xen',<<END)
+/^echo Loaded
+i
+echo osstest uboot $c
+.
+END
+ } else {
+ $ed->('/boot/grub/grub.cfg',<<END); # no support for grub1
+\$
+?^terminal_
+a
+echo osstest grub2 $c
+sleep 2
+.
+END
+ }
+}
+
+ordinary_console();
+bootloader();