All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v6 1/3] Add tst_kconfig_get() helper function
@ 2021-01-12  9:57 Martin Doucha
  2021-01-12  9:57 ` [LTP] [PATCH v6 2/3] Add tst_secureboot_enabled() " Martin Doucha
  2021-01-12  9:57 ` [LTP] [PATCH v6 3/3] syscalls/iopl02, ioperm02: Skip when kernel is locked down Martin Doucha
  0 siblings, 2 replies; 6+ messages in thread
From: Martin Doucha @ 2021-01-12  9:57 UTC (permalink / raw)
  To: ltp

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

Changes since v3:
- new patch

Changes since v4:
- moved tst_kconfig_get() declaration to tst_private.h

 include/tst_private.h |  8 ++++++++
 lib/tst_kconfig.c     | 21 +++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/include/tst_private.h b/include/tst_private.h
index e30d34740..fe0955f3b 100644
--- a/include/tst_private.h
+++ b/include/tst_private.h
@@ -29,4 +29,12 @@ void tst_print_svar_change(const char *name, const char *val);
 
 int tst_get_prefix(const char *ip_str, int is_ipv6);
 
+/*
+ * Checks kernel config for a single configuration option and returns its
+ * state if found. The possible return values are the same as for
+ * tst_kconfig_var.choice, with the same meaning. See tst_kconfig_read()
+ * description in tst_kconfig.h.
+ */
+char tst_kconfig_get(const char *confname);
+
 #endif
diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
index 734039e37..2b1087a8d 100644
--- a/lib/tst_kconfig.c
+++ b/lib/tst_kconfig.c
@@ -511,3 +511,24 @@ void tst_kconfig_check(const char *const kconfigs[])
 	if (abort_test)
 		tst_brk(TCONF, "Aborting due to unsuitable kernel config, see above!");
 }
+
+char tst_kconfig_get(const char *confname)
+{
+	struct tst_kconfig_var var;
+
+	var.id_len = strlen(confname);
+
+	if (var.id_len >= sizeof(var.id))
+		tst_brk(TBROK, "Kconfig var name \"%s\" too long", confname);
+
+	strcpy(var.id, confname);
+	var.choice = 0;
+	var.val = NULL;
+
+	tst_kconfig_read(&var, 1);
+
+	if (var.choice == 'v')
+		free(var.val);
+
+	return var.choice;
+}
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-14 14:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-12  9:57 [LTP] [PATCH v6 1/3] Add tst_kconfig_get() helper function Martin Doucha
2021-01-12  9:57 ` [LTP] [PATCH v6 2/3] Add tst_secureboot_enabled() " Martin Doucha
2021-01-14 13:38   ` Cyril Hrubis
2021-01-14 13:46     ` Martin Doucha
2021-01-14 14:09       ` Cyril Hrubis
2021-01-12  9:57 ` [LTP] [PATCH v6 3/3] syscalls/iopl02, ioperm02: Skip when kernel is locked down Martin Doucha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.