forked from os-autoinst/os-autoinst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
isotovideo
executable file
·170 lines (135 loc) · 3.76 KB
/
isotovideo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/usr/bin/perl -w
#
# Start up the VM and start feeding it the distribution test script
# specified in the DISTRI environment variable.
#
use strict;
use threads;
local $Devel::Trace::TRACE = 0;
our $installprefix;
BEGIN {
# the following line is modified during make install
$installprefix = undef;
my ($wd) = $0 =~ m-(.*)/-;
$wd ||= '.';
$installprefix ||= $wd;
unshift @INC, "$installprefix";
}
use bmwqemu qw(diag);
use needle;
use autotest;
use Getopt::Std;
# avoid paranoia
$Getopt::Std::STANDARD_HELP_VERSION = 1;
sub HELP_MESSAGE {
print "$0 [-d]\n";
print "Parses vars.json and tests the given assets/ISOS\n\n";
print " -d enables direct output to STDERR instead of autoinst-log.txt\n"
}
# enable debug default when started from a tty
$bmwqemu::istty = -t 1;
our ($opt_d);
getopts('d');
$bmwqemu::direct_output = $opt_d;
select(STDERR);
$| = 1;
select(STDOUT); # default
$| = 1;
$bmwqemu::scriptdir = $installprefix;
bmwqemu::init();
# Sanity checks
die "DISTRI environment variable not set. unknown OS?" if !defined $bmwqemu::vars{DISTRI} && !defined $bmwqemu::vars{CASEDIR};
die "No scripts in $bmwqemu::vars{CASEDIR}" if !-e "$bmwqemu::vars{CASEDIR}";
bmwqemu::clean_control_files();
my $init = 1;
# all so ugly ...
sub signalhandler {
# do not start a race about the results between the threads
my $sig = shift;
diag("signalhandler $$: got $sig");
if ($autotest::running) {
$autotest::running->fail_if_running();
$autotest::running = undef;
}
if ( threads->tid() == 0 ) {
bmwqemu::stop_vm();
# mark it as no longer working
delete $ENV{WORKERID};
bmwqemu::save_status();
}
else {
print STDERR "bug!? signal not received in main thread\n";
}
exit(1);
}
$SIG{ALRM} = \&signalhandler;
$SIG{TERM} = \&signalhandler;
$SIG{INT} = \&signalhandler;
$SIG{HUP} = \&signalhandler;
$ENV{MOJO_MAX_MESSAGE_SIZE} = 107741824;
# start web background server that provides real time information
# about the ongoing run
use commands;
# Load the main.pm from the casedir checked by the sanity checks above
require $bmwqemu::vars{CASEDIR}."/main.pm";
# init part
$bmwqemu::vars{BACKEND} ||= "qemu";
bmwqemu::save_vars();
bmwqemu::init_backend( $bmwqemu::vars{BACKEND} );
needle::init();
if ($init) {
open( my $fd, ">os-autoinst.pid" );
print $fd "$$\n";
close $fd;
# run prestart test code before VM is started
if (-f "$bmwqemu::vars{CASEDIR}/prestart.pm") {
diag "running prestart step";
eval {require $bmwqemu::vars{CASEDIR}."/prestart.pm";};
if ($@) {
diag "prestart step FAIL:";
die $@;
}
}
if ( !bmwqemu::alive ) {
bmwqemu::start_vm or die $@;
}
}
my $ct = commands::start_server($bmwqemu::vars{QEMUPORT} + 1);
if ($ENV{RUN_VNCVIEWER}) {
system("vncviewer -shared localhost:" . $bmwqemu::vars{VNC} . " -viewonly &");
}
require Carp;
my $r = 0;
eval { autotest::runalltests(); };
if ($@) {
warn $@;
$r = 1;
}
else {
# this is only for still getting screenshots while
# all testscripts would have been already run
sleep 10;
}
diag "isotovideo done" unless $r;
diag "FAIL" if $r;
$SIG{ALRM} = 'IGNORE'; # ignore ALRM so the readthread doesn't kill us here
bmwqemu::stop_vm();
print "killing commands thread\n";
$ct->kill('SIGTERM');
$ct->join();
print "done joining commands thread\n";
# run postrun test code after VM is stopped
if (-f "$bmwqemu::vars{CASEDIR}/postrun.pm") {
diag "running postrun step";
eval {require "$bmwqemu::vars{CASEDIR}/postrun.pm";};
if ($@) {
diag "postrun step FAIL:";
warn $@;
}
}
# mark it as no longer working
delete $ENV{WORKERID};
# Write JSON result
bmwqemu::save_status();
exit $r;
# vim: set sw=4 et: