From a63a0cc85da7558f98c0226eb5f2a871595fb589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= Date: Mon, 24 Jul 2023 01:11:59 +0200 Subject: [PATCH] More attempts to fix testing of ipv6 too Still failing on rawhide however. --- tests/ipv4-tests/dhcpcd-tests.py | 8 +++++++- tests/ipv6-tests/dhcpcd-tests.py | 24 ++++++++++++++---------- tests/ipv6-tests/runtest.sh | 9 ++++----- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/tests/ipv4-tests/dhcpcd-tests.py b/tests/ipv4-tests/dhcpcd-tests.py index 0da8812..d829ba4 100755 --- a/tests/ipv4-tests/dhcpcd-tests.py +++ b/tests/ipv4-tests/dhcpcd-tests.py @@ -59,6 +59,10 @@ class GenericUtilities(): log_file=DHCPCD_LOG_FILE + '.' + conf subprocess.check_output(['dhcpcd', '-4', '-M', '-d', '--logfile', log_file, '-f', conf_file, 'veth-test']) + def StopDhcpcd(self, conf): + """ Stop dhcpcd """ + subprocess.check_output(['dhcpcd', '-x', 'veth-test']) + def StopDaemon(self, pid_file): with open(pid_file, 'r') as f: @@ -123,6 +127,7 @@ class DhcpcdTests(unittest.TestCase, GenericUtilities): self.pid_file = subprocess.check_output(['dhcpcd', '--printpidfile']).rstrip().decode('utf-8') def tearDown(self): + #self.StopDhcpcd() self.StopDaemon(self.pid_file) self.StopDaemon(DNSMASQ_PID_FILE) @@ -184,10 +189,11 @@ class DhcpcdTests(unittest.TestCase, GenericUtilities): output=subprocess.check_output(['dhcpcd','-U', '-4', 'veth-test'], stderr=subprocess.STDOUT).rstrip().decode('utf-8') self.assertRegex(output, 'interface_mtu=1492') + @unittest.skip("Known to be failing") def test_dhcpcd_clientid_vendorclassid_userclass(self): """ verify dhcpcd sends custom clientid vendor class id and userclass """ - self.skipTest('Known to be failing') + self.debug() self.StartDnsMasq('dnsmasq-vendorclass.conf') time.sleep(1) diff --git a/tests/ipv6-tests/dhcpcd-tests.py b/tests/ipv6-tests/dhcpcd-tests.py index 9c8f794..e24871e 100755 --- a/tests/ipv6-tests/dhcpcd-tests.py +++ b/tests/ipv6-tests/dhcpcd-tests.py @@ -20,7 +20,7 @@ import socket from pyroute2 import IPRoute DHCPCD_CI_DIR="/var/run/dhcpcd-ci" -DHCPCD_LOG_FILE='/var/run/dhcpcd-ci/dhcpcd-test-log' +DHCPCD_LOG_FILE='/var/run/dhcpcd-ci/dhcpcd-test.log' DHCPCD_CONF_FILE='/var/run/dhcpcd-ci/dhcpcd-test.conf' DHCPCD_PID_FILE='/var/run/dhcpcd.pid' @@ -38,12 +38,9 @@ RESOLVE_CONF='/etc/resolv.conf' def setUpModule(): """Initialize the environment, and perform sanity checks on it.""" - if shutil.which('dhcpcd') is None: - raise OSError(errno.ENOENT, 'dhcpcd not found') - if shutil.which('dhcp6s') is None: - raise OSError(errno.ENOENT, 'dhcdp6s not found') - if shutil.which('radvd') is None: - raise OSError(errno.ENOENT, 'radvd not found') + for tool in ['dhcpcd', 'dhcp6s', 'radvd']: + if shutil.which(tool) is None: + raise OSError(errno.ENOENT, tool+' not found') def tearDownModule(): pass @@ -72,6 +69,12 @@ class GenericUtilities(): os.remove(pid_file) + def StopDaemonOptional(self, pid_file): + try: + self.StopDaemon(pid_file) + except FileNotFoundError: + pass + def WriteConfigFile(self, path, contents): """Write a config file, and queue it to be removed.""" @@ -116,12 +119,13 @@ class DhcpcdTests(unittest.TestCase, GenericUtilities): def setUp(self): """ setup veth and write radvd and dhcpv6configs """ + self.pid_file = subprocess.check_output(['dhcpcd', '--printpidfile']).rstrip().decode('utf-8') self.SetupVethInterface() def tearDown(self): - self.StopDaemon(DHCPCD_PID_FILE) - self.StopDaemon(RADVD_PID_FILE) - self.StopDaemon(DHCP6S_PID_FILE) + self.StopDaemon(self.pid_file) + self.StopDaemonOptional(RADVD_PID_FILE) + self.StopDaemonOptional(DHCP6S_PID_FILE) self.TearDownVethInterface() diff --git a/tests/ipv6-tests/runtest.sh b/tests/ipv6-tests/runtest.sh index aa44415..69e8977 100755 --- a/tests/ipv6-tests/runtest.sh +++ b/tests/ipv6-tests/runtest.sh @@ -28,27 +28,26 @@ rlJournalStart rlFileBackup "$RESOLVE_CONF" rlFileBackup "$DHCPCD_DUID_FILE" rlRun "[ -e /sys/class/net/veth-test ] && ip link del veth-test" 0,1 + rlRun "TESTDIR=$(pwd)" rlLog "Create work dir ..." rlRun "mkdir -p $DHCPCD_CI_DIR" rlRun "cp *.conf $DHCPCD_CI_DIR" - - rlRun "cp dhcpcd-tests.py /usr/bin/" rlPhaseEnd rlPhaseStartTest rlLog "Starting dhcpcd tests ..." - rlRun "/usr/bin/python3 /usr/bin/dhcpcd-tests.py" + rlRun "/usr/bin/python3 ${TESTDIR}/dhcpcd-tests.py" rlPhaseEnd rlPhaseStartCleanup - rlRun "rm /usr/bin/dhcpcd-tests.py" rlRun "[ -e /sys/class/net/veth-test ] && ip link del veth-test" 0,1 rlFileRestore + rlBundleLogs dhcpcd-ci ${DHCPCD_CI_DIR}/*log* rlLog "remove work dir" - rlRun "rm -rf $DHCPCD_CI_DIR" + #rlRun "rm -rf $DHCPCD_CI_DIR" rlRun "setenforce 1" 0,1 rlLog "dhcpcd tests done"