line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tapper::Schema::TestrunDB::Result::Precondition; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TAPPER'; |
3
|
|
|
|
|
|
|
$Tapper::Schema::TestrunDB::Result::Precondition::VERSION = '5.0.9'; |
4
|
|
|
|
|
|
|
# ABSTRACT: Tapper - Containing Preconditions for Testruns |
5
|
|
|
|
|
|
|
|
6
|
7
|
|
|
7
|
|
19353
|
use strict; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
184
|
|
7
|
7
|
|
|
7
|
|
27
|
use warnings; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
169
|
|
8
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
23
|
use parent 'DBIx::Class'; |
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
29
|
|
10
|
7
|
|
|
7
|
|
324
|
use YAML::Syck; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
3969
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->load_components("Core"); |
13
|
|
|
|
|
|
|
__PACKAGE__->table("precondition"); |
14
|
|
|
|
|
|
|
__PACKAGE__->add_columns |
15
|
|
|
|
|
|
|
( |
16
|
|
|
|
|
|
|
"id", { data_type => "INT", default_value => undef, is_nullable => 0, size => 11, is_auto_increment => 1, }, |
17
|
|
|
|
|
|
|
"shortname", { data_type => "VARCHAR", default_value => "", is_nullable => 0, size => 255, }, |
18
|
|
|
|
|
|
|
"precondition", { data_type => "TEXT", default_value => undef, is_nullable => 1, }, |
19
|
|
|
|
|
|
|
"timeout", { data_type => "INT", default_value => undef, is_nullable => 1, size => 10, }, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
__PACKAGE__->set_primary_key("id"); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__PACKAGE__->has_many ( child_pre_precondition => 'Tapper::Schema::TestrunDB::Result::PrePrecondition', { 'foreign.parent_precondition_id' => 'self.id' }); |
25
|
|
|
|
|
|
|
__PACKAGE__->many_to_many ( child_preconditions => 'child_pre_precondition', 'child' ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
__PACKAGE__->has_many ( parent_pre_precondition => 'Tapper::Schema::TestrunDB::Result::PrePrecondition', { 'foreign.child_precondition_id' => 'self.id' }); |
28
|
|
|
|
|
|
|
__PACKAGE__->many_to_many ( parent_preconditions => 'parent_pre_precondition', 'parent' ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__PACKAGE__->has_many ( testrun_precondition => 'Tapper::Schema::TestrunDB::Result::TestrunPrecondition', { 'foreign.precondition_id' => 'self.id' }, { 'join_type' => 'INNER' }); |
31
|
|
|
|
|
|
|
__PACKAGE__->many_to_many ( parent_testruns => 'testrun_precondition', 'testrun' ); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# -------------------- methods in results -------------------- |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub one_line { |
39
|
0
|
|
|
0
|
1
|
0
|
my ($str) = @_; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
0
|
$str =~ s/\\/\\\\/msg; |
42
|
0
|
|
|
|
|
0
|
$str =~ s/\n/\\n/msg; |
43
|
0
|
|
|
|
|
0
|
$str; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub quote { |
48
|
0
|
|
|
0
|
1
|
0
|
my ($str) = @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
my $d = Data::Dumper->new([$str])->Terse(1)->Indent(0); |
51
|
0
|
|
|
|
|
0
|
$d->Dump; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub quote_and_one_line { |
56
|
0
|
|
|
0
|
1
|
0
|
my ($str) = @_; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
0
|
$str = quote($str); |
59
|
0
|
|
|
|
|
0
|
$str =~ s/\n/\\n/msg; |
60
|
0
|
|
|
|
|
0
|
$str; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub to_string |
65
|
|
|
|
|
|
|
{ |
66
|
0
|
|
|
0
|
1
|
0
|
my ($self, $opt) = @_; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
0
|
my $str = ''; |
69
|
0
|
|
|
|
|
0
|
foreach (@{$self->result_source->{_ordered_columns} }) |
|
0
|
|
|
|
|
0
|
|
70
|
|
|
|
|
|
|
{ |
71
|
0
|
|
|
|
|
0
|
my $val = $self->$_; |
72
|
0
|
0
|
|
|
|
0
|
if (defined $val) |
73
|
|
|
|
|
|
|
{ |
74
|
0
|
0
|
0
|
|
|
0
|
if ( $opt->{quotevalues} && $opt->{nonewlines} ) { |
75
|
0
|
|
|
|
|
0
|
$val = quote_and_one_line($val); |
76
|
|
|
|
|
|
|
} else { |
77
|
0
|
0
|
|
|
|
0
|
$val = quote($val) if $opt->{quotevalues}; |
78
|
0
|
0
|
|
|
|
0
|
$val = one_line($val) if $opt->{nonewlines}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} else |
81
|
|
|
|
|
|
|
{ |
82
|
0
|
|
|
|
|
0
|
$val = $Tapper::Schema::TestrunDB::NULL; |
83
|
|
|
|
|
|
|
} |
84
|
0
|
|
|
|
|
0
|
$str .= $val . $Tapper::Schema::TestrunDB::DELIM; |
85
|
|
|
|
|
|
|
} |
86
|
0
|
|
|
|
|
0
|
return $str; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub precondition_as_hash { |
91
|
6
|
|
|
6
|
1
|
441
|
Load(shift->precondition); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub update_content { |
96
|
0
|
|
|
0
|
1
|
|
my ($self, $condition) = @_; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
my $yaml_error = Tapper::Schema::TestrunDB::_yaml_ok($condition); |
99
|
0
|
0
|
|
|
|
|
die Tapper::Exception::Param->new($yaml_error) if $yaml_error; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
my @a_conditions = Load($condition); |
102
|
0
|
0
|
|
|
|
|
if ( scalar @a_conditions > 1 ) { |
103
|
0
|
|
|
|
|
|
say {*STDERR} 'cannot update a single precondition with a set of preconditions'; |
|
0
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
return; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
my $cond_hash = $a_conditions[0]; |
108
|
0
|
0
|
|
|
|
|
$self->shortname( $cond_hash->{shortname} ) if $cond_hash->{shortname}; |
109
|
0
|
|
|
|
|
|
$self->precondition( $condition ); |
110
|
0
|
0
|
|
|
|
|
$self->timeout( $cond_hash->{timeout} ) if $cond_hash->{timeout}; |
111
|
|
|
|
|
|
|
|
112
|
0
|
0
|
|
|
|
|
if ( $self->update ) { |
113
|
0
|
|
|
|
|
|
return $self->id; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
else { |
116
|
0
|
|
|
|
|
|
say {*STDERR} 'update precondition failed: ' . $self->id; |
|
0
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
return; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=pod |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=encoding UTF-8 |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 NAME |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Tapper::Schema::TestrunDB::Result::Precondition - Tapper - Containing Preconditions for Testruns |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 one_line |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Make a string with newlines to one line inserting C<\n>. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 quote |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Quote a string according to Perl eval rules. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 quote_and_one_line |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Combine C<quote> and C<one_line>. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 to_string |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Return printable representation. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 precondition_as_hash |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Provide the precondition YAML as actual data structure. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 update_content |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Update precondition from given params. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 AUTHORS |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=over 4 |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item * |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
AMD OSRC Tapper Team <tapper@amd64.org> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item * |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Tapper Team <tapper-ops@amazon.com> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=back |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
This software is Copyright (c) 2017 by Advanced Micro Devices, Inc.. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
This is free software, licensed under: |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
The (two-clause) FreeBSD License |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=cut |