#! /usr/bin/python3 # SPDX-License-Identifier: GPL-2.0-or-later # # tasst - Test A Simple Socket Transport # library of test helpers for passt & pasta # # tasst/metatest/static_ifup - Static address configuration # # These test code from tasst.site, but require additional support from # tasst.nstool. # # Copyright Red Hat # Author: David Gibson import contextlib import ipaddress import avocado from tasst import Tasst from tasst.nstool import UnshareSite class StaticNetTasst(Tasst): """ Test helpers for static network configuration :avocado: tags=meta """ IFNAME = 'testveth' TEST_IPS = [ipaddress.ip_interface('192.0.2.1/24'), ipaddress.ip_interface('2001:db8:9a55::1/112'), ipaddress.ip_interface('10.1.2.3/8')] @contextlib.contextmanager def setup_ns(self): with UnshareSite(type(self).__name__, '-Un') as ns: ns.veth(self.IFNAME, self.IFNAME + 'peer') ns.ifup(self.IFNAME, *self.TEST_IPS, dad='disable') yield ns def test_addr(self): with self.setup_ns() as ns: self.assertCountEqual(ns.addrs(self.IFNAME, scope='global'), self.TEST_IPS)