[igt-dev] [PATCH i-g-t v2 3/4] lib/kselftests: Skip kselftest when opening kmsg fails
Tales Aparecida
tales.aparecida at gmail.com
Fri Aug 12 16:18:25 UTC 2022
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 at gmail.com>
---
Notes:
v1 -> v2: Removed return from igt_kselftest_begin and added assertion instead
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..6356a3e9 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_assert_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
More information about the igt-dev
mailing list