From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id C338F5A0321 for ; Mon, 05 Aug 2024 14:37:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1722861425; bh=hNAvkV5z2ZblQoSQfW1ALWd5i4HAI7aOdSLyZ2/ujho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hnuZWF+F5Y238g9jhXeiC10AZJPKC5WabGTZGFT+8p1ASjjBdwGFRGUKvKSHTUTv3 +cIk5SG+IRziRfUlcEh2qZNpynCVbZYwjlUdUuwyrV7ckslv/p943N1ycjIk4j2Toh tHSLFqbiTlYUoVpNBQMDU2eJR1f7QKH1WfGEQGCy7Rz+zaxjZJ8GrvQr7beD9Uqlld 4QI5Q2pJUyTOjzmsKrDYK33zkCze9lRBZAWnmxoqUZVCAS7/gEOeEyIQnp+ERHhJ8e ShxurQFM5ilnOaaQHFvG4MbBf8nMpYlztszV6NF9sau6OsjHeTktV2i/leHwAO2nEB Slhb1K3GQuiHA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4WcwtT2d8Xz4x7H; Mon, 5 Aug 2024 22:37:05 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v2 14/22] tasst: Add helper for getting MTU of a network interface Date: Mon, 5 Aug 2024 22:36:53 +1000 Message-ID: <20240805123701.1720730-15-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240805123701.1720730-1-david@gibson.dropbear.id.au> References: <20240805123701.1720730-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: XK22SSE2J5RB4343KRTIZHHXO3RF2KCE X-Message-ID-Hash: XK22SSE2J5RB4343KRTIZHHXO3RF2KCE X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Cleber Rosa , David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: David Gibson --- test/tasst/selftest/veth.py | 7 +++++++ test/tasst/snh.py | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/test/tasst/selftest/veth.py b/test/tasst/selftest/veth.py index 3c0b3f5b..5c8f0c0b 100644 --- a/test/tasst/selftest/veth.py +++ b/test/tasst/selftest/veth.py @@ -31,3 +31,10 @@ 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) diff --git a/test/tasst/snh.py b/test/tasst/snh.py index fd8f6f13..0554fbd0 100644 --- a/test/tasst/snh.py +++ b/test/tasst/snh.py @@ -130,6 +130,11 @@ class SimNetHost(contextlib.AbstractContextManager): for ai in self.addrinfos(ifname, **criteria) if 'tentative' not in ai] + def mtu(self, ifname): + cmd = ['ip', '-j', 'link', 'show', f'{ifname}'] + (info,) = json.loads(self.output(*cmd)) + return info['mtu'] + # Internal tests def test_true(self): with self as snh: @@ -192,10 +197,14 @@ class SimNetHost(contextlib.AbstractContextManager): with self as snh: assert set(snh.addrs('lo')) == expected + def test_lo_mtu(self): + with self as snh: + exeter.assert_eq(snh.mtu('lo'), 65536) + SELFTESTS = [test_true, test_false, test_echo, test_timeout, test_bg_true, test_bg_false, test_bg_echo, test_bg_timeout, test_bg_context_timeout, - test_has_lo, test_lo_addrs] + test_has_lo, test_lo_addrs, test_lo_mtu] @classmethod def selftest(cls, setup): -- 2.45.2