| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Tapper::Cmd::Precondition; |
|
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TAPPER'; |
|
3
|
|
|
|
|
|
|
$Tapper::Cmd::Precondition::VERSION = '5.0.11'; |
|
4
|
5
|
|
|
5
|
|
5580970
|
use Moose; |
|
|
5
|
|
|
|
|
535338
|
|
|
|
5
|
|
|
|
|
41
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
33613
|
use YAML::Syck; |
|
|
5
|
|
|
|
|
12
|
|
|
|
5
|
|
|
|
|
339
|
|
|
7
|
5
|
|
|
5
|
|
607
|
use Kwalify; |
|
|
5
|
|
|
|
|
3770
|
|
|
|
5
|
|
|
|
|
326
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
37
|
use parent 'Tapper::Cmd'; |
|
|
5
|
|
|
|
|
12
|
|
|
|
5
|
|
|
|
|
39
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub die_on_invalid_precondition |
|
14
|
|
|
|
|
|
|
{ |
|
15
|
12
|
|
|
12
|
1
|
84
|
my ($self, $preconditions, $schema) = @_; |
|
16
|
12
|
50
|
33
|
|
|
96
|
if (not ($schema and ref($schema) eq 'HASH') ) { |
|
17
|
12
|
|
|
|
|
121
|
$schema = |
|
18
|
|
|
|
|
|
|
{ |
|
19
|
|
|
|
|
|
|
type => 'map', |
|
20
|
|
|
|
|
|
|
mapping => |
|
21
|
|
|
|
|
|
|
{ |
|
22
|
|
|
|
|
|
|
precondition_type => |
|
23
|
|
|
|
|
|
|
{ type => 'str', |
|
24
|
|
|
|
|
|
|
required => 1, |
|
25
|
|
|
|
|
|
|
}, |
|
26
|
|
|
|
|
|
|
'=' => |
|
27
|
|
|
|
|
|
|
{ |
|
28
|
|
|
|
|
|
|
type => 'any', |
|
29
|
|
|
|
|
|
|
required => 1, |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
}; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
12
|
50
|
|
|
|
57
|
$preconditions = [ $preconditions] unless ref($preconditions) eq 'ARRAY'; |
|
35
|
|
|
|
|
|
|
precondition: |
|
36
|
12
|
|
|
|
|
44
|
foreach my $precondition (@$preconditions) { |
|
37
|
|
|
|
|
|
|
# undefined preconditions are caused by tapper headers or a "---\n" line at the end |
|
38
|
40
|
100
|
|
|
|
8389
|
next precondition unless defined($precondition); |
|
39
|
39
|
|
|
|
|
184
|
Kwalify::validate($schema, $precondition); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
11
|
|
|
|
|
2449
|
return 0; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub add { |
|
46
|
12
|
|
|
12
|
1
|
31287
|
my ($self, $input, $schema) = @_; |
|
47
|
12
|
100
|
|
|
|
63
|
if (ref $input eq 'ARRAY') { |
|
48
|
10
|
|
|
|
|
49
|
$self->die_on_invalid_precondition($input, $schema); |
|
49
|
10
|
|
|
|
|
362
|
return $self->schema->resultset('Precondition')->add($input); |
|
50
|
|
|
|
|
|
|
} else { |
|
51
|
2
|
50
|
|
|
|
17
|
$input .= "\n" unless $input =~ /\n$/; |
|
52
|
2
|
|
|
|
|
11
|
my @yaml = Load($input); |
|
53
|
2
|
|
|
|
|
168
|
$self->die_on_invalid_precondition(\@yaml, $schema); |
|
54
|
1
|
|
|
|
|
78
|
return $self->schema->resultset('Precondition')->add(\@yaml); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub update { |
|
60
|
0
|
|
|
0
|
1
|
0
|
my ($self, $id, $condition) = @_; |
|
61
|
0
|
|
|
|
|
0
|
my $precondition = $self->schema->resultset('Precondition')->find($id); |
|
62
|
0
|
0
|
|
|
|
0
|
die "Precondition with id $id not found\n" if not $precondition; |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
0
|
return $precondition->update_content($condition); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub del { |
|
70
|
1
|
|
|
1
|
1
|
66270
|
my ($self, $id) = @_; |
|
71
|
1
|
|
|
|
|
35
|
my $precondition = $self->schema->resultset('Precondition')->find($id); |
|
72
|
1
|
50
|
|
|
|
3032
|
return qq(No precondition with id "$id" found) if not $precondition;; |
|
73
|
1
|
|
|
|
|
36
|
$precondition->delete(); |
|
74
|
1
|
|
|
|
|
25188
|
return 0; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; # End of Tapper::Cmd::Testrun |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=pod |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=encoding UTF-8 |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 NAME |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Tapper::Cmd::Precondition |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This project offers backend functions for all projects that manipulate |
|
92
|
|
|
|
|
|
|
testruns or preconditions in the database. This module handles the precondition part. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
use Tapper::Cmd::Testrun; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $bar = Tapper::Cmd::Precondition->new(); |
|
97
|
|
|
|
|
|
|
$bar->add($precondition); |
|
98
|
|
|
|
|
|
|
... |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 NAME |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Tapper::Cmd::Precondition - Backend functions for manipluation of preconditions in the database |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 die_on_invalid_precondition |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Check whether a precondition is valid either based on a given kwalify |
|
109
|
|
|
|
|
|
|
schema or the default schema. Errors are returned by die-ing. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
@param array ref - preconditions |
|
112
|
|
|
|
|
|
|
@param schema (optional) |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
@return success 0 |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
@throws Perl die |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 add |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Add a new precondition. Expects a precondition in YAML format. Multiple |
|
121
|
|
|
|
|
|
|
preconditions may be given as one string. In this case every valid |
|
122
|
|
|
|
|
|
|
precondition (i.e. those with a precondition_type) will be added. This is |
|
123
|
|
|
|
|
|
|
useful for macro preconditions. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
@param string - preconditions in YAML format OR |
|
126
|
|
|
|
|
|
|
@param array ref - preconditions as list of hashes |
|
127
|
|
|
|
|
|
|
@param hash ref - kwalify schema (optional) |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
@return success - list of precondition ids |
|
130
|
|
|
|
|
|
|
@return error - undef |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
@throws Perl die |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 update |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Update a given precondition. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
@param int - precondition id |
|
139
|
|
|
|
|
|
|
@param string - precondition as it should be |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
@return success - precondition id |
|
142
|
|
|
|
|
|
|
@return error - error string |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
@throws die |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 del |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Delete a precondition with given id. Its named del instead of delete to |
|
149
|
|
|
|
|
|
|
prevent confusion with the buildin delete function. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
@param int - precondition id |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
@return success - 0 |
|
154
|
|
|
|
|
|
|
@return error - error string |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 AUTHORS |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=over 4 |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item * |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
AMD OSRC Tapper Team <tapper@amd64.org> |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item * |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Tapper Team <tapper-ops@amazon.com> |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=back |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Advanced Micro Devices, Inc.. |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This is free software, licensed under: |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
The (two-clause) FreeBSD License |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |