#! /usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright Red Hat # Author: David Gibson """ Test A Simple Socket Transport meta/static_ifup - Static address configuration """ import contextlib import ipaddress import exeter from tasst import nstool IFNAME = 'testveth' IFNAME_PEER = 'vethpeer' TEST_IPS = set([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(): with nstool.unshare_snh('ns', '-Un') as ns: ns.veth(IFNAME, IFNAME_PEER) ns.ifup(IFNAME, *TEST_IPS, dad='disable') yield ns @exeter.test def test_addr(): with setup_ns() as ns: exeter.assert_eq(set(ns.addrs(IFNAME, scope='global')), TEST_IPS)