diff options
author | Evgeny Vereshchagin <evvers@ya.ru> | 2018-11-05 06:47:38 +0300 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-05 12:47:38 +0900 |
commit | 201bf07f7c5467928a0dd6c91ef298f144151740 (patch) | |
tree | cc8c0e5341c2336d7f4f62298c073e9cf6cf0ec5 /test/test-network | |
parent | man: locale.conf: fix file name (#10637) (diff) | |
download | systemd-201bf07f7c5467928a0dd6c91ef298f144151740.tar.gz systemd-201bf07f7c5467928a0dd6c91ef298f144151740.tar.bz2 systemd-201bf07f7c5467928a0dd6c91ef298f144151740.zip |
tests: also use lsmod to check whether modules are available (#10634)
It's not entirely impossible to screw something up playing with
kernel modules on a Saturday evening :-) This PR fixes a scenario
where a module has been loaded into the kernel but the module itself
has been removed from the disk.
```
$ lsmod | grep wireg
wireguard 225280 0
ip6_udp_tunnel 16384 1 wireguard
udp_tunnel 16384 1 wireguard
$ modprobe wireguard
modprobe: FATAL: Module wireguard not found in directory /lib/modules/4.18.16-200.fc28.x86_64
$ sudo ./systemd-networkd-tests.py NetworkdNetDevTests.test_wireguard
...
modprobe: FATAL: Module wireguard not found in directory /lib/modules/4.18.16-200.fc28.x86_64
test_wireguard (__main__.NetworkdNetDevTests) ... unexpected success
----------------------------------------------------------------------
Ran 1 test in 5.152s
FAILED (unexpected successes=1)
```
This is a follow-up to https://github.com/systemd/systemd/pull/10625.
Diffstat (limited to 'test/test-network')
-rwxr-xr-x | test/test-network/systemd-networkd-tests.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 16dadd150..b418d15e8 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -7,6 +7,7 @@ import sys import unittest import subprocess import time +import re import shutil import signal import socket @@ -23,7 +24,9 @@ dnsmasq_pid_file='/var/run/networkd-ci/test-test-dnsmasq.pid' dnsmasq_log_file='/var/run/networkd-ci/test-dnsmasq-log-file' def is_module_available(module_name): - return not subprocess.call(["modprobe", module_name]) + lsmod_output = subprocess.check_output('lsmod', universal_newlines=True) + module_re = re.compile(r'^{0}\b'.format(re.escape(module_name)), re.MULTILINE) + return module_re.search(lsmod_output) or not subprocess.call(["modprobe", module_name]) def expectedFailureIfModuleIsNotAvailable(module_name): def f(func): |