igt-dev.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Tales Aparecida <tales.aparecida@gmail.com>
To: Petri Latvala <petri.latvala@intel.com>, igt-dev@lists.freedesktop.org
Cc: siqueirajordao@riseup.net, magalilemes00@gmail.com,
	tales.aparecida@gmail.com, Isabella Basso <isabbasso@riseup.net>,
	andrealmeid@riseup.net, Trevor Woerner <twoerner@gmail.com>
Subject: [igt-dev] [PATCH i-g-t v3 3/4] lib/kselftests: Skip kselftest when opening kmsg fails
Date: Mon, 15 Aug 2022 11:51:45 -0300	[thread overview]
Message-ID: <20220815145146.24038-4-tales.aparecida@gmail.com> (raw)
In-Reply-To: <20220815145146.24038-1-tales.aparecida@gmail.com>

Check for errors in igt_kselftest_begin() during open("/dev/kmsg")
and fail appropriately, removing the always-zero return of the function.

Signed-off-by: Tales Aparecida <tales.aparecida@gmail.com>
---

Notes:
    v2 -> v3: Use igt_require_fd to skip tests instead of igt_assert_fd, which would fail tests

 lib/igt_kmod.c | 7 +++----
 lib/igt_kmod.h | 2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index bde0461a..5864f68c 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -922,7 +922,7 @@ int igt_kselftest_init(struct igt_kselftest *tst,
 	return 0;
 }
 
-int igt_kselftest_begin(struct igt_kselftest *tst)
+void igt_kselftest_begin(struct igt_kselftest *tst)
 {
 	int err;
 
@@ -933,8 +933,7 @@ int igt_kselftest_begin(struct igt_kselftest *tst)
 	igt_require(err == 0 || err == -ENOENT);
 
 	tst->kmsg = open("/dev/kmsg", O_RDONLY | O_NONBLOCK);
-
-	return 0;
+	igt_require_fd(tst->kmsg);
 }
 
 int igt_kselftest_execute(struct igt_kselftest *tst,
@@ -1012,7 +1011,7 @@ void igt_kselftests(const char *module_name,
 		return;
 
 	igt_fixture
-		igt_require(igt_kselftest_begin(&tst) == 0);
+		igt_kselftest_begin(&tst);
 
 	igt_kselftest_get_tests(tst.kmod, filter, &tests);
 	igt_subtest_with_dynamic(filter ?: "all") {
diff --git a/lib/igt_kmod.h b/lib/igt_kmod.h
index f98dd29f..0d80451b 100644
--- a/lib/igt_kmod.h
+++ b/lib/igt_kmod.h
@@ -65,7 +65,7 @@ struct igt_kselftest_list {
 
 int igt_kselftest_init(struct igt_kselftest *tst,
 		       const char *module_name);
-int igt_kselftest_begin(struct igt_kselftest *tst);
+void igt_kselftest_begin(struct igt_kselftest *tst);
 
 void igt_kselftest_get_tests(struct kmod_module *kmod,
 			     const char *filter,
-- 
2.37.1

  parent reply	other threads:[~2022-08-15 14:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 14:51 [igt-dev] [PATCH i-g-t v3 0/4] add kselftest runner documentation Tales Aparecida
2022-08-15 14:51 ` [igt-dev] [PATCH i-g-t v3 1/4] lib/igt_kmod: fix trivial typos Tales Aparecida
2022-08-15 14:51 ` [igt-dev] [PATCH i-g-t v3 2/4] CONTRIBUTING: Add reference for GTKDoc Tales Aparecida
2022-08-15 14:51 ` Tales Aparecida [this message]
2022-08-15 14:51 ` [igt-dev] [PATCH i-g-t v3 4/4] lib/igt_kmod: add igt_kselftests documentation Tales Aparecida
2022-08-15 16:46   ` André Almeida
2022-08-15 17:20     ` Tales
2022-08-15 17:23       ` André Almeida
2022-08-15 16:35 ` [igt-dev] [PATCH i-g-t v3 2/4] CONTRIBUTING: Add reference for GTKDoc Tales Aparecida
2022-08-15 17:54 ` [igt-dev] ✓ Fi.CI.BAT: success for add kselftest runner documentation (rev3) Patchwork
2022-08-16  2:39 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220815145146.24038-4-tales.aparecida@gmail.com \
    --to=tales.aparecida@gmail.com \
    --cc=andrealmeid@riseup.net \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=isabbasso@riseup.net \
    --cc=magalilemes00@gmail.com \
    --cc=petri.latvala@intel.com \
    --cc=siqueirajordao@riseup.net \
    --cc=twoerner@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).