line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Integrator::Test::ConfigData; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
125078
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
141
|
|
4
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
94
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
18
|
use base 'Exporter'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
335
|
|
7
|
3
|
|
|
3
|
|
15
|
use vars qw($VERSION); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
371
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Integrator::Test::ConfigData - Configuration information transfered in the TAP output |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$Revision: 1.11 $ |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$VERSION = sprintf "%d.%03d", q$Revision: 1.11 $ =~ /(\d+)/g; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
This module provides test functions to automate measurement and state |
24
|
|
|
|
|
|
|
information gathering from a test script to the TAP output with the |
25
|
|
|
|
|
|
|
intent of loading the information in the Integrator tool from Cydone |
26
|
|
|
|
|
|
|
Solutions. These functions are mostly wrappers around ok functions. |
27
|
|
|
|
|
|
|
See Test::Simple on www.cpan.org as a reference. If you need more |
28
|
|
|
|
|
|
|
information for the TAP format see Test::TAP::Model on www.cpan.org. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Each of these functions is considered a single test statement and must |
31
|
|
|
|
|
|
|
be counted in your test plan. This module is a sub-class of Test::Builder. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#... your typical test.t file ... |
34
|
|
|
|
|
|
|
#!/usr/bin/perl |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use Test::More tests => 3; #you declare your tests as usual |
37
|
|
|
|
|
|
|
use Integrator::Test::ConfigData; #you add this to have access this module's functions |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# a test to produce a measurement in the TAP output. |
40
|
|
|
|
|
|
|
my $fan_speed = function_that_returns_some_fan_speed(); |
41
|
|
|
|
|
|
|
measure( 'fan speed on FAN1', 'FAN_TACH1', $fan_speed, 'RPM', 0.1, 'TACH_123' ); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# a test to declare a component state in the TAP output. |
44
|
|
|
|
|
|
|
component( 'locking a blade in place', 'CPU_BLADE', 'SN0010023', 'HANDLE', 'LOCKED' ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# a test to store a config file in the TAP output. |
47
|
|
|
|
|
|
|
config_file( 'last night temperature log', '/var/log/heat.log.00'); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# a test to store config data in the TAP output. |
50
|
|
|
|
|
|
|
my $string = 'SERIAL_NUMER=1234;18Sept1970'; |
51
|
|
|
|
|
|
|
config_data( 'last night temperature log', 'serial_number_and_date', $string); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 EXPORT |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=over 4 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item measure |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item component |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item config_data |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=back |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
our @EXPORT = qw( measure component config_string config_data config_file); |
68
|
|
|
|
|
|
|
|
69
|
3
|
|
|
3
|
|
6588
|
use MIME::Base64; |
|
3
|
|
|
|
|
2731
|
|
|
3
|
|
|
|
|
246
|
|
70
|
3
|
|
|
3
|
|
21
|
use Test::Builder; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
1953
|
|
71
|
|
|
|
|
|
|
my $Test = Test::Builder->new(); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 FUNCTIONS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 measure |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This function is used to generate integrator_measurement tags in the TAP |
78
|
|
|
|
|
|
|
output. In turn, this data will be interpreted by Cydone Integrator as |
79
|
|
|
|
|
|
|
a measurement. The arguments to the function are: |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
measurement ( COMMENT, MEASURMENT_NAME, VALUE, UNIT, TOLERANCE, EQUIPMENT ); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Where COMMENT, MEASURMENT_NAME and VALUE are required. Fields are evaluated as |
84
|
|
|
|
|
|
|
SCALARs. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
If fields are empty, the corresponding values in the test results will |
87
|
|
|
|
|
|
|
be blank, which is valid but not a good practice since the measurement |
88
|
|
|
|
|
|
|
is not traceable. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub measure ($$$;$$$) { |
93
|
4
|
|
|
4
|
1
|
1974
|
my @params = @_; |
94
|
4
|
|
|
|
|
10
|
foreach my $param (@params) { |
95
|
22
|
|
|
|
|
40
|
$param =~ s/:/_COLON_/g; |
96
|
22
|
|
|
|
|
34
|
$param =~ s/;/_SEMICOLON_/g; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
4
|
|
|
|
|
13
|
my ($cmt, @values) = @params; |
100
|
4
|
|
|
|
|
13
|
my $value_string = join(';',@values); |
101
|
|
|
|
|
|
|
|
102
|
4
|
|
|
|
|
26
|
return $Test->ok(1==1, "$cmt integrator_measurement:$value_string"); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 component |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This function is used to generate integrator_component tags in the TAP |
108
|
|
|
|
|
|
|
output. In turn, this data will be interpreted by Cydone Integrator as |
109
|
|
|
|
|
|
|
a component and state declaration. The arguments to the function are: |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
component ( COMMENT, COMPONENT_NAME, COMPONENT_SERIAL_NUMBER,STATE_NAME, STATE_VALUE ); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Where COMMENT and COMPONENT_NAME are required. Fields are evaluated as SCALARs |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
If fields are empty, the corresponding values in the test results will |
116
|
|
|
|
|
|
|
be blank, which is valid but not a good practice since the declaration |
117
|
|
|
|
|
|
|
is not complete. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub component ($$;$$$) { |
122
|
5
|
|
|
5
|
1
|
1966
|
my @params = @_; |
123
|
5
|
|
|
|
|
9
|
foreach my $param (@params) { |
124
|
25
|
|
|
|
|
29
|
$param =~ s/:/_COLON_/g; |
125
|
25
|
|
|
|
|
34
|
$param =~ s/;/_SEMICOLON_/g; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
5
|
|
|
|
|
11
|
my ($cmt, @values) = @params; |
129
|
5
|
|
|
|
|
11
|
my $value_string = join(';',@values); |
130
|
|
|
|
|
|
|
|
131
|
5
|
|
|
|
|
20
|
return $Test->ok(1==1, "$cmt integrator_component:$value_string"); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 config_data |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This function is used to attach text data from a string in the TAP |
137
|
|
|
|
|
|
|
output. The string will be encoded and the data will be interpreted by |
138
|
|
|
|
|
|
|
Cydone Integrator as a log file with a name coresponding to the NAME |
139
|
|
|
|
|
|
|
parameter for the current test case. The arguments to the function are: |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
config_data ( COMMENT, NAME, STRING ); |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Notes: No string size limit is specified in this version. Use with care... |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub config_data { |
148
|
1
|
|
|
1
|
1
|
485
|
my $cmt = shift; |
149
|
1
|
|
|
|
|
3
|
my $name = shift; |
150
|
1
|
|
|
|
|
3
|
my $string = shift; |
151
|
|
|
|
|
|
|
|
152
|
1
|
|
50
|
|
|
8
|
$string ||= ""; |
153
|
1
|
|
|
|
|
3
|
my $size = length($string); |
154
|
1
|
|
|
|
|
16
|
my $encoded_string = encode_base64($string); |
155
|
|
|
|
|
|
|
|
156
|
1
|
|
|
|
|
13
|
$Test->ok(1==1, "Loaded data: $cmt\n" |
157
|
|
|
|
|
|
|
."integrator_config_data:$name;$size;\n" |
158
|
|
|
|
|
|
|
."$encoded_string integrator_config_data_end:$name;" ); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 config_file |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This function is used to attach a file in the TAP output. The file will be |
164
|
|
|
|
|
|
|
encoded and the data will be interpreted by Cydone Integrator as a log file |
165
|
|
|
|
|
|
|
for the current test case. The arguments to the function are: |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
config_file ( COMMENT, FILE_NAME ); |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Notes: No file size limit is specified in this version. Use with care... |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Other Note: If you must specify a file in a different directory, beware |
172
|
|
|
|
|
|
|
that your test might not be portable because different path specifier |
173
|
|
|
|
|
|
|
conventions (forward slashes versus backslashes). |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub config_file { |
178
|
0
|
|
|
0
|
1
|
|
my $cmt = shift; |
179
|
0
|
|
|
|
|
|
my $file = shift; |
180
|
|
|
|
|
|
|
|
181
|
0
|
0
|
|
|
|
|
if (-r $file) { |
182
|
0
|
0
|
|
|
|
|
open FCONF, "<$file" or die "Error: unable to load config file $file, $?"; |
183
|
0
|
|
|
|
|
|
my $size = (stat FCONF)[7]; |
184
|
0
|
|
|
|
|
|
my $encoded_file = encode_base64(join '', ()); |
185
|
0
|
0
|
|
|
|
|
close FCONF or die "Error: unable to close config file $file, $?"; |
186
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
$Test->ok(1==1, "Loaded file $file: $cmt\n" |
188
|
|
|
|
|
|
|
."integrator_config_data:$file;$size;\n" |
189
|
|
|
|
|
|
|
."$encoded_file integrator_config_data_end:$file;" ); |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
else { |
192
|
0
|
|
|
|
|
|
$Test->ok(2==1, "Could not read config_data in file $file"); |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 AUTHOR |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Cydone Solutions Inc, C<< >> |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 BUGS |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
203
|
|
|
|
|
|
|
C, or through the web interface at |
204
|
|
|
|
|
|
|
L. |
205
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
206
|
|
|
|
|
|
|
your bug as I make changes. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 SUPPORT |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
perldoc Integrator::Test::ConfigData |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
You can also look for information at: |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=over 4 |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
L |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=item * CPAN Ratings |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
L |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
L |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=item * Search CPAN |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
L |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=back |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Copyright 2007 Cydone Solutions Inc, all rights reserved. |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
243
|
|
|
|
|
|
|
under the same terms as Perl itself. |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=cut |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
1; # End of Integrator::Test::ConfigData |