From 313d8dbbed298fea3df00904771f7bca840cfeae Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Wed, 14 Oct 2020 09:55:57 -0700 Subject: [PATCH] auto-t: remove requirement for /var/lib/{ead,iwd} The host systems configuration directories for IWD/EAD were being mounted in the virtual machine. This required that the host create these directories before hand. Instead we can just set up the system and IWD/EAD to use directories in /tmp that we create when we start the VM. This avoids the need for any host configuration. --- autotests/testEAD/connection_test.py | 11 ++++++++--- autotests/util/iwd.py | 10 +++++----- tools/test-runner | 6 +++--- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/autotests/testEAD/connection_test.py b/autotests/testEAD/connection_test.py index c51d7237..bdf242b6 100644 --- a/autotests/testEAD/connection_test.py +++ b/autotests/testEAD/connection_test.py @@ -2,6 +2,7 @@ import unittest import sys +import os sys.path.append('../util') from iwd import IWD @@ -11,7 +12,9 @@ from ead import EAD class Test(unittest.TestCase): def test_connection_success(self): - ctx.start_process(['ead', '-i', 'eth1', '-d']) + env = os.environ.copy() + env['STATE_DIRECTORY'] = '/tmp/ead' + ctx.start_process(['ead', '-i', 'eth1', '-d'], env=env) ead = EAD() @@ -25,11 +28,13 @@ class Test(unittest.TestCase): @classmethod def setUpClass(cls): - IWD.copy_to_storage('default.8021x', storage_dir='/var/lib/ead') + os.mkdir('/tmp/ead') + + IWD.copy_to_storage('default.8021x', storage_dir='/tmp/ead') @classmethod def tearDownClass(cls): - IWD.clear_storage() + IWD.clear_storage(storage_dir='/tmp/ead') if __name__ == '__main__': unittest.main(exit=True) diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py index ef843a95..76d96289 100755 --- a/autotests/util/iwd.py +++ b/autotests/util/iwd.py @@ -17,8 +17,8 @@ from enum import Enum from config import ctx -IWD_STORAGE_DIR = '/var/lib/iwd' -IWD_CONFIG_DIR = '/etc/iwd' +IWD_STORAGE_DIR = '/tmp/iwd' +IWD_CONFIG_DIR = '/tmp' DBUS_OBJECT_MANAGER = 'org.freedesktop.DBus.ObjectManager' DBUS_PROPERTIES = 'org.freedesktop.DBus.Properties' @@ -909,9 +909,9 @@ class IWD(AsyncOpAbstract): GLib.source_remove(timeout) @staticmethod - def clear_storage(): - os.system('rm -rf ' + IWD_STORAGE_DIR + '/*') - os.system('rm -rf ' + IWD_STORAGE_DIR + '/hotspot/*') + def clear_storage(storage_dir=IWD_STORAGE_DIR): + os.system('rm -rf ' + storage_dir + '/*') + os.system('rm -rf ' + storage_dir + '/hotspot/*') @staticmethod def create_in_storage(file_name, file_content): diff --git a/tools/test-runner b/tools/test-runner index 3b9c1854..809a3905 100755 --- a/tools/test-runner +++ b/tools/test-runner @@ -112,8 +112,6 @@ mount_table = [ MountInfo('devpts', '/dev/pts', 'mode=0620', MS_NOSUID|MS_NOEXEC), MountInfo('tmpfs', '/dev/shm', 'mode=1777', MS_NOSUID|MS_NODEV|MS_STRICTATIME), MountInfo('tmpfs', '/run', 'mode=0755', MS_NOSUID|MS_NODEV|MS_STRICTATIME), - MountInfo('tmpfs', '/var/lib/iwd', 'mode=0755', 0), - MountInfo('tmpfs', '/var/lib/ead', 'mode=0755', 0), MountInfo('tmpfs', '/tmp', '', 0), MountInfo('tmpfs', '/usr/share/dbus-1', 'mode=0755', MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME), MountInfo('debugfs', '/sys/kernel/debug', '', 0) @@ -572,7 +570,7 @@ class TestContext: env = os.environ.copy() env['CONFIGURATION_DIRECTORY'] = config_dir - env['STATE_DIRECTORY'] = '/var/lib/iwd' + env['STATE_DIRECTORY'] = '/tmp/iwd' if self.is_verbose('iwd-dhcp'): env['IWD_DHCP_DEBUG'] = '1' @@ -742,6 +740,8 @@ def prepare_sandbox(): for entry in dev_table: os.symlink(entry.target, entry.linkpath) + os.mkdir('/tmp/iwd') + os.setsid() fcntl.ioctl(STDIN_FILENO, TIOCSTTY, 1)