| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Tapper::SimNow; |
|
2
|
|
|
|
|
|
|
# git description: v4.1.0-1-gefbd11b |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
BEGIN { |
|
5
|
1
|
|
|
1
|
|
57763
|
$Tapper::SimNow::AUTHORITY = 'cpan:TAPPER'; |
|
6
|
|
|
|
|
|
|
} |
|
7
|
|
|
|
|
|
|
{ |
|
8
|
|
|
|
|
|
|
$Tapper::SimNow::VERSION = '4.1.1'; |
|
9
|
|
|
|
|
|
|
} |
|
10
|
|
|
|
|
|
|
# ABSTRACT: Tapper - Support for running SimNow sessions |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
2334
|
use Moose; |
|
|
1
|
|
|
|
|
770033
|
|
|
|
1
|
|
|
|
|
12
|
|
|
13
|
1
|
|
|
1
|
|
12859
|
use common::sense; |
|
|
1
|
|
|
|
|
9
|
|
|
|
1
|
|
|
|
|
5
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
58
|
use File::Basename; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
89
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
394
|
use Tapper::Remote::Config; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use Tapper::Remote::Net; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
extends 'Tapper::Base'; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has cfg => (is => 'rw', |
|
23
|
|
|
|
|
|
|
isa => 'HashRef', |
|
24
|
|
|
|
|
|
|
default => sub { {} }, |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub get_static_tap_headers |
|
30
|
|
|
|
|
|
|
{ |
|
31
|
|
|
|
|
|
|
my ($self, $report) = @_; |
|
32
|
|
|
|
|
|
|
$report->{headers}{'Tapper-reportgroup-testrun'} = $self->cfg->{test_run}; |
|
33
|
|
|
|
|
|
|
$report->{headers}{'Tapper-suite-name'} = "SimNow-Metainfo"; |
|
34
|
|
|
|
|
|
|
$report->{headers}{'Tapper-suite-version'} = $Tapper::SimNow::VERSION; |
|
35
|
|
|
|
|
|
|
$report->{headers}{'Tapper-machine-name'} = $self->cfg->{hostname}; |
|
36
|
|
|
|
|
|
|
return $report; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub generate_meta_report |
|
41
|
|
|
|
|
|
|
{ |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my ($self) = @_; |
|
44
|
|
|
|
|
|
|
my $report; |
|
45
|
|
|
|
|
|
|
$report = $self->get_static_tap_headers($report); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $error = 0; |
|
48
|
|
|
|
|
|
|
my ($success, $retval) = $self->log_and_exec($self->cfg->{paths}->{simnow_path}."/simnow","--version"); |
|
49
|
|
|
|
|
|
|
if ($success) { |
|
50
|
|
|
|
|
|
|
push @{$report->{tests}}, {error => 1, test => "Getting SimNow version"}; |
|
51
|
|
|
|
|
|
|
} else { |
|
52
|
|
|
|
|
|
|
push @{$report->{tests}}, {test => "Getting SimNow version"}; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
if ($retval =~ m/This is AMD SimNow version (\d+\.\d+\.\d+(-NDA)?)/) { |
|
55
|
|
|
|
|
|
|
$report->{headers}{'Tapper-SimNow-Version'} = $1; |
|
56
|
|
|
|
|
|
|
} else { |
|
57
|
|
|
|
|
|
|
$report->{headers}{'Tapper-SimNow-Version'} = 'Not set'; |
|
58
|
|
|
|
|
|
|
$error = 1; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
push @{$report->{tests}}, {error => $error, test => "Parsing SimNow version"}; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$error = 0; |
|
64
|
|
|
|
|
|
|
if ($retval =~ m/This internal release is built from revision: (.+) of SVN URL: (.+)/) { |
|
65
|
|
|
|
|
|
|
$report->{headers}{'Tapper-SimNow-SVN-Version'} = $1; |
|
66
|
|
|
|
|
|
|
$report->{headers}{'Tapper-SimNow-SVN-Repository'} = $2; |
|
67
|
|
|
|
|
|
|
} elsif ($retval =~ m/Build number: (.+)/) { |
|
68
|
|
|
|
|
|
|
$report->{headers}{'Tapper-SimNow-SVN-Version'} = $1; |
|
69
|
|
|
|
|
|
|
$report->{headers}{'Tapper-SimNow-SVN-Repository'} = 'Not set'; |
|
70
|
|
|
|
|
|
|
} else { |
|
71
|
|
|
|
|
|
|
$report->{headers}{'Tapper-SimNow-SVN-Version'} = 'Not set'; |
|
72
|
|
|
|
|
|
|
$report->{headers}{'Tapper-SimNow-SVN-Repository'} = 'Not set'; |
|
73
|
|
|
|
|
|
|
$error = 1; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
push @{$report->{tests}}, {error => $error, test => "Parsing SVN version"}; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$error = 0; |
|
78
|
|
|
|
|
|
|
if ($retval =~ m/supporting version (\d+) of the AMD SimNow Device Interface/) { |
|
79
|
|
|
|
|
|
|
$report->{headers}{'Tapper-SimNow-Device-Interface-Version'} = $1; |
|
80
|
|
|
|
|
|
|
} else { |
|
81
|
|
|
|
|
|
|
$report->{headers}{'Tapper-SimNow-Device-Interface-Version'} = 'Not set'; |
|
82
|
|
|
|
|
|
|
$error = 1; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
push @{$report->{tests}}, {error => $error, test => "Parsing device interface version"}; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
$error = 0; |
|
88
|
|
|
|
|
|
|
if (open my $fh ,"<", $self->cfg->{files}{simnow_script}) { |
|
89
|
|
|
|
|
|
|
my $content = do {local $/; <$fh>}; |
|
90
|
|
|
|
|
|
|
close $fh; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
if ($content =~ m|open bsds/(\w+)\.bsd|) { |
|
93
|
|
|
|
|
|
|
$report->{headers}{'Tapper-SimNow-BSD-File'} = $1; |
|
94
|
|
|
|
|
|
|
} else { |
|
95
|
|
|
|
|
|
|
$error = 1; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
push @{$report->{tests}}, {error => $error, test => "Getting BSD file information"}; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$error = 0; |
|
100
|
|
|
|
|
|
|
if ($content =~ m|ide:0.image master .*/((?:\w\|\.)+?)(?:\.[a-zA-Z]+)?$|m) { |
|
101
|
|
|
|
|
|
|
$report->{headers}{'Tapper-SimNow-Image-File'} = $1; |
|
102
|
|
|
|
|
|
|
} else { |
|
103
|
|
|
|
|
|
|
$error = 1; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
push @{$report->{tests}}, {error => $error, test => "Getting image file information"}; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
$error = 0; |
|
108
|
|
|
|
|
|
|
} else { |
|
109
|
|
|
|
|
|
|
$report->{headers}{'Tapper-SimNow-BSD-File'} = 'Not set'; |
|
110
|
|
|
|
|
|
|
$report->{headers}{'Tapper-SimNow-Image-File'} = 'Not set'; |
|
111
|
|
|
|
|
|
|
$error = 1; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
push @{$report->{tests}}, {error => $error, test => "Reading Simnow config file"}; |
|
114
|
|
|
|
|
|
|
return $report; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub create_console |
|
122
|
|
|
|
|
|
|
{ |
|
123
|
|
|
|
|
|
|
my ($self) = @_; |
|
124
|
|
|
|
|
|
|
$self->log->debug("Creating console links"); |
|
125
|
|
|
|
|
|
|
my $test_run = $self->cfg->{test_run}; |
|
126
|
|
|
|
|
|
|
my $out_dir = $self->cfg->{paths}{output_dir}."/$test_run/test/"; |
|
127
|
|
|
|
|
|
|
$self->makedir($out_dir) unless -d $out_dir; |
|
128
|
|
|
|
|
|
|
my $outfile = $out_dir."/simnow_console"; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# create the file, otherwise simnow can't write to it |
|
131
|
|
|
|
|
|
|
open my $fh, ">", $outfile or return "Can not open $outfile: $!"; |
|
132
|
|
|
|
|
|
|
close $fh; |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
my $pipedir = dirname($self->cfg->{files}{simnow_console}); |
|
135
|
|
|
|
|
|
|
$self->makedir($pipedir) unless -d $pipedir; |
|
136
|
|
|
|
|
|
|
my $retval = $self->log_and_exec("ln","-sf", $outfile, $self->cfg->{files}{simnow_console}); |
|
137
|
|
|
|
|
|
|
return $retval; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub start_simnow |
|
143
|
|
|
|
|
|
|
{ |
|
144
|
|
|
|
|
|
|
my ($self) = @_; |
|
145
|
|
|
|
|
|
|
$self->log->debug("starting simnow"); |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
my $simnow_script = $self->cfg->{files}{simnow_script}; |
|
148
|
|
|
|
|
|
|
my $test_run = $self->cfg->{test_run}; |
|
149
|
|
|
|
|
|
|
my $out_dir = $self->cfg->{paths}{output_dir}."/$test_run/test/"; |
|
150
|
|
|
|
|
|
|
$self->makedir($out_dir) unless -d $out_dir; |
|
151
|
|
|
|
|
|
|
my $output = $out_dir.'/simnow'; |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
open (STDOUT, ">>", "$output.stdout") or return("Can't open output file $output.stdout: $!"); |
|
154
|
|
|
|
|
|
|
open (STDERR, ">>", "$output.stderr") or return("Can't open output file $output.stderr: $!"); |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
my $retval = $self->run_one({command => $self->cfg->{paths}->{simnow_path}."/simnow", |
|
157
|
|
|
|
|
|
|
argv => [ "-e", $simnow_script, '--nogui' ], |
|
158
|
|
|
|
|
|
|
pid_file => $self->cfg->{paths}->{pids_path}."/simnow.pid", |
|
159
|
|
|
|
|
|
|
}); |
|
160
|
|
|
|
|
|
|
return $retval; |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub start_mediator |
|
166
|
|
|
|
|
|
|
{ |
|
167
|
|
|
|
|
|
|
my ($self) = @_; |
|
168
|
|
|
|
|
|
|
$self->log->debug("starting mediator"); |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
my $retval = $self->run_one({command => $self->cfg->{paths}->{simnow_path}."/mediator", |
|
171
|
|
|
|
|
|
|
pid_file => $self->cfg->{paths}->{pids_path}."/mediator.pid", |
|
172
|
|
|
|
|
|
|
}); |
|
173
|
|
|
|
|
|
|
return $retval; |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub run |
|
180
|
|
|
|
|
|
|
{ |
|
181
|
|
|
|
|
|
|
my ($self) = @_; |
|
182
|
|
|
|
|
|
|
$self->log->info("Starting Simnow"); |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
my $consumer = Tapper::Remote::Config->new(); |
|
185
|
|
|
|
|
|
|
my $config = $consumer->get_local_data('simnow'); |
|
186
|
|
|
|
|
|
|
die $config unless ref($config) eq 'HASH'; |
|
187
|
|
|
|
|
|
|
my $net = Tapper::Remote::Net->new($config); |
|
188
|
|
|
|
|
|
|
$self->cfg( $config ); |
|
189
|
|
|
|
|
|
|
$net->mcp_inform("start-test"); |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
# simnow only runs in its own directory due to lib issues |
|
192
|
|
|
|
|
|
|
chdir $self->cfg->{paths}->{simnow_path}; |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
my $retval; |
|
195
|
|
|
|
|
|
|
{ |
|
196
|
|
|
|
|
|
|
$retval = $self->kill_instance($self->cfg->{paths}->{pids_path}."/simnow.pid"); |
|
197
|
|
|
|
|
|
|
last if $retval; |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
$retval = $self->create_console(); |
|
200
|
|
|
|
|
|
|
last if $retval; |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
$retval = $self->start_mediator(); |
|
204
|
|
|
|
|
|
|
last if $retval; |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
$retval = $self->start_simnow(); |
|
207
|
|
|
|
|
|
|
last if $retval; |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
my $report = $self->generate_meta_report(); |
|
210
|
|
|
|
|
|
|
my $tap = $net->tap_report_create($report); |
|
211
|
|
|
|
|
|
|
my $error; |
|
212
|
|
|
|
|
|
|
($error, $retval) = $net->tap_report_away($tap); |
|
213
|
|
|
|
|
|
|
last if $error; |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
if ($retval) { |
|
217
|
|
|
|
|
|
|
$net->mcp_send({state => 'error-guest', error => $retval}); |
|
218
|
|
|
|
|
|
|
$self->log->logdie($retval); |
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
$net->mcp_inform("end-test"); |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
$self->log->info("Simnow prepared and running"); |
|
223
|
|
|
|
|
|
|
return 0; |
|
224
|
|
|
|
|
|
|
} |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
1; # End of Tapper::SimNow |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
__END__ |
|
229
|
|
|
|
|
|
|
=pod |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=encoding utf-8 |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 NAME |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
Tapper::SimNow - Tapper - Support for running SimNow sessions |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
Tapper::SimNow controls running SimNow session with Tapper. With this |
|
240
|
|
|
|
|
|
|
module Tapper is able to treat similar to virtualisation tests. |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
use Tapper::SimNow; |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
my $simnow = Tapper::SimNow->new(); |
|
245
|
|
|
|
|
|
|
$simnow->run(); |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head2 get_static_tap_headers |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
Create a report hash that contains all headers that do not need to be |
|
252
|
|
|
|
|
|
|
produced somehow. This includes suite-name and suite-version for |
|
253
|
|
|
|
|
|
|
example. |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
@return string - tap headers |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head2 generate_meta_report |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
Generate a report containing metainformation about the SimNow we use. |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
@return hash ref - report data as expected by Remote::Net->tap_report_create() |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=head2 create_console |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
Create console file for output of system under test in simnow. |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
@param hash ref - config |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
@return success - 0 |
|
270
|
|
|
|
|
|
|
@return error - error string |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head2 start_simnow |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
Start the simnow process. |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
@param hash ref - config |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
@return success - 0 |
|
279
|
|
|
|
|
|
|
@return error - error string |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=head2 start_mediator |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
Start the mediator process. |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
@param hash ref - config |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
@return success - 0 |
|
288
|
|
|
|
|
|
|
@return error - error string |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=head2 run |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
Control a SimNow session. Handles getting config, sending status |
|
293
|
|
|
|
|
|
|
messages to MCP and console handling. |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
@return success - 0 |
|
296
|
|
|
|
|
|
|
@return error - error string |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=head1 AUTHOR |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
AMD OSRC Tapper Team <tapper@amd64.org> |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
This software is Copyright (c) 2012 by Advanced Micro Devices, Inc.. |
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
This is free software, licensed under: |
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
The (two-clause) FreeBSD License |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=cut |
|
311
|
|
|
|
|
|
|
|