#! /usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0-or-later # # Copyright Red Hat # Author: David Gibson """ Test A Simple Socket Transport selftest/veth.py - Test various veth configurations """ import contextlib import exeter from tasst import nstool @contextlib.contextmanager def unconfigured_veth(): with nstool.unshare_snh('ns1', '-Un') as ns1: with nstool.unshare_snh('ns2', '-n', parent=ns1, capable=True) as ns2: ns1.veth('veth1', 'veth2', ns2) yield (ns1, ns2) @exeter.test def test_ifs(): with unconfigured_veth() as (ns1, ns2): exeter.assert_eq(set(ns1.ifs()), set(['lo', 'veth1'])) exeter.assert_eq(set(ns2.ifs()), set(['lo', 'veth2'])) @exeter.test def test_mtu(): with unconfigured_veth() as (ns1, ns2): exeter.assert_eq(ns1.mtu('veth1'), 1500) exeter.assert_eq(ns2.mtu('veth2'), 1500)