line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tapper::Test; |
2
|
|
|
|
|
|
|
# git description: v4.1.1-1-g2583c93 |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
BEGIN { |
5
|
2
|
|
|
2
|
|
95339
|
$Tapper::Test::AUTHORITY = 'cpan:TAPPER'; |
6
|
|
|
|
|
|
|
} |
7
|
|
|
|
|
|
|
{ |
8
|
|
|
|
|
|
|
$Tapper::Test::VERSION = '4.1.2'; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
# ABSTRACT: Tapper - Utilities for Perl based Tapper testing |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
21
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
67
|
|
13
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
85
|
|
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
55
|
use 5.010; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
86
|
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
10
|
use Test::More; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
28
|
|
18
|
2
|
|
|
2
|
|
2626
|
use Sys::Info; |
|
2
|
|
|
|
|
122789
|
|
|
2
|
|
|
|
|
14
|
|
19
|
2
|
|
|
2
|
|
2382
|
use Format::Human::Bytes; |
|
2
|
|
|
|
|
2649
|
|
|
2
|
|
|
|
|
74
|
|
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
2
|
|
2855
|
use parent 'Exporter'; |
|
2
|
|
|
|
|
8437
|
|
|
2
|
|
|
|
|
15
|
|
22
|
|
|
|
|
|
|
our @EXPORT = qw/tapper_suite_meta tapper_section_meta/; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _uname { |
25
|
0
|
|
|
0
|
|
0
|
my $os = Sys::Info->new->os; |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
0
|
my $osbase = |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$os->is_win ? "Windows" : |
29
|
|
|
|
|
|
|
$os->is_linux ? "Linux" : |
30
|
|
|
|
|
|
|
$os->is_bsd ? "BSD" : |
31
|
|
|
|
|
|
|
"UnknownOS"; |
32
|
0
|
|
|
|
|
0
|
my $uname = join (" ", |
33
|
|
|
|
|
|
|
$osbase, |
34
|
|
|
|
|
|
|
$os->node_name, |
35
|
|
|
|
|
|
|
$os->name(long => 1, edition => 1), |
36
|
|
|
|
|
|
|
~~localtime($os->build), |
37
|
|
|
|
|
|
|
); |
38
|
0
|
|
|
|
|
0
|
$uname .= " [Sys::Info]"; |
39
|
0
|
|
|
|
|
0
|
return $uname; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _hostname { |
43
|
0
|
|
|
0
|
|
0
|
my $hostname = Sys::Info->new->os->node_name; |
44
|
0
|
|
|
|
|
0
|
return $hostname; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _osname { |
48
|
0
|
|
|
0
|
|
0
|
my $os = Sys::Info->new->os; |
49
|
0
|
|
|
|
|
0
|
my $osname = join (" ", |
50
|
|
|
|
|
|
|
$os->name(edition => 1), |
51
|
|
|
|
|
|
|
$os->version, |
52
|
|
|
|
|
|
|
); |
53
|
0
|
|
|
|
|
0
|
return $osname; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _cpuinfo { |
57
|
0
|
|
|
0
|
|
0
|
return Sys::Info->new->device('CPU')->identify; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _ram { |
61
|
0
|
|
|
0
|
|
0
|
my %osmeta = Sys::Info->new->os->meta; |
62
|
0
|
|
|
|
|
0
|
my $ram = Format::Human::Bytes::base2($osmeta{physical_memory_total}*1024); |
63
|
0
|
|
|
|
|
0
|
return $ram; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _starttime_test_program { |
67
|
2
|
|
|
2
|
|
2935
|
use POSIX qw(strftime setlocale); |
|
2
|
|
|
|
|
17889
|
|
|
2
|
|
|
|
|
16
|
|
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
0
|
|
0
|
my $old_loc = setlocale( &POSIX::LC_ALL ); |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
0
|
setlocale( &POSIX::LC_ALL, "C" ); |
72
|
0
|
|
|
|
|
0
|
my $starttime_test_program = strftime("%a, %d %b %Y %H:%M:%S %z", gmtime(time())); |
73
|
0
|
|
|
|
|
0
|
setlocale( &POSIX::LC_ALL, $old_loc ); |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
0
|
return $starttime_test_program; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _suite_name |
79
|
|
|
|
|
|
|
{ |
80
|
1
|
|
|
1
|
|
1264
|
my $build_paramfile = '_build/build_params'; |
81
|
1
|
|
|
|
|
3
|
my $makefile = 'Makefile'; |
82
|
1
|
|
|
|
|
2
|
my $distini = 'dist.ini'; |
83
|
|
|
|
|
|
|
|
84
|
1
|
50
|
|
|
|
43
|
if (-e $build_paramfile ) |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
85
|
|
|
|
|
|
|
{ |
86
|
0
|
|
|
|
|
0
|
my $params = do $build_paramfile; |
87
|
0
|
|
|
|
|
0
|
my $suite_name = $params->[2]->{dist_name}; |
88
|
0
|
|
|
|
|
0
|
return $suite_name; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
elsif (-e $makefile) |
91
|
|
|
|
|
|
|
{ |
92
|
1
|
|
|
|
|
2
|
my $infile = $makefile; |
93
|
1
|
50
|
|
|
|
47
|
open my $F, "<", $infile or die "Cannot open $infile"; |
94
|
1
|
|
|
|
|
1841
|
my ($suite_name) = grep { /^DISTNAME *=/ } <$F>; |
|
889
|
|
|
|
|
1101
|
|
95
|
1
|
|
|
|
|
59
|
$suite_name =~ s/^.*=\s*//; |
96
|
1
|
|
|
|
|
4
|
chomp $suite_name; |
97
|
1
|
|
|
|
|
22
|
return $suite_name; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
elsif (-e $distini) |
100
|
|
|
|
|
|
|
{ |
101
|
0
|
|
|
|
|
|
my $infile = $distini; |
102
|
0
|
0
|
|
|
|
|
open my $F, "<", $infile or die "Cannot open $infile"; |
103
|
0
|
|
|
|
|
|
my ($suite_name) = grep { /^name *=/ } <$F>; |
|
0
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
$suite_name =~ s/^.*=\s*//; |
105
|
0
|
|
|
|
|
|
chomp $suite_name; |
106
|
0
|
|
|
|
|
|
return $suite_name; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
else |
109
|
|
|
|
|
|
|
{ |
110
|
0
|
|
|
|
|
|
warn "Cannot access $build_paramfile or $makefile.\nPlease run perl Build.PL or perl Makefile.PL.\n"; |
111
|
0
|
|
|
|
|
|
return undef; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub _suite_version |
116
|
|
|
|
|
|
|
{ |
117
|
0
|
|
|
0
|
|
|
my $build_paramfile = '_build/build_params'; |
118
|
0
|
|
|
|
|
|
my $makefile = 'Makefile'; |
119
|
0
|
|
|
|
|
|
my $distini = 'dist.ini'; |
120
|
|
|
|
|
|
|
|
121
|
0
|
0
|
|
|
|
|
if (-e $build_paramfile ) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
122
|
|
|
|
|
|
|
{ |
123
|
0
|
|
|
|
|
|
my $params = do $build_paramfile; |
124
|
0
|
|
|
|
|
|
my $suite_version; |
125
|
0
|
0
|
|
|
|
|
if (not ref $params->[2]->{dist_version}) { |
126
|
0
|
|
|
|
|
|
$suite_version = $params->[2]->{dist_version}; |
127
|
|
|
|
|
|
|
} else { |
128
|
0
|
|
|
|
|
|
$suite_version = $params->[2]->{dist_version}->{original}; |
129
|
|
|
|
|
|
|
} |
130
|
0
|
|
|
|
|
|
return $suite_version; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
elsif (-e $makefile) |
133
|
|
|
|
|
|
|
{ |
134
|
0
|
|
|
|
|
|
my $infile = $makefile; |
135
|
0
|
0
|
|
|
|
|
open my $F, "<", $infile or die "Cannot open $infile"; |
136
|
0
|
|
|
|
|
|
my ($suite_version) = grep { /^VERSION *=/ } <$F>; |
|
0
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
$suite_version =~ s/^.*=\s*//; |
138
|
0
|
|
|
|
|
|
chomp $suite_version; |
139
|
0
|
|
|
|
|
|
return $suite_version; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
elsif (-e $distini) |
142
|
|
|
|
|
|
|
{ |
143
|
0
|
|
|
|
|
|
return undef; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
else |
146
|
|
|
|
|
|
|
{ |
147
|
0
|
|
|
|
|
|
warn "Cannot access $build_paramfile or $makefile.\nPlease run perl Build.PL or perl Makefile.PL\n"; |
148
|
0
|
|
|
|
|
|
return undef; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub _suite_type |
153
|
|
|
|
|
|
|
{ |
154
|
0
|
|
|
0
|
|
|
'software'; # 'hardware', 'benchmark', 'os', 'unknown' |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub _language_description { |
158
|
0
|
|
|
0
|
|
|
return "Perl $], $^X"; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
0
|
|
|
0
|
|
|
sub _reportgroup_arbitrary { $ENV{TAPPER_REPORT_GROUP} } |
162
|
0
|
|
|
0
|
|
|
sub _reportgroup_testrun { $ENV{TAPPER_TESTRUN} } |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub tapper_suite_meta |
166
|
|
|
|
|
|
|
{ |
167
|
0
|
|
|
0
|
1
|
|
my %opts = @_; |
168
|
|
|
|
|
|
|
|
169
|
0
|
0
|
|
|
|
|
plan tests => 1 unless $opts{-suppress_plan}; |
170
|
0
|
|
|
|
|
|
pass("tapper-suite-meta"); |
171
|
|
|
|
|
|
|
|
172
|
0
|
|
0
|
|
|
|
my $suite_name = $opts{suite_name} // _suite_name(); |
173
|
0
|
|
0
|
|
|
|
my $suite_version = $opts{suite_version} // _suite_version(); |
174
|
0
|
|
0
|
|
|
|
my $suite_type = $opts{suite_type} // _suite_type(); |
175
|
0
|
|
0
|
|
|
|
my $hostname = $opts{hostname} // _hostname(); |
176
|
0
|
|
0
|
|
|
|
my $reportgroup_arbitrary = $opts{reportgroup_arbitrary} // _reportgroup_arbitrary(); |
177
|
0
|
|
0
|
|
|
|
my $reportgroup_testrun = $opts{reportgroup_testrun} // _reportgroup_testrun(); |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# to be used by TestSuite::* and Tapper::* modules |
180
|
|
|
|
|
|
|
|
181
|
0
|
0
|
|
|
|
|
print "# Tapper-reportgroup-arbitrary: $reportgroup_arbitrary\n" if $reportgroup_arbitrary; |
182
|
0
|
0
|
|
|
|
|
print "# Tapper-reportgroup-testrun: $reportgroup_testrun\n" if $reportgroup_testrun; |
183
|
0
|
|
|
|
|
|
print "# Tapper-suite-name: $suite_name\n"; |
184
|
0
|
|
|
|
|
|
print "# Tapper-suite-version: $suite_version\n"; |
185
|
0
|
|
|
|
|
|
print "# Tapper-suite-type: $suite_type\n"; |
186
|
0
|
|
|
|
|
|
print "# Tapper-machine-name: $hostname\n"; |
187
|
|
|
|
|
|
|
|
188
|
0
|
|
|
|
|
|
tapper_section_meta(@_); |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub tapper_section_meta |
193
|
|
|
|
|
|
|
{ |
194
|
0
|
|
|
0
|
1
|
|
my %opts = @_; |
195
|
|
|
|
|
|
|
|
196
|
0
|
|
0
|
|
|
|
my $uname = $opts{uname} // _uname(); |
197
|
0
|
|
0
|
|
|
|
my $osname = $opts{osname} // _osname(); |
198
|
0
|
|
0
|
|
|
|
my $cpuinfo = $opts{cpuinfo} // _cpuinfo(); |
199
|
0
|
|
0
|
|
|
|
my $ram = $opts{ram} // _ram(); |
200
|
0
|
|
0
|
|
|
|
my $starttime_test_program = $opts{starttime_test_program} // _starttime_test_program(); |
201
|
0
|
|
0
|
|
|
|
my $language_description = $opts{language_description} // _language_description(); |
202
|
0
|
|
|
|
|
|
my $section = $opts{section}; |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# to be used by TestSuite::* and Tapper::* modules |
205
|
|
|
|
|
|
|
|
206
|
0
|
|
|
|
|
|
print "# Tapper-language-description: $language_description\n"; |
207
|
0
|
|
|
|
|
|
print "# Tapper-uname: $uname\n"; |
208
|
0
|
|
|
|
|
|
print "# Tapper-osname: $osname\n"; |
209
|
0
|
|
|
|
|
|
print "# Tapper-cpuinfo: $cpuinfo\n"; |
210
|
0
|
|
|
|
|
|
print "# Tapper-ram: $ram\n"; |
211
|
0
|
|
|
|
|
|
print "# Tapper-starttime-test-program: $starttime_test_program\n"; |
212
|
0
|
0
|
|
|
|
|
print "# Tapper-section: $section\n" if $section; |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
1; # End of Tapper::Test |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
__END__ |