diff options
Diffstat (limited to 'debian/tests')
| -rw-r--r-- | debian/tests/control | 2 | ||||
| -rwxr-xr-x | debian/tests/nm.py (renamed from debian/tests/nm) | 58 |
2 files changed, 32 insertions, 28 deletions
diff --git a/debian/tests/control b/debian/tests/control index 14ebb2f5..a8f4d148 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -2,7 +2,7 @@ Tests: wpa-dhclient Depends: python3, hostapd, dnsmasq-base, wpasupplicant, isc-dhcp-client, iw Restrictions: needs-root allow-stderr isolation-machine -Tests: nm +Tests: nm.py Depends: python3, dnsmasq-base, isc-dhcp-client, gir1.2-networkmanager-1.0, network-manager, hostapd, iw, python3-dbusmock Restrictions: needs-root isolation-machine diff --git a/debian/tests/nm b/debian/tests/nm.py index a40be9e4..64350e08 100755 --- a/debian/tests/nm +++ b/debian/tests/nm.py @@ -821,32 +821,36 @@ class Suspend(NetworkManagerTest, DBusTestCase): self.assert_iface_up(self.dev_w_client, expected_ip_a) -# avoid unintelligible error messages, and breaking "make check" when not being -# root -if os.getuid() != 0: - sys.stderr.write('This integration test suite needs to be run as root\n') - sys.exit(1) - -# AppArmor currently does not allow us to access the system D-BUS from an -# unshared file system. Hack the policy to allow that until that gets fixed -# properly. See https://launchpad.net/bugs/1244157 -subprocess.check_call("sed '/nm-dhcp-client.action {/ s/{/flags=(attach_disconnected) {/'" - " /etc/apparmor.d/sbin.dhclient > $ADTTMP/sbin.dhclient", - shell=True) -subprocess.check_call('apparmor_parser -Kr $ADTTMP/sbin.dhclient', shell=True) - -# unshare the mount namespace, so that our tmpfs mounts are guaranteed to get -# cleaned up, and don't influence the production system -libc6 = ctypes.cdll.LoadLibrary('libc.so.6') -assert libc6.unshare(ctypes.c_int(0x00020000)) == 0, 'failed to unshare mount namespace' - -# stop system-wide NetworkManager to avoid interfering with tests -nm_running = subprocess.call('service network-manager stop 2>&1', shell=True) == 0 - -# write to stdout, not stderr -runner = unittest.TextTestRunner(stream=sys.stdout, verbosity=2) -try: - unittest.main(testRunner=runner) -finally: +def setUpModule(): + # AppArmor currently does not allow us to access the system D-BUS from an + # unshared file system. Hack the policy to allow that until that gets fixed + # properly. See https://launchpad.net/bugs/1244157 + subprocess.check_call("sed '/nm-dhcp-client.action {/ s/{/flags=(attach_disconnected) {/'" + " /etc/apparmor.d/sbin.dhclient > $ADTTMP/sbin.dhclient", + shell=True) + subprocess.check_call('apparmor_parser -Kr $ADTTMP/sbin.dhclient', shell=True) + + # unshare the mount namespace, so that our tmpfs mounts are guaranteed to get + # cleaned up, and don't influence the production system + libc6 = ctypes.cdll.LoadLibrary('libc.so.6') + assert libc6.unshare(ctypes.c_int(0x00020000)) == 0, 'failed to unshare mount namespace' + + # stop system-wide NetworkManager to avoid interfering with tests + nm_running = subprocess.call('service network-manager stop 2>&1', shell=True) == 0 + + +def tearDownModule(): subprocess.call('dhclient eth0', shell=True) subprocess.call('sleep 10', shell=True) + + +if __name__ == '__main__': + # avoid unintelligible error messages, and breaking "make check" when not being + # root + if os.getuid() != 0: + sys.stderr.write('This integration test suite needs to be run as root\n') + sys.exit(1) + + # write to stdout, not stderr + runner = unittest.TextTestRunner(stream=sys.stdout, verbosity=2) + unittest.main(testRunner=runner) |