line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PITA::Guest::Driver::Local; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
PITA::Guest::Driver::Local - PITA Guest Driver for Local images |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
The author is an idiot |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
3293
|
use 5.006; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
68
|
|
16
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
17
|
1
|
|
|
1
|
|
1325
|
use version (); |
|
1
|
|
|
|
|
3715
|
|
|
1
|
|
|
|
|
29
|
|
18
|
1
|
|
|
1
|
|
7
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
19
|
1
|
|
|
1
|
|
5
|
use File::Spec (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
20
|
1
|
|
|
1
|
|
984
|
use File::Copy (); |
|
1
|
|
|
|
|
2184
|
|
|
1
|
|
|
|
|
18
|
|
21
|
1
|
|
|
1
|
|
4
|
use File::Temp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
22
|
1
|
|
|
1
|
|
2573
|
use File::Which (); |
|
1
|
|
|
|
|
1287
|
|
|
1
|
|
|
|
|
32
|
|
23
|
1
|
|
|
1
|
|
11113
|
use Data::GUID (); |
|
1
|
|
|
|
|
27605
|
|
|
1
|
|
|
|
|
42
|
|
24
|
1
|
|
|
1
|
|
4418
|
use Storable (); |
|
1
|
|
|
|
|
4119
|
|
|
1
|
|
|
|
|
29
|
|
25
|
1
|
|
|
1
|
|
9
|
use Params::Util (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
26
|
1
|
|
|
1
|
|
481
|
use PITA::XML (); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use PITA::Scheme (); |
28
|
|
|
|
|
|
|
use PITA::Guest::Driver (); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = '0.60'; |
31
|
|
|
|
|
|
|
our @ISA = 'PITA::Guest::Driver'; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# SHOULD be tested, but recheck on load |
34
|
|
|
|
|
|
|
my $workarea = File::Spec->tmpdir; |
35
|
|
|
|
|
|
|
unless ( -d $workarea and -r _ and -w _ ) { |
36
|
|
|
|
|
|
|
Carp::croak('Workarea does no exist or insufficient permissions'); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
##################################################################### |
44
|
|
|
|
|
|
|
# Constructor and Accessors |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub new { |
47
|
|
|
|
|
|
|
my $class = shift; |
48
|
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Get ourselves a fresh tmp directory for the scheme workarea |
51
|
|
|
|
|
|
|
unless ( $self->workarea ) { |
52
|
|
|
|
|
|
|
$self->{workarea} = File::Temp::tempdir(); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
unless ( -d $self->workarea and -w _ ) { |
55
|
|
|
|
|
|
|
die("Working directory " . $self->workarea . " is not writable"); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
### Not used, for now |
59
|
|
|
|
|
|
|
# Locate the perl binary |
60
|
|
|
|
|
|
|
$self->{local_bin} = File::Which::which('perl') unless $self->local_bin; |
61
|
|
|
|
|
|
|
unless ( $self->local_bin ) { |
62
|
|
|
|
|
|
|
Carp::croak("Cannot locate perl, requires explicit param"); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
unless ( -x $self->local_bin ) { |
65
|
|
|
|
|
|
|
Carp::croak("Insufficient permissions to run perl"); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Find the install perl version |
69
|
|
|
|
|
|
|
my $local_bin = $self->local_bin; |
70
|
|
|
|
|
|
|
my $lines = `$local_bin -v`; |
71
|
|
|
|
|
|
|
unless ( $lines =~ /^This is perl[^\n]+v([\d\.]+)[^\n]+built for/m ) { |
72
|
|
|
|
|
|
|
Carp::croak("Failed to locate Perl version"); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
$self->{local_version} = version->new("$1"); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Check the local version |
77
|
|
|
|
|
|
|
unless ( $self->local_version >= version->new('5.6.1') ) { |
78
|
|
|
|
|
|
|
Carp::croak("Currently only supports perl 5.6.1 or newer"); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$self; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Scheme workarea |
85
|
|
|
|
|
|
|
sub workarea { |
86
|
|
|
|
|
|
|
$_[0]->{workarea}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub local_bin { |
90
|
|
|
|
|
|
|
$_[0]->{local_bin}; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub local_version { |
94
|
|
|
|
|
|
|
$_[0]->{local_version}; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
##################################################################### |
102
|
|
|
|
|
|
|
# PITA::Guest::Driver Main Methods |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# We are running now, of course we are here |
105
|
|
|
|
|
|
|
sub ping { |
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# Only implements the current Perl |
110
|
|
|
|
|
|
|
sub discover { |
111
|
|
|
|
|
|
|
my $self = shift; |
112
|
|
|
|
|
|
|
$self->guest->discovered and return 1; |
113
|
|
|
|
|
|
|
$self->guest->add_platform( |
114
|
|
|
|
|
|
|
PITA::XML::Platform->autodetect_perl5, |
115
|
|
|
|
|
|
|
); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# Execute a test |
119
|
|
|
|
|
|
|
sub test { |
120
|
|
|
|
|
|
|
my $self = shift; |
121
|
|
|
|
|
|
|
my $request = $self->_REQUEST(shift) |
122
|
|
|
|
|
|
|
or Carp::croak('Did not provide a request'); |
123
|
|
|
|
|
|
|
my $platform = Params::Util::_INSTANCE(shift, 'PITA::XML::Platform') |
124
|
|
|
|
|
|
|
or Carp::croak('Did not provide a platform'); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# Set the tarball filename to be relative to current |
127
|
|
|
|
|
|
|
my $file = $request->file; |
128
|
|
|
|
|
|
|
my $filename = File::Basename::basename( $file->filename ); |
129
|
|
|
|
|
|
|
my $tarball_from = $file->filename; |
130
|
|
|
|
|
|
|
my $tarball_to = File::Spec->catfile( |
131
|
|
|
|
|
|
|
$self->injector_dir, $filename, |
132
|
|
|
|
|
|
|
); |
133
|
|
|
|
|
|
|
$request = Storable::dclone( $request ); |
134
|
|
|
|
|
|
|
$request->file->{filename} = $filename; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# Copy the tarball into the injector |
137
|
|
|
|
|
|
|
unless ( File::Copy::copy( $tarball_from, $tarball_to ) ) { |
138
|
|
|
|
|
|
|
Carp::croak("Failed to copy in test package: $!"); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# Create the testing scheme |
142
|
|
|
|
|
|
|
my $driver = PITA::Scheme->_DRIVER($request->scheme); |
143
|
|
|
|
|
|
|
my $scheme = $driver->new( |
144
|
|
|
|
|
|
|
injector => $self->injector_dir, |
145
|
|
|
|
|
|
|
workarea => $self->workarea, |
146
|
|
|
|
|
|
|
scheme => $request->scheme, |
147
|
|
|
|
|
|
|
path => $platform->path, |
148
|
|
|
|
|
|
|
request => $request, |
149
|
|
|
|
|
|
|
request_id => 1234, |
150
|
|
|
|
|
|
|
); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# Execute the testing scheme |
153
|
|
|
|
|
|
|
$scheme->prepare_all; |
154
|
|
|
|
|
|
|
$scheme->execute_all; |
155
|
|
|
|
|
|
|
unless ( $scheme->report ) { |
156
|
|
|
|
|
|
|
Carp::croak('Executing test scheme failed to generate a report'); |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
$scheme->report; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
##################################################################### |
167
|
|
|
|
|
|
|
# Support Methods |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub DESTROY { |
170
|
|
|
|
|
|
|
$_[0]->SUPER::DESTROY(); |
171
|
|
|
|
|
|
|
if ( $_[0]->{workarea} and -d $_[0]->{workarea} ) { |
172
|
|
|
|
|
|
|
File::Remove::remove( \1, $_[0]->{workarea} ); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
1; |