From nobody Mon May 15 10:53:39 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QKbnw0Y23z4BTCc; Mon, 15 May 2023 10:53:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QKbnv6pBNz42Ct; Mon, 15 May 2023 10:53:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684148020; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fm1VvJeeL9RBul9AqRCcmbauvkJFbiDKjZJZ3nTBmQs=; b=Vrn6/UQIHegnodYk2FBhXx7RTmK25tT+y8xULNmbTAAYTgHiN7fXalMe0i/B4G0Wncp2ix mQD7UJpNyaDB9zIDLYGYGjc+z+7egKOCoqjkvE2jwhsP45Y5ygGP1TiVU5FlYYNNtHsVqf sSTiFmwfalJ3apRjZ+H4e/GPFcMafyZm8AqDTbMHUYq4CgHSTpKmfBElF1DKhavhB97ezS xajZHUJmwso7dPq6IWmYfKzqC4wJGyrdFdjCk3K136Ke1X+2BfxjidczPZlWsfUQjGl4T+ 34eXhc52HjeFDWO7lreus5uNnV/PbYwqvvBeQ1j5iemvSR09iefIzQ7kJAgOIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684148020; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fm1VvJeeL9RBul9AqRCcmbauvkJFbiDKjZJZ3nTBmQs=; b=cUpfn8/FGsdm23X0BLNP2l2v/eyKIdNEnLug9pylfgYAQ1E4Yk4CKRnb4WFYpQdJvtbo+/ 5PDoW67Y/88c73VLrdMHfAI+e/szx05ylqRn+OPJqroP2uoqviQT3hOn18elsUKbiH+OUd 0sSC7cVZgzhlM9TcGYcrPIIGd/fWPYdAz2GF/fk92Pzd1WjT1bueVdrOifj/rHQrPujMzX CewI3wV1fDRqqx2oopuCmMC+I//i9rjvg10cfn1APAQDErqL/OPge1T4+6XNwgZgoBB+1u Gpce/v58IqdG/TO/dV9UqlLwPRsBxX7IK2rfMrSBAbia9wTD6J069kalBWcGTg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1684148020; a=rsa-sha256; cv=none; b=aJDnGDjJ0ryTEZd6eZWLkm6fP1t1kQuRHrWdv403U2hZV8rnaM1JNbETri4kcUTG72yR7D 7hMXt0CvRs12JMoKgXWy4BdegLGNTacADerDhdyuvqX4fcgVAlu1cPqL2/E2o1tBS4u/lq f17cwyAhWtx/Vz296Tfz43ItadXm7fwV7jjejWt+a2+3u17Dc2ETOlXXCKr950gHiw2VM7 5iIkqnaTWHhaRmf7eWoL86oIoBBRRYzdltUdxygzu8XpAP2jvoZc2vswnva+WZtztGAevE QiQFQu/67yOHlbv850jqjXx1v+wMv1S9IwPZzy0NalpeCd/mKuyALYkt1RpOnw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QKbnv5rFFzchJ; Mon, 15 May 2023 10:53:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34FArdB2095648; Mon, 15 May 2023 10:53:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34FArdx6095647; Mon, 15 May 2023 10:53:39 GMT (envelope-from git) Date: Mon, 15 May 2023 10:53:39 GMT Message-Id: <202305151053.34FArdx6095647@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 97760572a0e4 - main - testing: add public method for requiring module presense in pytest List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 97760572a0e4c287a67730df80e7a7b4cf735977 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=97760572a0e4c287a67730df80e7a7b4cf735977 commit 97760572a0e4c287a67730df80e7a7b4cf735977 Author: Alexander V. Chernikov AuthorDate: 2023-05-15 10:50:55 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-05-15 10:50:55 +0000 testing: add public method for requiring module presense in pytest MFC after: 2 weeks --- tests/atf_python/utils.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/atf_python/utils.py b/tests/atf_python/utils.py index 1c0a68dad383..4bd4b642b131 100644 --- a/tests/atf_python/utils.py +++ b/tests/atf_python/utils.py @@ -47,14 +47,21 @@ class BaseTest(object): TARGET_USER = None # Set to the target user by the framework REQUIRED_MODULES: List[str] = [] + def require_module(self, mod_name: str, skip=True): + error_code = libc.modfind(mod_name) + if error_code == 0: + return + err_str = os.strerror(error_code) + txt = "kernel module '{}' not available: {}".format(mod_name, err_str) + if skip: + pytest.skip(txt) + else: + raise ValueError(txt) + def _check_modules(self): for mod_name in self.REQUIRED_MODULES: - error_code = libc.modfind(mod_name) - if error_code != 0: - err_str = os.strerror(error_code) - pytest.skip( - "kernel module '{}' not available: {}".format(mod_name, err_str) - ) + self.require_module(mod_name) + @property def atf_vars(self) -> Dict[str, str]: px = "_ATF_VAR_"