Skip to content

Commit 57b1175

Browse files
committed
Merge branch 'master' into deploy
2 parents 18197b8 + cc9ae22 commit 57b1175

10 files changed

+209
-2
lines changed

README.md

+56
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,59 @@ More than one selftest can be run by passing multiple arguments to
228228

229229
From there the bisection can either be run by hand, or fully automated by
230230
creating a script to build the kernel and run the qemu test.
231+
232+
Using the powerpc debian image
233+
------------------------------
234+
235+
The debian powerpc image in `root-disks` can be used to test big endian kernels.
236+
It also exercises COMPAT, which is not tested on ppc64le these days.
237+
238+
The kernel needs virtio drivers as well as 9PFS built-in. For example to get it
239+
booting with `g5_defconfig`:
240+
241+
```
242+
$ cd linux
243+
$ ~/ci-scripts/scripts/misc/apply-configs.py 9p guest_configs cgroups-y
244+
$ make g5_defconfig vmlinux
245+
$ ~/ci-scripts/boot/qemu-g5+debian
246+
```
247+
248+
To do interactive testing, run the boot script with `--interactive`, the login
249+
is `root/linuxppc`.
250+
251+
Once logged in, to install packages a few steps are needed.
252+
253+
If the network doesn't come up by default:
254+
```
255+
dhclient $(basename $(ls -1d /sys/class/net/en*))
256+
```
257+
258+
If you need to use a http proxy:
259+
```
260+
echo 'Acquire::http::Proxy "http://proxy.org:3128";' > /etc/apt/apt.conf.d/00proxy
261+
```
262+
263+
Tell apt to update package lists while ignoring missing GPG keys:
264+
```
265+
apt -o Acquire::AllowInsecureRepositories=true -o Acquire::AllowDowngradeToInsecureRepositories=true update
266+
```
267+
268+
At that point you should be able to install the updated keyring:
269+
```
270+
apt install -y --allow-unauthenticated debian-ports-archive-keyring
271+
```
272+
273+
And update package lists again:
274+
```
275+
apt update
276+
```
277+
278+
Then you should be able to install packages, eg:
279+
```
280+
apt install gcc
281+
```
282+
283+
If you still can't install packages due to GPG errors, you can disable package authentication with:
284+
```
285+
echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf.d/00allow-unauth
286+
```

build/scripts/container-build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ else
179179
# Workaround 303e6218ecec ("selftests: Fix O= and KBUILD_OUTPUT handling for relative paths")
180180
export abs_objtree=$KBUILD_OUTPUT
181181

182-
cmd="make -k $quiet -j $JFACTOR -C tools/testing/selftests"
182+
cmd="make -k $quiet $verbose -j $JFACTOR -C tools/testing/selftests"
183183

184184
if [[ "$1" == "ppctests" ]]; then
185185
TARGETS="powerpc"

etc/configs/kasan-y.config

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_KASAN=y

etc/filters.ini

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[ignore]
2+
start=#@@@ ignore warnings @@@#
3+
stop=#@@@ detect warnings @@@#
4+
15
[patterns]
26
v1=detected stall(s)? on CPU
37
v2=WARNING:.*\s(un)?lock(s|ing)?\s

etc/tests.py

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ngci import TestSuite, SelftestsBuild, SelftestsConfig, QemuSelftestsConfig, TestConfig, QemuNetTestConfig
1+
from ngci import *
22
from configs import *
33
from defaults import *
44
from qemu import kvm_present
@@ -359,3 +359,31 @@ def full_compile_and_qemu(args):
359359
full_compile_test(args, suite)
360360
qemu_coverage(args, suite)
361361
return suite
362+
363+
364+
def qemu_kasan(args, suite=None):
365+
images = std_images(args)
366+
if suite is None:
367+
suite = TestSuite('qemu-kasan', qemus=args.qemus)
368+
369+
k = suite.add_kernel
370+
b = suite.add_qemu_boot
371+
372+
for image in images:
373+
k('ppc64le_guest_defconfig', image, merge_config=guest_configs + ['kasan-y'])
374+
375+
# Just a plain boot
376+
b('qemu-pseries+p9+kvm+radix+fedora34', 'ppc64le_guest_defconfig', image,
377+
script='qemu-pseries+p9+kvm+fedora34')
378+
b('qemu-pseries+p9+kvm+hpt+fedora34', 'ppc64le_guest_defconfig', image,
379+
script='qemu-pseries+p9+kvm+fedora34', cmdline='disable_radix')
380+
381+
# Now boot and test KASAN
382+
test = QemuTestConfig('kasan-kunit', ['kasan_kunit'])
383+
b('qemu-pseries+p9+kvm+radix+fedora34+kasan', 'ppc64le_guest_defconfig', image,
384+
script='qemu-pseries+p9+kvm+fedora34', tests=[test])
385+
# FIXME currently broken - some missing kasan_arch_is_ready() or similar
386+
#b('qemu-pseries+p9+kvm+hpt+fedora34+kasan', 'ppc64le_guest_defconfig', image,
387+
# script='qemu-pseries+p9+kvm+fedora34', tests=[test], cmdline='disable_radix')
388+
389+
return suite

lib/ngci.py

+19
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,25 @@ def setup(self, state, boot, test_dir):
291291
boot.args.append('--net-tests')
292292

293293

294+
class QemuTestConfig(TestConfig):
295+
def __init__(self, name, callbacks=[]):
296+
super().__init__(f'qemu-test-{name}')
297+
self.callbacks = callbacks
298+
299+
def setup(self, state, boot, test_dir):
300+
start_marker = f'starting-{self.name}'
301+
end_marker = f'end-{self.name}'
302+
303+
# Script doesn't run the tests, just greps the qemu console.log
304+
gen_script(f'{test_dir}/run.sh',
305+
f"awk '/{start_marker}/, /{end_marker}/' ../console.log | tee extracted.log")
306+
307+
boot.callbacks.append(f'sh(# {start_marker})')
308+
for callback in self.callbacks:
309+
boot.callbacks.append(callback)
310+
boot.callbacks.append(f'sh(# {end_marker})')
311+
312+
294313
class QemuSelftestsConfig(TestConfig):
295314
def __init__(self, selftest_build, collection=None, exclude=[], extra_callbacks=[]):
296315
name = 'qemu-selftests'

lib/pexpect_utils.py

+8
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,11 @@ def xmon_di(p, addr):
198198

199199
return result
200200

201+
202+
def ignore_warnings(p, f):
203+
p.cmd('echo "#@@@ ignore warnings @@@#"')
204+
bug_patterns = p.bug_patterns
205+
p.bug_patterns = []
206+
f(p)
207+
p.bug_patterns = bug_patterns
208+
p.cmd('echo "#@@@ detect warnings @@@#"')

lib/qemu_callbacks.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
from utils import setup_timeout
3+
from pexpect_utils import ignore_warnings
34

45
########################################
56
# Callbacks that can run once the VM has booted
@@ -71,6 +72,12 @@ def run_selftests_nocheck(qconf, p, arg=None):
7172
return run_selftests(qconf, p, arg, check=False)
7273

7374

75+
# KASAN Kunit test, needs modules
76+
def kasan_kunit(qconf, p):
77+
ignore_warnings(p, lambda p: p.cmd('modprobe kasan_test'))
78+
return True
79+
80+
7481
# Invoke lkdtm via sysfs
7582
# eg. --callback "lkdtm(BUG WARNING)"
7683
def lkdtm(qconf, p, arg):

lib/utils.py

+11
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ def filter_log_warnings(infile, outfile):
161161

162162
parser = ConfigParser()
163163
parser.read_file(open(path))
164+
ignore_start = parser['ignore']['start']
165+
ignore_stop = parser['ignore']['stop']
164166
suppressions = [t[1] for t in parser.items('suppressions', [])]
165167
suppression_patterns = [t[1] for t in parser.items('suppression_patterns', [])]
166168
suppression_patterns = [re.compile(p) for p in suppression_patterns]
@@ -180,11 +182,20 @@ def suppress(line):
180182
return False
181183

182184
found = False
185+
ignoring = False
183186
while True:
184187
line = infile.readline()
185188
if len(line) == 0:
186189
break
187190

191+
if ignore_stop in line:
192+
ignoring = False
193+
elif not ignoring and ignore_start in line:
194+
ignoring = True
195+
196+
if ignoring:
197+
continue
198+
188199
if suppress(line):
189200
continue
190201

scripts/misc/apply-configs.py

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Apply configs from etc/configs/ to the local kernel tree.
4+
#
5+
# eg.
6+
# $ cd ~/linux
7+
# $ make ppc64le_defconfig
8+
# $ ~/ci-scripts/scripts/misc/apply-configs.py 4k-pages compat-y
9+
# $ make olddefconfig
10+
#
11+
# Or a group of configs defined in configs.py:
12+
#
13+
# $ ~/ci-scripts/scripts/misc/apply-configs.py guest_configs
14+
15+
16+
from subprocess import run
17+
import os, sys
18+
19+
base_dir = os.path.realpath(f'{os.path.dirname(os.path.realpath(sys.argv[0]))}/../..')
20+
sys.path.append(f'{base_dir}/lib')
21+
22+
import configs
23+
24+
25+
def main(args):
26+
if len(args) == 0:
27+
print('Usage: apply-configs.py (config group|config file)+')
28+
return False
29+
30+
names = []
31+
for arg in args:
32+
try:
33+
group = getattr(configs, arg)
34+
except AttributeError:
35+
names.append(arg)
36+
else:
37+
names.extend(group)
38+
39+
src_dir = os.getcwd()
40+
paths = []
41+
for name in names:
42+
# Look in source tree first, which must be current directory
43+
full_path = f'{src_dir}/{name}'
44+
if os.path.exists(full_path):
45+
paths.append((name, full_path))
46+
continue
47+
48+
full_path = f'{base_dir}/etc/configs/{name}'
49+
if not name.endswith('.config'):
50+
full_path += '.config'
51+
52+
if not os.path.exists(full_path):
53+
print(f'Error: unable to find {name}')
54+
return False
55+
56+
paths.append((name, full_path))
57+
58+
kbuild_output = os.environ.get('KBUILD_OUTPUT', None)
59+
if kbuild_output:
60+
# merge_config.sh writes its TMP files to $PWD, so change into KBUILD_OUTPUT
61+
os.chdir(kbuild_output)
62+
63+
for name, path in paths:
64+
print(f'Merging {name} ...')
65+
rc = run([f'{src_dir}/scripts/kconfig/merge_config.sh', '-m', '.config', path])
66+
if rc.returncode != 0:
67+
print(f'Error: failed merging {name}')
68+
return False
69+
70+
return True
71+
72+
73+
sys.exit(0 if main(sys.argv[1:]) else 1)

0 commit comments

Comments
 (0)