3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-21 22:09:23 +01:00

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.
This commit is contained in:
James Prestwood 2020-10-14 09:55:57 -07:00 committed by Denis Kenzior
parent 008b29f359
commit 313d8dbbed
3 changed files with 16 additions and 11 deletions

View File

@ -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)

View File

@ -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):

View File

@ -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)