-
Notifications
You must be signed in to change notification settings - Fork 269
/
ulp_openposix.pm
155 lines (125 loc) · 4.68 KB
/
ulp_openposix.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# SUSE's openQA tests
#
# Copyright 2022 SUSE LLC
# SPDX-License-Identifier: FSFAP
#
# Summary: Install glibc livepatch and run openposix testsuite
# Maintainer: Martin Doucha <mdoucha@suse.cz>
use strict;
use warnings;
use base 'opensusebasetest';
use testapi;
use utils;
use serial_terminal;
use klp;
use qam;
use LTP::utils;
use OpenQA::Test::RunArgs;
sub parse_incident_repo {
my $incident_id = get_required_var('INCIDENT_ID');
my $repo = get_required_var('INCIDENT_REPO');
my @repos = split(",", $repo);
my @repo_names;
my $packname;
my %ulp_tools = (
libpulp0 => 1,
'libpulp-tools' => 1,
'libpulp-load-default' => 1
);
while ((my ($i, $url)) = (each(@repos))) {
push @repo_names, "ULP_$i";
zypper_ar($url, name => $repo_names[$i]);
}
my $repo_args = join(' ', map({ "-r $_" } @repo_names));
my $packlist = zypper_search("-st package $repo_args");
if (grep { $$_{name} eq 'glibc-livepatches' } @$packlist) {
record_info('Livepatch tests', "Incident $incident_id contains userspace livepatches.");
$packname = 'glibc-livepatches';
}
elsif (grep { exists($ulp_tools{$$_{name}}) } @$packlist) {
record_info('Tools tests', "Incident $incident_id contains livepatching tools.");
my $patches = get_patches($incident_id, $repo);
die "Patch isn't needed" unless $patches;
$packname = 'openposix-livepatches';
$repo_args = '';
# Install the libpulp/tools update before running tests
zypper_call("in -l -t patch $patches", exitcode => [0, 102, 103],
log => 'zypper.log', timeout => 1400);
}
else {
# Incident has no userspace livepatch related packages, nothing to do
record_info('Exit', "Incident $incident_id contains no userspace livepatching related packages. Nothing to test.");
return undef;
}
return {packname => $packname, repo_args => $repo_args};
}
sub setup_ulp {
my $packname = 'openposix-livepatches';
my $repo_args = '';
install_klp_product;
zypper_call('in libpulp0 libpulp-tools libpulp-load-default');
if (get_var('INCIDENT_REPO')) {
my $repo_data = parse_incident_repo();
return undef unless $repo_data;
$packname = $repo_data->{packname};
$repo_args = $repo_data->{repo_args};
} else {
record_info('Tools tests', "No incident provided, testing lastest livepatching tools.");
}
# Find glibc versions targeted by livepatch package
my $provides = script_output("zypper -n info --provides $repo_args $packname");
my @versions = $provides =~ m/^\s*libc_([^_()]+)_livepatch\d+\.so\(\)\([^)]+\)\s*$/gm;
die "Package $packname contains no libc livepatches"
unless scalar @versions;
# Find which targeted glibc versions can be installed. Livepatch RPMs
# get released for multiple SLE service packs and some old targeted glibc
# versions may be unavailable on the newer service packs.
my %glibc_map;
my $glibc_versions = zypper_search('-s -x -t package glibc');
$glibc_map{$$_{version}} = 1 for (@$glibc_versions);
@versions = grep { defined($glibc_map{$_}) } @versions;
die "No livepatchable glibc versions found" unless scalar @versions;
prepare_ltp_env;
return OpenQA::Test::RunArgs->new(run_id => 0,
glibc_versions => \@versions, packname => $packname);
}
sub run {
my ($self, $tinfo) = @_;
select_serial_terminal;
if (!defined($tinfo)) {
# First test round in the job, prepare environment
$tinfo = setup_ulp();
# Incident has no userspace livepatch related packages, nothing to do
return if not $tinfo;
} else {
zypper_call("rm " . $tinfo->{packname});
}
# Schedule openposix tests and install the livepatch
my $libver = $tinfo->{glibc_versions}[$tinfo->{run_id}];
record_info('glibc version', $libver);
zypper_call("in --oldpackage glibc-$libver");
schedule_tests('openposix', "_glibc-$libver");
loadtest_kernel('ulp_threads', name => "ulp_threads_glibc-$libver",
run_args => $tinfo);
zypper_call("in " . $tinfo->{packname});
# Run tests again with the next untested glibc version
if ($tinfo->{run_id} < $#{$tinfo->{glibc_versions}}) {
my $runargs = OpenQA::Test::RunArgs->new(run_id => $tinfo->{run_id} + 1,
glibc_versions => $tinfo->{glibc_versions},
packname => $tinfo->{packname});
loadtest_kernel('ulp_openposix', run_args => $runargs);
}
else {
shutdown_ltp;
}
}
sub test_flags {
return {
fatal => 1,
milestone => 1,
};
}
=head1 Configuration
This test module is activated by LIBC_LIVEPATCH=1
=cut
1;