From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 965005A031C for ; Mon, 05 Aug 2024 14:37:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1722861425; bh=X83p84M93lwpy3Ey8VNO6PWwRvf5AKGET5kHZQSyuqc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XSDur6reP74XzqgPwD3ZtHLCh8aTWOdCZf/SEgpANmb71YrvrSHX0E7ZTVNfpy9xH bOB6SNn4uCTgN4gs6nraKv1rNSUlsqTGsKlBtNUR7XiQtoV7E+rQrlroIEEmcMQwYE I6QVA3NkeU2bertNh9dhy50qfMFSYEbCJNjPl85H9dnZZm1dxhxLuxTRDOzXk2sspl ZQwmdEz2aklszxEQzJGPT1TqNXmNjBXnlHvR5SJcQKQg4HxB99NbzQk70ttkrBnmlE tTtk6aVJ5XSmFA6OUBpO0ZO47oCzTC3D8FqIuH/xgu/haj90FtDVEW+tvJMNjP110N 13jKBJQpWCHjA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4WcwtT2P9Lz4x7D; Mon, 5 Aug 2024 22:37:05 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v2 10/22] tasst: Add helper to get network interface names for a site Date: Mon, 5 Aug 2024 22:36:49 +1000 Message-ID: <20240805123701.1720730-11-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: RFB3GFGNCHG6KKTBB6Z2UHXZEFKFV5EG X-Message-ID-Hash: RFB3GFGNCHG6KKTBB6Z2UHXZEFKFV5EG 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: Start adding convenience functions for handling sites as places with network setup with a simple helper which lists the network interface names for a site. Signed-off-by: David Gibson --- test/tasst/snh.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/tasst/snh.py b/test/tasst/snh.py index dfbe2c84..8ee9802a 100644 --- a/test/tasst/snh.py +++ b/test/tasst/snh.py @@ -13,6 +13,7 @@ tasst/snh.py - Simulated network hosts for testing import contextlib +import json import subprocess import sys @@ -105,6 +106,10 @@ class SimNetHost(contextlib.AbstractContextManager): file=sys.stderr) return proc + def ifs(self): + info = json.loads(self.output('ip', '-j', 'link', 'show')) + return [i['ifname'] for i in info] + # Internal tests def test_true(self): with self as snh: @@ -157,9 +162,14 @@ class SimNetHost(contextlib.AbstractContextManager): pass exeter.assert_raises(subprocess.TimeoutExpired, run_timeout) + def test_has_lo(self): + with self as snh: + assert 'lo' in snh.ifs() + 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_bg_context_timeout, + test_has_lo] @classmethod def selftest(cls, setup): -- 2.45.2