Skip to contentSkip to conversation

Replace needs_drivers with needs_kconfigs

PATCH In review Cyril Hrubis 3 participants 51 messages Apr 2 – Apr 21 Library code

lore
Share & tools
lore
#0 lore raw

cover Replace needs_drivers with needs_kconfigs

The needs_drivers and needs_kconfigs options had overlapping functionality. This patchset gets rid of needs_drivers by adding module checks to needs_kconfigs.

Cyril Hrubis (17):
syscalls: ioctl08: Remove .needs_drivers
lib: shell: Remove needs_drivers from JSON parser
lib: tst_kernel: Add tst_check_module_driver()
lib: tst_kconfig: Add module presence checks
tests: kvm: Switch from needs_drivers to needs_kconfigs
tests: zram03: Switch from needs_drivers to needs_kconfigs
tests: squashfs01: Switch from needs_drivers to needs_kconfigs
tests: ioctl: Switch from needs_drivers to needs_kconfigs
tests: madvise11: Switch from needs_drivers to needs_kconfigs
tests: quotactl: Switch from needs_drivers to needs_kconfigs
tests: uevent: Switch from needs_drivers to needs_kconfigs
cve: tcindex01: Switch from needs_drivers to needs_kconfigs
tests: can: Switch from needs_drivers to needs_kconfigs
tests: fsetxattr: Switch from needs_drivers to needs_kconfigs
sctp: Switch from needs_drivers to needs_kconfigs
lib: tst_test: Remove now unused needs_drivers
doc: metadata: Remove needs_drivers from docs

 doc/developers/writing_tests.rst              |  3 --
 doc/old/C-Test-API.asciidoc                   | 13 +++---
 include/tst_kernel.h                          | 10 +++++
 include/tst_test.h                            |  5 ---
 lib/tst_kconfig.c                             | 41 +++++++++++++++++++
 lib/tst_kernel.c                              | 12 +++---
 lib/tst_test.c                                |  9 ----
 metadata/README.md                            | 15 +++----
 testcases/cve/tcindex01.c                     |  5 +--
 testcases/kernel/device-drivers/zram/zram03.c |  4 +-
 testcases/kernel/fs/squashfs/squashfs01.c     |  4 +-
 testcases/kernel/kvm/kvm_pagefault01.c        |  4 +-
 testcases/kernel/kvm/kvm_svm01.c              |  4 +-
 testcases/kernel/kvm/kvm_svm02.c              |  4 +-
 testcases/kernel/kvm/kvm_svm03.c              |  4 +-
 testcases/kernel/kvm/kvm_svm04.c              |  4 +-
 testcases/kernel/kvm/kvm_vmx01.c              |  4 +-
 testcases/kernel/kvm/kvm_vmx02.c              |  4 +-
 .../kernel/syscalls/fsetxattr/fsetxattr02.c   |  4 +-
 testcases/kernel/syscalls/ioctl/ioctl08.c     |  4 --
 testcases/kernel/syscalls/ioctl/ioctl09.c     |  4 +-
 .../kernel/syscalls/ioctl/ioctl_loop01.c      |  4 +-
 .../kernel/syscalls/ioctl/ioctl_loop02.c      |  4 +-
 .../kernel/syscalls/ioctl/ioctl_loop03.c      |  4 +-
 .../kernel/syscalls/ioctl/ioctl_loop04.c      |  4 +-
 .../kernel/syscalls/ioctl/ioctl_loop05.c      |  4 +-
 .../kernel/syscalls/ioctl/ioctl_loop06.c      |  4 +-
 .../kernel/syscalls/ioctl/ioctl_loop07.c      |  4 +-
 testcases/kernel/syscalls/madvise/madvise11.c |  5 +--
 .../kernel/syscalls/quotactl/quotactl01.c     |  4 +-
 .../kernel/syscalls/quotactl/quotactl04.c     |  4 +-
 .../kernel/syscalls/quotactl/quotactl06.c     |  4 +-
 .../kernel/syscalls/quotactl/quotactl08.c     |  4 +-
 .../kernel/syscalls/quotactl/quotactl09.c     |  4 +-
 testcases/kernel/uevents/uevent01.c           |  4 +-
 testcases/kernel/uevents/uevent02.c           |  4 +-
 testcases/kernel/uevents/uevent03.c           |  4 +-
 testcases/lib/tst_run_shell.c                 |  5 ---
 testcases/network/can/cve/can_bcm01.c         |  6 +--
 .../network/can/filter-tests/can_filter.c     |  6 +--
 .../can/filter-tests/can_rcv_own_msgs.c       |  6 +--
 .../func_tests/test_1_to_1_initmsg_connect.c  |  4 +-
 42 files changed, 135 insertions(+), 118 deletions(-)
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH 1/17 syscalls: ioctl08: Remove .needs_drivers

The test already required btrfs filesystem to be mounted by the test library which means that the test would be skipped properly if btrfs is not supported. There is no need to have a duplicit check for a btrfs module.

---
 testcases/kernel/syscalls/ioctl/ioctl08.c | 4 ----
 1 file changed, 4 deletions(-)
testcases/kernel/syscalls/ioctl/ioctl08.c +0 -4
index dd6406550..46a2e5fa7 100644
@@ -129,10 +129,6 @@ static struct tst_test test = {
 		{.type = "btrfs"},
 		{}
 	},
-	.needs_drivers = (const char *const[]) {
-		"btrfs",
-		NULL,
-	},
 };
 #else
 	TST_TEST_TCONF(
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 1/17
#2 lore raw

Re: [LTP] [PATCH 01/17] syscalls: ioctl08: Remove .needs_drivers

Hi Cyril,

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Re: [LTP] [PATCH 01/17] syscalls: ioctl08: Remove .needs_drivers

Hi!
Thanks for all the reviews, pushed.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

PATCH 2/17 lib: shell: Remove needs_drivers from JSON parser

In reply to Cyril Hrubis

No shell tests were using it at the moment.

---
 testcases/lib/tst_run_shell.c | 5 -----
 1 file changed, 5 deletions(-)
testcases/lib/tst_run_shell.c +0 -5
index c12361ef5..2778fb6d5 100644
@@ -68,7 +68,6 @@ enum test_attr_ids {
 	NEEDS_CMDS,
 	NEEDS_DEVFS,
 	NEEDS_DEVICE,
-	NEEDS_DRIVERS,
 	NEEDS_HUGETLBFS,
 	NEEDS_KCONFIGS,
 	NEEDS_ROFS,
@@ -103,7 +102,6 @@ static ujson_obj_attr test_attrs[] = {
 	UJSON_OBJ_ATTR_IDX(NEEDS_CMDS, "needs_cmds", UJSON_ARR),
 	UJSON_OBJ_ATTR_IDX(NEEDS_DEVFS, "needs_devfs", UJSON_BOOL),
 	UJSON_OBJ_ATTR_IDX(NEEDS_DEVICE, "needs_device", UJSON_BOOL),
-	UJSON_OBJ_ATTR_IDX(NEEDS_DRIVERS, "needs_drivers", UJSON_ARR),
 	UJSON_OBJ_ATTR_IDX(NEEDS_HUGETLBFS, "needs_hugetlbfs", UJSON_BOOL),
 	UJSON_OBJ_ATTR_IDX(NEEDS_KCONFIGS, "needs_kconfigs", UJSON_ARR),
 	UJSON_OBJ_ATTR_IDX(NEEDS_ROFS, "needs_rofs", UJSON_BOOL),
@@ -512,9 +510,6 @@ static void parse_metadata(void)
 		case NEEDS_DEVICE:
 			test.needs_device = val.val_bool;
 		break;
-		case NEEDS_DRIVERS:
-			test.needs_drivers = parse_strarr(&reader, &val);
-		break;
 		case NEEDS_HUGETLBFS:
 			test.needs_hugetlbfs = val.val_bool;
 		break;
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 2/17
#6 lore raw

Re: [LTP] [PATCH 02/17] lib: shell: Remove needs_drivers from JSON parser

Quoted 1 line

No shell tests were using it at the moment.

And the current shell tests (tst_test.sh) will be also during conversion to the shell loader changed to use needs_kconfigs.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw

PATCH 3/17 lib: tst_kernel: Add tst_check_module_driver()

In reply to Cyril Hrubis

This function allows us to check for presence of drivers build as modules.

---
 include/tst_kernel.h | 10 ++++++++++
 lib/tst_kernel.c     | 12 +++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)
include/tst_kernel.h +10 -0
index 63ecb19a4..d5a4a9625 100644
@@ -45,6 +45,16 @@ bool tst_abi_bits(int abi);
  */
 int tst_check_builtin_driver(const char *driver);
 
+/**
+ * tst_check_module_driver() - Check if the kernel module is present.
+ *
+ * @driver: the name of the driver.
+ *
+ * Return: 0 if module driver is present or -1 when driver is missing or config file not
+ * available. On Android *always* 0 (always expect the module is present).
+ */
+int tst_check_module_driver(const char *driver);
+
 /**
  * tst_check_driver() - Check support for the kernel module.
  *
lib/tst_kernel.c +7 -5
index 8bb7e080a..8f7503c02 100644
@@ -200,16 +200,18 @@ static int tst_search_driver(const char *driver, const char *file)
 
 int tst_check_builtin_driver(const char *driver)
 {
-	if (!tst_search_driver(driver, "modules.builtin"))
-		return 0;
+	return tst_search_driver(driver, "modules.builtin");
+}
 
-	return -1;
+int tst_check_module_driver(const char *driver)
+{
+	return tst_search_driver(driver, "modules.dep");
 }
 
 int tst_check_driver(const char *driver)
 {
-	if (!tst_search_driver(driver, "modules.dep") ||
-		!tst_check_builtin_driver(driver))
+	if (!tst_check_module_driver(driver) ||
+	    !tst_check_builtin_driver(driver))
 		return 0;
 
 	return -1;
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 3/17
#8 lore raw

Re: [LTP] [PATCH 03/17] lib: tst_kernel: Add tst_check_module_driver()

Hi Cyril,

Quoted 1 line

This function allows us to check for presence of drivers build as

s/build/built/

Quoted 1 line

modules.

Quoted 11 lines
---
 include/tst_kernel.h | 10 ++++++++++
 lib/tst_kernel.c     | 12 +++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)
include/tst_kernel.h +0 -0
index 63ecb19a4..d5a4a9625 100644

include/tst_kernel.h bool tst_abi_bits(int abi); · line 54

Quoted 10 lines
include/tst_kernel.h +7 -0
@@ -45,6 +45,16 @@ bool tst_abi_bits(int abi);
  */
 int tst_check_builtin_driver(const char *driver);
 
+/**
+ * tst_check_module_driver() - Check if the kernel module is present.
+ *
+ * @driver: the name of the driver.
+ *
+ * Return: 0 if module driver is present or -1 when driver is missing or config file not
+ * available. On Android *always* 0 (always expect the module is present).

nit: "the driver" vs. "the module". We have kernel modules which are builtin or compiled as modules. The older two functions say "the driver", but they are also modules (although builtin), maybe worth to change it.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#9 lore raw

Re: [LTP] [PATCH 03/17] lib: tst_kernel: Add tst_check_module_driver()

In reply to Cyril Hrubis

Hi Cyril,

lib/tst_kernel.c static int tst_search_driver(const char *driver, const char *file) · line 208

Quoted 13 lines
lib/tst_kernel.c +5 -3
@@ -200,16 +200,18 @@ static int tst_search_driver(const char *driver, const char *file)
 
 int tst_check_builtin_driver(const char *driver)
 {
-	if (!tst_search_driver(driver, "modules.builtin"))
-		return 0;
+	return tst_search_driver(driver, "modules.builtin");
+}
 
-	return -1;
+int tst_check_module_driver(const char *driver)
+{
+	return tst_search_driver(driver, "modules.dep");

Thinking about it twice, could we check for the module by reading /sys/module/? Our current approach shows what module *should* be available, but that might not be true for some reason (i.e. loadable module not installed).

Unfortunately while this works for loadable modules (and IMHO worth to add it), builtin modules are here only if they have a version or at least one parameter [1]. And this will not work at least for hwpoison_inject.

Kind regards,
Petr

[1] https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-module

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#10 lore raw

Re: [LTP] [PATCH 03/17] lib: tst_kernel: Add tst_check_module_driver()

Hi!

Quoted 8 lines

lib/tst_kernel.c static int tst_search_driver(const char *driver, const char *file) · line 208

Quoted 4 lines
lib/tst_kernel.c +3 -1
-	return -1;
+int tst_check_module_driver(const char *driver)
+{
+	return tst_search_driver(driver, "modules.dep");

Thinking about it twice, could we check for the module by reading /sys/module/? Our current approach shows what module *should* be available, but that might not be true for some reason (i.e. loadable module not installed).

The modules.dep file contains names of all modules installed in particular kernel modules directory. We cannot do anything better than parsing that file because it's (re)genrated on the system each time packages with modules have been installed/removed. If that wasn't the case modprobe that depends on that file wouldn't work either.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#11 lore raw

Re: [LTP] [PATCH 03/17] lib: tst_kernel: Add tst_check_module_driver()

Quoted 10 lines

Hi!

Quoted 8 lines

lib/tst_kernel.c static int tst_search_driver(const char *driver, const char *file) · line 208

Quoted 4 lines
lib/tst_kernel.c +3 -1
-	return -1;
+int tst_check_module_driver(const char *driver)
+{
+	return tst_search_driver(driver, "modules.dep");

Thinking about it twice, could we check for the module by reading /sys/module/? Our current approach shows what module *should* be available, but that might not be true for some reason (i.e. loadable module not installed).

Quoted 5 lines

The modules.dep file contains names of all modules installed in particular kernel modules directory. We cannot do anything better than parsing that file because it's (re)genrated on the system each time packages with modules have been installed/removed. If that wasn't the case modprobe that depends on that file wouldn't work either.

We effectively ask users to install modules.dep and modules.builtin. While this is ok for distros and nobody has complained, I can imagine special embedded systems can have problem. If everything was reliably detectable via /sys or /proc I'd move to it. But even it's not working for all modules, checking first /sys/module/ and fallback using modules.{builtin,dep} wouldn't take much effort. But sure, we can postpone it until somebody has problems with the current approach.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#12 lore raw

Re: [LTP] [PATCH 03/17] lib: tst_kernel: Add tst_check_module_driver()

Hi!

Quoted 10 lines
Quoted 9 lines
Quoted 3 lines

Thinking about it twice, could we check for the module by reading /sys/module/? Our current approach shows what module *should* be available, but that might not be true for some reason (i.e. loadable module not installed).

The modules.dep file contains names of all modules installed in particular kernel modules directory. We cannot do anything better than parsing that file because it's (re)genrated on the system each time packages with modules have been installed/removed. If that wasn't the case modprobe that depends on that file wouldn't work either.

Quoted 5 lines

We effectively ask users to install modules.dep and modules.builtin. While this is ok for distros and nobody has complained, I can imagine special embedded systems can have problem. If everything was reliably detectable via /sys or /proc I'd move to it. But even it's not working for all modules, checking first /sys/module/ and fallback using modules.{builtin,dep} wouldn't take much effort.

My code does not add any new dependencies. The check for module.dep has been in LTP since:

8f7013ba6917 ('tst_check_driver(): Fix kernel module detection on BusyBox')

which was introduced five years ago.

The only thing that changes is that the check is being moved from needs_drivers to needs_kconfigs.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#13 lore raw

Re: [LTP] [PATCH 03/17] lib: tst_kernel: Add tst_check_module_driver()

Quoted 20 lines

Hi!

Quoted 10 lines
Quoted 9 lines
Quoted 3 lines

Thinking about it twice, could we check for the module by reading /sys/module/? Our current approach shows what module *should* be available, but that might not be true for some reason (i.e. loadable module not installed).

The modules.dep file contains names of all modules installed in particular kernel modules directory. We cannot do anything better than parsing that file because it's (re)genrated on the system each time packages with modules have been installed/removed. If that wasn't the case modprobe that depends on that file wouldn't work either.

Quoted 5 lines

We effectively ask users to install modules.dep and modules.builtin. While this is ok for distros and nobody has complained, I can imagine special embedded systems can have problem. If everything was reliably detectable via /sys or /proc I'd move to it. But even it's not working for all modules, checking first /sys/module/ and fallback using modules.{builtin,dep} wouldn't take much effort.

My code does not add any new dependencies. The check for module.dep has been in LTP since:

Quoted 6 lines

8f7013ba6917 ('tst_check_driver(): Fix kernel module detection on BusyBox')

which was introduced five years ago.

The only thing that changes is that the check is being moved from needs_drivers to needs_kconfigs.

Sure, it's not new dependency and I like this cleanup. My point is not directly related to the these changes, but to the fact that I probably did not know about /sys/module/ back then. But I knew the limitations (no detection on Android, possible problems on embedded).

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#14 lore raw

PATCH 4/17 lib: tst_kconfig: Add module presence checks

In reply to Cyril Hrubis

The .needs_kconfig and .needs_drivers fields in the tst_test structure had overlaping functionality. Both were checking if a functionality was build in into the kernel or compiled as a driver. Similarily to the runtime checks added to tst_kconfig modules can be build but packaged into separate packages and may not be installed on the system even if corresponding config option was set to 'm'.

This commit adds a mapping table from CONFIG options to module names for the modules we care about. Most of the time the mapping is trivial, but some CONFIG options does not really match the module name, hence we need a mapping. We may also be able to generate the table from kernel config infrastructure later on, but at this point the number of options is small enough to be manageable by hand editing.

Once we have that mapping we can run aditional check for a module presence if the confing option was set to 'm' and if mapping exists in order to disable the config option when the module was not found.

---
 lib/tst_kconfig.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
lib/tst_kconfig.c +41 -0
index 52dd6d726..c5dd97a45 100644
@@ -144,6 +144,46 @@ static void runtime_check(struct tst_kconfig_var *var)
 	}
 }
 
+static struct module_check {
+	const char *config;
+	const char *module_name;
+} module_checks[] = {
+	{"CONFIG_KVM", "kvm"},
+	{"CONFIG_ZRAM", "zram"},
+	{"CONFIG_SQUASHFS", "squashfs"},
+	{"CONFIG_BLK_DEV_LOOP", "loop"},
+	{"CONFIG_TUN", "tun"},
+	{"CONFIG_BLK_DEV_RAM", "brd"},
+	{"CONFIG_HWPOISON_INJECT", "hwpoison_inject"},
+	{"CONFIG_QFMT_V2", "quota_v2"},
+	{"CONFIG_INPUT_UINPUT", "uinput"},
+	{"CONFIG_DUMMY", "dummy"},
+	{"CONFIG_CAN_VCAN", "vcan"},
+	{"CONFIG_CAN_RAW", "can-raw"},
+	{"CONFIG_CAN_BCM", "can-bcm"},
+	{"CONFIG_IP_SCTP", "sctp"},
+	{}
+};
+
+static void module_check(struct tst_kconfig_var *var)
+{
+	size_t i;
+
+	for (i = 0; module_checks[i].config; i++) {
+		if (strcmp(module_checks[i].config, var->id))
+			continue;
+
+		tst_res(TDEBUG, "Running module check for '%s'", var->id);
+
+		if (tst_check_module_driver(module_checks[i].module_name)) {
+			tst_res(TINFO, "%s=%c present but module '%s' not installed",
+					var->id, var->choice, module_checks[i].module_name);
+			var->choice = 'n';
+			return;
+		}
+	}
+}
+
 static inline int kconfig_parse_line(const char *line,
                                      struct tst_kconfig_var *vars,
                                      unsigned int vars_len)
@@ -222,6 +262,7 @@ out:
 			case 'm':
 				vars[i].choice = 'm';
 				runtime_check(&vars[i]);
+				module_check(&vars[i]);
 				return 1;
 			}
 		}
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#15 lore raw

Re: [LTP] [PATCH 04/17] lib: tst_kconfig: Add module presence checks

Quoted 41 lines · Cyril Hrubis

The .needs_kconfig and .needs_drivers fields in the tst_test structure had overlaping functionality. Both were checking if a functionality was build in into the kernel or compiled as a driver. Similarily to the runtime checks added to tst_kconfig modules can be build but packaged into separate packages and may not be installed on the system even if corresponding config option was set to 'm'.

This commit adds a mapping table from CONFIG options to module names for the modules we care about. Most of the time the mapping is trivial, but some CONFIG options does not really match the module name, hence we need a mapping. We may also be able to generate the table from kernel config infrastructure later on, but at this point the number of options is small enough to be manageable by hand editing.

Once we have that mapping we can run aditional check for a module presence if the confing option was set to 'm' and if mapping exists in order to disable the config option when the module was not found.

---
 lib/tst_kconfig.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
lib/tst_kconfig.c +10 -0
index 52dd6d726..c5dd97a45 100644
@@ -144,6 +144,46 @@ static void runtime_check(struct tst_kconfig_var *var)
 	}
 }
 
+static struct module_check {
+	const char *config;
+	const char *module_name;
+} module_checks[] = {
+	{"CONFIG_KVM", "kvm"},
+	{"CONFIG_ZRAM", "zram"},
+	{"CONFIG_SQUASHFS", "squashfs"},
+	{"CONFIG_BLK_DEV_LOOP", "loop"},
+	{"CONFIG_TUN", "tun"},
+	{"CONFIG_BLK_DEV_RAM", "brd"},

lib/tst_kconfig.c static void runtime_check(struct tst_kconfig_var *var) · line 166

Quoted 10 lines
lib/tst_kconfig.c +10 -0
+	{"CONFIG_HWPOISON_INJECT", "hwpoison_inject"},
+	{"CONFIG_QFMT_V2", "quota_v2"},
+	{"CONFIG_INPUT_UINPUT", "uinput"},
+	{"CONFIG_DUMMY", "dummy"},
+	{"CONFIG_CAN_VCAN", "vcan"},
+	{"CONFIG_CAN_RAW", "can-raw"},
+	{"CONFIG_CAN_BCM", "can-bcm"},
+	{"CONFIG_IP_SCTP", "sctp"},
+	{}
+};

Maybe rename the struct to:

	static struct config_module_map {
		const char *config;
		const char *module_name;
	} config_module_maps[] = {
		...
	}

And rename 'struct runtime_check' to:

	static struct config_runtime_map {
		const char *config;
		bool (*runtime_check)(void);
	} config_runtime_maps[] = {
		...
	};

This is a tiny nit; I don't have strong opinions.

lib/tst_kconfig.c out: · line 265

Quoted 8 lines
lib/tst_kconfig.c +1 -0
 static inline int kconfig_parse_line(const char *line,
                                      struct tst_kconfig_var *vars,
                                      unsigned int vars_len)
@@ -222,6 +262,7 @@ out:
 			case 'm':
 				vars[i].choice = 'm';
 				runtime_check(&vars[i]);
+				module_check(&vars[i]);

Then rename the two functions to:

kconfig_runtime_check()
kconfig_module_check()

Because in tst_kconfig.c most function contains "kconfig_" string.

Signature · 6 lines
Regards,
Li Wang


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#16 lore raw

Re: [LTP] [PATCH 04/17] lib: tst_kconfig: Add module presence checks

Hi!

Quoted 31 lines

Maybe rename the struct to:

	static struct config_module_map {
		const char *config;
		const char *module_name;
	} config_module_maps[] = {
		...
	}

And rename 'struct runtime_check' to:

	static struct config_runtime_map {
		const char *config;
		bool (*runtime_check)(void);
	} config_runtime_maps[] = {
		...
	};

This is a tiny nit; I don't have strong opinions.

lib/tst_kconfig.c out: · line 265

Quoted 8 lines

static inline int kconfig_parse_line(const char *line,
struct tst_kconfig_var *vars, unsigned int vars_len)

lib/tst_kconfig.c +1 -0
@@ -222,6 +262,7 @@ out:
 			case 'm':
 				vars[i].choice = 'm';
 				runtime_check(&vars[i]);
+				module_check(&vars[i]);

Then rename the two functions to:

Quoted 4 lines

kconfig_runtime_check()
kconfig_module_check()

Because in tst_kconfig.c most function contains "kconfig_" string.

I do not have strong opition, if you agree that these names are better we can rename them.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#17 lore raw

Re: [LTP] [PATCH 04/17] lib: tst_kconfig: Add module presence checks

Quoted 2 lines

I do not have strong opition, if you agree that these names are better we can rename them.

Yes, I have a bit preference to rename.

Signature · 6 lines
Regards,
Li Wang


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#18 lore raw

Re: [LTP] [PATCH 04/17] lib: tst_kconfig: Add module presence checks

Hi!

Quoted 4 lines
Quoted 2 lines

I do not have strong opition, if you agree that these names are better we can rename them.

Yes, I have a bit preference to rename.

I will rename the config module checks in this patchset and add a rename for the runtime checks on the top of it later on then.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 4/17
#19 lore raw

Re: [LTP] [PATCH 04/17] lib: tst_kconfig: Add module presence checks

In reply to Cyril Hrubis

Hi Cyril, Li,

...

lib/tst_kconfig.c static void runtime_check(struct tst_kconfig_var *var) · line 181

Quoted 4 lines
lib/tst_kconfig.c +4 -0
+		if (tst_check_module_driver(module_checks[i].module_name)) {
+			tst_res(TINFO, "%s=%c present but module '%s' not installed",
+					var->id, var->choice, module_checks[i].module_name);
+			var->choice = 'n';

I would consider having defines for 'y', 'm', 'n' to avoid typos. OTOH even kernel code in scripts/kconfig/symbol.c use plain strings (chars) without defines so feel free to ignore.

I consider renames suggested by Li slightly better (it's really mapping).

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#20 lore raw

PATCH 5/17 tests: kvm: Switch from needs_drivers to needs_kconfigs

In reply to Cyril Hrubis
---
 testcases/kernel/kvm/kvm_pagefault01.c | 4 ++--
 testcases/kernel/kvm/kvm_svm01.c       | 4 ++--
 testcases/kernel/kvm/kvm_svm02.c       | 4 ++--
 testcases/kernel/kvm/kvm_svm03.c       | 4 ++--
 testcases/kernel/kvm/kvm_svm04.c       | 4 ++--
 testcases/kernel/kvm/kvm_vmx01.c       | 4 ++--
 testcases/kernel/kvm/kvm_vmx02.c       | 4 ++--
 7 files changed, 14 insertions(+), 14 deletions(-)
testcases/kernel/kvm/kvm_pagefault01.c +2 -2
index 2b477f7af..090d8a6a3 100644
@@ -165,8 +165,8 @@ static struct tst_test test = {
 	.setup = setup,
 	.cleanup = tst_kvm_cleanup,
 	.needs_root = 1,
-	.needs_drivers = (const char *const []) {
-		"kvm",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_KVM",
 		NULL
 	},
 	.supported_archs = (const char *const []) {
testcases/kernel/kvm/kvm_svm01.c +2 -2
index f81602567..b295c18ba 100644
@@ -108,8 +108,8 @@ static struct tst_test test = {
 	.test_all = tst_kvm_run,
 	.setup = tst_kvm_setup,
 	.cleanup = tst_kvm_cleanup,
-	.needs_drivers = (const char *const []) {
-		"kvm",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_KVM",
 		NULL
 	},
 	.supported_archs = (const char *const []) {
testcases/kernel/kvm/kvm_svm02.c +2 -2
index 701f2731d..0c1b239cf 100644
@@ -129,8 +129,8 @@ static struct tst_test test = {
 	.test_all = tst_kvm_run,
 	.setup = tst_kvm_setup,
 	.cleanup = tst_kvm_cleanup,
-	.needs_drivers = (const char *const []) {
-		"kvm",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_KVM",
 		NULL
 	},
 	.supported_archs = (const char *const []) {
testcases/kernel/kvm/kvm_svm03.c +2 -2
index faafaf7cf..dba1ab9e7 100644
@@ -154,8 +154,8 @@ static struct tst_test test = {
 	.test_all = run,
 	.setup = setup,
 	.cleanup = cleanup,
-	.needs_drivers = (const char *const []) {
-		"kvm",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_KVM",
 		NULL
 	},
 	.min_cpus = 2,
testcases/kernel/kvm/kvm_svm04.c +2 -2
index af3c8b1c6..4a6e73818 100644
@@ -295,8 +295,8 @@ static struct tst_test test = {
 	.test_all = tst_kvm_run,
 	.setup = tst_kvm_setup,
 	.cleanup = tst_kvm_cleanup,
-	.needs_drivers = (const char *const []) {
-		"kvm",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_KVM",
 		NULL
 	},
 	.supported_archs = (const char *const []) {
testcases/kernel/kvm/kvm_vmx01.c +2 -2
index d0c4913c9..9950e1bc8 100644
@@ -269,8 +269,8 @@ static struct tst_test test = {
 	.setup = setup,
 	.cleanup = tst_kvm_cleanup,
 	.needs_root = 1,
-	.needs_drivers = (const char *const []) {
-		"kvm",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_KVM",
 		NULL
 	},
 	.supported_archs = (const char *const []) {
testcases/kernel/kvm/kvm_vmx02.c +2 -2
index 4ce225e56..5152ad8f3 100644
@@ -183,8 +183,8 @@ static struct tst_test test = {
 	.setup = setup,
 	.cleanup = tst_kvm_cleanup,
 	.needs_root = 1,
-	.needs_drivers = (const char *const []) {
-		"kvm",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_KVM",
 		NULL
 	},
 	.supported_archs = (const char *const []) {
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 5/17
#21 lore raw

Re: [LTP] [PATCH 05/17] tests: kvm: Switch from needs_drivers to needs_kconfigs

Hi Cyril,

obviously correct, thanks!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#22 lore raw

PATCH 6/17 tests: zram03: Switch from needs_drivers to needs_kconfigs

In reply to Cyril Hrubis
---
 testcases/kernel/device-drivers/zram/zram03.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/device-drivers/zram/zram03.c +2 -2
index 4dcf23b4e..23f6da14f 100644
@@ -236,8 +236,8 @@ static struct tst_test test = {
 	.cleanup = cleanup,
 	.needs_root = 1,
 	.needs_tmpdir = 1,
-	.needs_drivers = (const char *const []) {
-		"zram",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_ZRAM",
 		NULL
 	},
 	.needs_cmds = (struct tst_cmd[]) {
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 6/17
#23 lore raw

Re: [LTP] [PATCH 06/17] tests: zram03: Switch from needs_drivers to needs_kconfigs

Hi Cyril,

obviously correct, thanks!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#24 lore raw

PATCH 7/17 tests: squashfs01: Switch from needs_drivers to needs_kconfigs

In reply to Cyril Hrubis
---
 testcases/kernel/fs/squashfs/squashfs01.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/fs/squashfs/squashfs01.c +2 -2
index 7a548d62c..a5789c6ae 100644
@@ -106,8 +106,8 @@ static struct tst_test test = {
 		{.cmd = "mksquashfs"},
 		{}
 	},
-	.needs_drivers = (const char *const []) {
-		"squashfs",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_SQUASHFS",
 		NULL
 	},
 	.tags = (const struct tst_tag[]) {
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 7/17
#25 lore raw

Re: [LTP] [PATCH 07/17] tests: squashfs01: Switch from needs_drivers to needs_kconfigs

Hi Cyril,

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#26 lore raw

PATCH 8/17 tests: ioctl: Switch from needs_drivers to needs_kconfigs

In reply to Cyril Hrubis
---
 testcases/kernel/syscalls/ioctl/ioctl09.c      | 4 ++--
 testcases/kernel/syscalls/ioctl/ioctl_loop01.c | 4 ++--
 testcases/kernel/syscalls/ioctl/ioctl_loop02.c | 4 ++--
 testcases/kernel/syscalls/ioctl/ioctl_loop03.c | 4 ++--
 testcases/kernel/syscalls/ioctl/ioctl_loop04.c | 4 ++--
 testcases/kernel/syscalls/ioctl/ioctl_loop05.c | 4 ++--
 testcases/kernel/syscalls/ioctl/ioctl_loop06.c | 4 ++--
 testcases/kernel/syscalls/ioctl/ioctl_loop07.c | 4 ++--
 8 files changed, 16 insertions(+), 16 deletions(-)
testcases/kernel/syscalls/ioctl/ioctl09.c +2 -2
index 561c1b6b5..bffcc2e0e 100644
@@ -104,8 +104,8 @@ static struct tst_test test = {
 	.cleanup = cleanup,
 	.test_all = verify_ioctl,
 	.needs_root = 1,
-	.needs_drivers = (const char *const []) {
-		"loop",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_BLK_DEV_LOOP",
 		NULL
 	},
 	.needs_cmds = (struct tst_cmd[]) {
testcases/kernel/syscalls/ioctl/ioctl_loop01.c +2 -2
index f7e56dea8..0322b2633 100644
@@ -136,8 +136,8 @@ static struct tst_test test = {
 	.cleanup = cleanup,
 	.test_all = verify_ioctl_loop,
 	.needs_root = 1,
-	.needs_drivers = (const char *const []) {
-		"loop",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_BLK_DEV_LOOP",
 		NULL
 	},
 	.tags = (const struct tst_tag[]) {
testcases/kernel/syscalls/ioctl/ioctl_loop02.c +2 -2
index a5398ba0a..27f8e6cf9 100644
@@ -158,8 +158,8 @@ static struct tst_test test = {
 	.test = verify_ioctl_loop,
 	.needs_root = 1,
 	.needs_tmpdir = 1,
-	.needs_drivers = (const char *const []) {
-		"loop",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_BLK_DEV_LOOP",
 		NULL
 	}
 };
testcases/kernel/syscalls/ioctl/ioctl_loop03.c +2 -2
index 56a717476..47f69e800 100644
@@ -71,8 +71,8 @@ static struct tst_test test = {
 	.test_all = verify_ioctl_loop,
 	.needs_root = 1,
 	.needs_tmpdir = 1,
-	.needs_drivers = (const char *const []) {
-		"loop",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_BLK_DEV_LOOP",
 		NULL
 	}
 };
testcases/kernel/syscalls/ioctl/ioctl_loop04.c +2 -2
index 38134fb70..e5c11aa5b 100644
@@ -96,8 +96,8 @@ static struct tst_test test = {
 	.test_all = verify_ioctl_loop,
 	.needs_root = 1,
 	.needs_tmpdir = 1,
-	.needs_drivers = (const char *const []) {
-		"loop",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_BLK_DEV_LOOP",
 		NULL
 	}
 };
testcases/kernel/syscalls/ioctl/ioctl_loop05.c +2 -2
index 88db7d168..11952af0a 100644
@@ -154,8 +154,8 @@ static struct tst_test test = {
 		"overlayfs",
 		NULL
 	},
-	.needs_drivers = (const char *const []) {
-		"loop",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_BLK_DEV_LOOP",
 		NULL
 	}
 };
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +2 -2
index 94f9bcdc6..f523df1c6 100644
@@ -147,8 +147,8 @@ static struct tst_test test = {
 	.tcnt = ARRAY_SIZE(tcases),
 	.needs_root = 1,
 	.needs_tmpdir = 1,
-	.needs_drivers = (const char *const []) {
-		"loop",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_BLK_DEV_LOOP",
 		NULL
 	}
 };
testcases/kernel/syscalls/ioctl/ioctl_loop07.c +2 -2
index 0a210038b..6a58577c7 100644
@@ -162,8 +162,8 @@ static struct tst_test test = {
 		{"linux-git", "79e5dc59e297"},
 		{}
 	},
-	.needs_drivers = (const char *const []) {
-		"loop",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_BLK_DEV_LOOP",
 		NULL
 	}
 };
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#27 lore raw

PATCH 9/17 tests: madvise11: Switch from needs_drivers to needs_kconfigs

In reply to Cyril Hrubis
---
 testcases/kernel/syscalls/madvise/madvise11.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
testcases/kernel/syscalls/madvise/madvise11.c +1 -4
index 73d2d4294..97d2b851e 100644
@@ -417,10 +417,6 @@ static void cleanup(void)
 
 static struct tst_test test = {
 	.needs_root = 1,
-	.needs_drivers = (const char *const []) {
-		HW_MODULE,
-		NULL
-	},
 	.needs_cmds = (struct tst_cmd[]) {
 		{.cmd = "modprobe"},
 		{.cmd = "rmmod"},
@@ -428,6 +424,7 @@ static struct tst_test test = {
 	},
 	.needs_kconfigs = (const char *[]) {
 		"CONFIG_MEMORY_FAILURE=y",
+		"CONFIG_HWPOISON_INJECT",
 		NULL
 	},
 	.runtime = 30,
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 9/17
#28 lore raw

Re: [LTP] [PATCH 09/17] tests: madvise11: Switch from needs_drivers to needs_kconfigs

Hi Cyril,

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#29 lore raw

PATCH 10/17 tests: quotactl: Switch from needs_drivers to needs_kconfigs

In reply to Cyril Hrubis
---
 testcases/kernel/syscalls/quotactl/quotactl01.c | 4 ++--
 testcases/kernel/syscalls/quotactl/quotactl04.c | 4 ++--
 testcases/kernel/syscalls/quotactl/quotactl06.c | 4 ++--
 testcases/kernel/syscalls/quotactl/quotactl08.c | 4 ++--
 testcases/kernel/syscalls/quotactl/quotactl09.c | 4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)
testcases/kernel/syscalls/quotactl/quotactl01.c +2 -2
index 3091ac5bf..b14203a28 100644
@@ -208,8 +208,8 @@ static void verify_quota(unsigned int n)
 
 static struct tst_test test = {
 	.needs_root = 1,
-	.needs_drivers = (const char *const []) {
-		"quota_v2",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_QFMT_V2",
 		NULL
 	},
 	.test = verify_quota,
testcases/kernel/syscalls/quotactl/quotactl04.c +2 -2
index a70903330..ee7671ca3 100644
@@ -144,8 +144,8 @@ static void verify_quota(unsigned int n)
 
 static struct tst_test test = {
 	.needs_root = 1,
-	.needs_drivers = (const char *const []) {
-		"quota_v2",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_QFMT_V2",
 		NULL
 	},
 	.min_kver = "4.5", /* commit 689c958cbe6b (ext4: add project quota support) */
testcases/kernel/syscalls/quotactl/quotactl06.c +2 -2
index 333f5720d..b46fd1a3b 100644
@@ -211,8 +211,8 @@ static void cleanup(void)
 static struct tst_test test = {
 	.setup = setup,
 	.cleanup = cleanup,
-	.needs_drivers = (const char *const []) {
-		"quota_v2",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_QFMT_V2",
 		NULL
 	},
 	.tcnt = ARRAY_SIZE(tcases),
testcases/kernel/syscalls/quotactl/quotactl08.c +2 -2
index ce7a8b008..e20a8a8ae 100644
@@ -200,8 +200,8 @@ static void verify_quota(unsigned int n)
 
 static struct tst_test test = {
 	.needs_root = 1,
-	.needs_drivers = (const char *const []) {
-		"quota_v2",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_QFMT_V2",
 		NULL
 	},
 	.test = verify_quota,
testcases/kernel/syscalls/quotactl/quotactl09.c +2 -2
index fd6629c0c..862ab4edf 100644
@@ -168,8 +168,8 @@ static void cleanup(void)
 static struct tst_test test = {
 	.setup = setup,
 	.cleanup = cleanup,
-	.needs_drivers = (const char *const []) {
-		"quota_v2",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_QFMT_V2",
 		NULL
 	},
 	.tcnt = ARRAY_SIZE(tcases),
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 10/17
#30 lore raw

Re: [LTP] [PATCH 10/17] tests: quotactl: Switch from needs_drivers to needs_kconfigs

Hi Cyril,

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#31 lore raw

PATCH 11/17 tests: uevent: Switch from needs_drivers to needs_kconfigs

In reply to Cyril Hrubis
---
 testcases/kernel/uevents/uevent01.c | 4 ++--
 testcases/kernel/uevents/uevent02.c | 4 ++--
 testcases/kernel/uevents/uevent03.c | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
testcases/kernel/uevents/uevent01.c +2 -2
index 09ef42412..f5fe099d8 100644
@@ -90,8 +90,8 @@ static struct tst_test test = {
 	.test_all = verify_uevent,
 	.forks_child = 1,
 	.needs_checkpoints = 1,
-	.needs_drivers = (const char *const []) {
-		"loop",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_BLK_DEV_LOOP",
 		NULL
 	},
 	.needs_root = 1
testcases/kernel/uevents/uevent02.c +2 -2
index abae4f88e..1135f55a8 100644
@@ -148,8 +148,8 @@ static struct tst_test test = {
 	.test_all = verify_uevent,
 	.forks_child = 1,
 	.needs_checkpoints = 1,
-	.needs_drivers = (const char *const []) {
-		"tun",
+	.needs_kconfigs = (const char *const []) {
+		"CONFIG_TUN",
 		NULL
 	},
 	.needs_root = 1
testcases/kernel/uevents/uevent03.c +2 -2
index 23866460b..42d629a4a 100644
@@ -239,8 +239,8 @@ static struct tst_test test = {
 	.test_all = verify_uevent,
 	.forks_child = 1,
 	.needs_checkpoints = 1,
-	.needs_drivers = (const char *const[]) {
-		"uinput",
+	.needs_kconfigs = (const char *const[]) {
+		"CONFIG_INPUT_UINPUT",
 		NULL
 	},
 	.needs_root = 1,
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 11/17
#32 lore raw

Re: [LTP] [PATCH 11/17] tests: uevent: Switch from needs_drivers to needs_kconfigs

Hi Cyril,

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#33 lore raw

PATCH 12/17 cve: tcindex01: Switch from needs_drivers to needs_kconfigs

In reply to Cyril Hrubis
---
 testcases/cve/tcindex01.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
testcases/cve/tcindex01.c +1 -4
index 370d7de49..478d75055 100644
@@ -145,16 +145,13 @@ static struct tst_test test = {
 		"CONFIG_NET_NS=y",
 		"CONFIG_NET_SCH_HTB",
 		"CONFIG_NET_CLS_TCINDEX",
+		"CONFIG_DUMMY",
 		NULL
 	},
 	.save_restore = (const struct tst_path_val[]) {
 		{"/proc/sys/user/max_user_namespaces", "1024", TST_SR_SKIP},
 		{}
 	},
-	.needs_drivers = (const char *const []) {
-		"dummy",
-		NULL
-	},
 	.tags = (const struct tst_tag[]) {
 		{"linux-git", "8c710f75256b"},
 		{"CVE", "2023-1829"},
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 12/17
#34 lore raw

Re: [LTP] [PATCH 12/17] cve: tcindex01: Switch from needs_drivers to needs_kconfigs

Hi Cyril,

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#35 lore raw

PATCH 13/17 tests: can: Switch from needs_drivers to needs_kconfigs

In reply to Cyril Hrubis
---
 testcases/network/can/cve/can_bcm01.c                 | 6 +++---
 testcases/network/can/filter-tests/can_filter.c       | 6 +++---
 testcases/network/can/filter-tests/can_rcv_own_msgs.c | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)
testcases/network/can/cve/can_bcm01.c +3 -3
index 57ec4989f..3b66037e7 100644
@@ -140,9 +140,9 @@ static struct tst_test test = {
 	.needs_root = 1,
 	.skip_in_compat = 1,
 	.min_runtime = 30,
-	.needs_drivers = (const char *const[]) {
-		"vcan",
-		"can-bcm",
+	.needs_kconfigs = (const char *const[]) {
+		"CONFIG_CAN_VCAN",
+		"CONFIG_CAN_BCM",
 		NULL
 	},
 	.tags = (const struct tst_tag[]) {
testcases/network/can/filter-tests/can_filter.c +3 -3
index 1ea8ea18f..8b4f2fc05 100644
@@ -183,9 +183,9 @@ static struct tst_test test = {
 		TST_CAP(TST_CAP_DROP, CAP_SYS_ADMIN),
 		{}
 	},
-	.needs_drivers = (const char *const[]) {
-		"vcan",
-		"can-raw",
+	.needs_kconfigs = (const char *const[]) {
+		"CONFIG_CAN_VCAN",
+		"CONFIG_CAN_RAW",
 		NULL
 	}
 };
testcases/network/can/filter-tests/can_rcv_own_msgs.c +3 -3
index ba40666dc..2c0acecf9 100644
@@ -145,9 +145,9 @@ static struct tst_test test = {
 		TST_CAP(TST_CAP_DROP, CAP_SYS_ADMIN),
 		{}
 	},
-	.needs_drivers = (const char *const[]) {
-		"vcan",
-		"can-raw",
+	.needs_kconfigs = (const char *const[]) {
+		"CONFIG_CAN_VCAN",
+		"CONFIG_CAN_RAW",
 		NULL
 	}
 };
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 13/17
#36 lore raw

Re: [LTP] [PATCH 13/17] tests: can: Switch from needs_drivers to needs_kconfigs

Hi Cyril,

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#37 lore raw

PATCH 14/17 tests: fsetxattr: Switch from needs_drivers to needs_kconfigs

In reply to Cyril Hrubis
---
 testcases/kernel/syscalls/fsetxattr/fsetxattr02.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/fsetxattr/fsetxattr02.c +2 -2
index 42dfc9d4f..2a48b7da7 100644
@@ -265,8 +265,8 @@ static struct tst_test test = {
 	.needs_devfs = 1,
 	.mntpoint = MNTPOINT,
 	.needs_root = 1,
-	.needs_drivers = (const char *const[]) {
-		"brd",
+	.needs_kconfigs = (const char *const[]) {
+		"CONFIG_BLK_DEV_RAM",
 		NULL,
 	},
 };
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 14/17
#38 lore raw

Re: [LTP] [PATCH 14/17] tests: fsetxattr: Switch from needs_drivers to needs_kconfigs

Hi Cyril,

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#39 lore raw

PATCH 15/17 sctp: Switch from needs_drivers to needs_kconfigs

In reply to Cyril Hrubis
---
 utils/sctp/func_tests/test_1_to_1_initmsg_connect.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
utils/sctp/func_tests/test_1_to_1_initmsg_connect.c +2 -2
index 98013cd30..c9c3c1c30 100644
@@ -110,8 +110,8 @@ static void test_sctp(unsigned int n)
 static struct tst_test test = {
 	.test = test_sctp,
 	.tcnt = ARRAY_SIZE(testcase_list),
-	.needs_drivers = (const char *[]) {
-		"sctp",
+	.needs_kconfigs = (const char *[]) {
+		"CONFIG_IP_SCTP",
 		NULL
 	},
 };
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 15/17
#40 lore raw

Re: [LTP] [PATCH 15/17] sctp: Switch from needs_drivers to needs_kconfigs

Hi Cyril,

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#41 lore raw

PATCH 16/17 lib: tst_test: Remove now unused needs_drivers

In reply to Cyril Hrubis
---
 include/tst_test.h | 5 -----
 lib/tst_test.c     | 9 ---------
 2 files changed, 14 deletions(-)
include/tst_test.h +0 -5
index ddfe9d4d6..752688c45 100644
@@ -498,10 +498,6 @@ struct tst_fs {
  *                  to the test temporary directory from the LTP datafiles
  *                  directory.
  *
- * @needs_drivers: A NULL terminated array of kernel modules required to run
- *                 the test. The module has to be build in or present in order
- *                 for the test to run.
- *
  * @save_restore: A {} terminated array of /proc or /sys files that should
  *                saved at the start of the test and restored at the end. See
  *                tst_sys_conf_save() and :ref:`struct tst_path_val` for details.
@@ -605,7 +601,6 @@ struct tst_fs {
 	int (*sample)(int clk_id, long long usec);
 
 	const char *const *resource_files;
-	const char * const *needs_drivers;
 
 	const struct tst_path_val *save_restore;
 
lib/tst_test.c +0 -9
index 2d62ab164..26f6510a0 100644
@@ -1487,15 +1487,6 @@ static void do_setup(int argc, char *argv[])
 		}
 	}
 
-	if (tst_test->needs_drivers) {
-		const char *name;
-		int i;
-
-		for (i = 0; (name = tst_test->needs_drivers[i]); ++i)
-			if (tst_check_driver(name))
-				tst_brk(TCONF, "%s driver not available", name);
-	}
-
 	if (tst_test->mount_device)
 		tst_test->format_device = 1;
 
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#42 lore raw

Re: [LTP] [PATCH 16/17] lib: tst_test: Remove now unused needs_drivers

include/tst_test.h struct tst_fs { · line 503

Quoted 13 lines
include/tst_test.h +0 -4
@@ -498,10 +498,6 @@ struct tst_fs {
  *                  to the test temporary directory from the LTP datafiles
  *                  directory.
  *
- * @needs_drivers: A NULL terminated array of kernel modules required to run
- *                 the test. The module has to be build in or present in order
- *                 for the test to run.
- *
  * @save_restore: A {} terminated array of /proc or /sys files that should
  *                saved at the start of the test and restored at the end. See
  *                tst_sys_conf_save() and :ref:`struct tst_path_val` for details.

As we add runtime_check and module_check, I think we also need to update the descrition comments of @needs_kconfigs in tst_test.h.

Signature · 6 lines
Regards,
Li Wang


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#43 lore raw

Re: [LTP] [PATCH 16/17] lib: tst_test: Remove now unused needs_drivers

Hi!

Quoted 8 lines
Quoted 8 lines
include/tst_test.h +0 -2
@@ -498,10 +498,6 @@ struct tst_fs {
  *                  to the test temporary directory from the LTP datafiles
  *                  directory.
  *
- * @needs_drivers: A NULL terminated array of kernel modules required to run
- *                 the test. The module has to be build in or present in order
Quoted 8 lines

include/tst_test.h struct tst_fs { · line 503

Quoted 5 lines
include/tst_test.h +0 -2
- *                 for the test to run.
- *
  * @save_restore: A {} terminated array of /proc or /sys files that should
  *                saved at the start of the test and restored at the end. See
  *                tst_sys_conf_save() and :ref:`struct tst_path_val` for details.

As we add runtime_check and module_check, I think we also need to update the descrition comments of @needs_kconfigs in tst_test.h.

What about something like this:

include/tst_test.h +7 -0
index 752688c45..f2a5378cd 100644
@@ -511,6 +511,13 @@ struct tst_fs {
  *                  and parenthesis are supported, e.g.
  *                  "CONFIG_X86_INTEL_UMIP=y | CONFIG_X86_UIMP=y" is evaluated
  *                  to true if at least one of the options is present.
+ *                  For some config options their presence in the config file
+ *                  is not enough to assure the functionality is present or
+ *                  enabled. E.g. config option may be set to 'm' but the
+ *                  module may not be installed or functionality may be
+ *                  disabled on the kernel command line. The kconfig library
+ *                  has a set of additonal checks for a few config options that
+ *                  are used in the tests and need additional checks.
  *
  * @bufs: A description of guarded buffers to be allocated for the test. Guarded
  *        buffers are buffers with poisoned page allocated right before the start
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#44 lore raw

Re: [LTP] [PATCH 16/17] lib: tst_test: Remove now unused needs_drivers

Overall it's good, just minor polishing below:

include/tst_test.h struct tst_fs { · line 516

Quoted 9 lines
include/tst_test.h +2 -0
@@ -511,6 +511,13 @@ struct tst_fs {
  *                  and parenthesis are supported, e.g.
  *                  "CONFIG_X86_INTEL_UMIP=y | CONFIG_X86_UIMP=y" is evaluated
  *                  to true if at least one of the options is present.
 
+ *                  For some config options their presence in the config file
+ *                  is not enough to assure the functionality is present or

Merely finding a config option in the config file does not guarantee that the corresponding functionality is available.

include/tst_test.h struct tst_fs { · line 518

Quoted 3 lines
include/tst_test.h +3 -0
+ *                  enabled. E.g. config option may be set to 'm' but the
+ *                  module may not be installed or functionality may be
+ *                  disabled on the kernel command line. The kconfig library

For instance, an option might be set to 'm' without the module being installed, or the feature could be disabled via the kernel command line.

include/tst_test.h struct tst_fs { · line 520

Quoted 2 lines
include/tst_test.h +2 -0
+ *                  has a set of additonal checks for a few config options that
+ *                  are used in the tests and need additional checks.

To address this, the kconfig library implements supplementary runtime checks for specific options required by the tests.

Signature · 6 lines
Regards,
Li Wang


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#45 lore raw

Re: [LTP] [PATCH 16/17] lib: tst_test: Remove now unused needs_drivers

Hi!

Quoted 21 lines

include/tst_test.h struct tst_fs { · line 516

Quoted 9 lines
include/tst_test.h +2 -0
@@ -511,6 +511,13 @@ struct tst_fs {
  *                  and parenthesis are supported, e.g.
  *                  "CONFIG_X86_INTEL_UMIP=y | CONFIG_X86_UIMP=y" is evaluated
  *                  to true if at least one of the options is present.
 
+ *                  For some config options their presence in the config file
+ *                  is not enough to assure the functionality is present or

Merely finding a config option in the config file does not guarantee that the corresponding functionality is available.

include/tst_test.h struct tst_fs { · line 518

Quoted 3 lines
include/tst_test.h +3 -0
+ *                  enabled. E.g. config option may be set to 'm' but the
+ *                  module may not be installed or functionality may be
+ *                  disabled on the kernel command line. The kconfig library

For instance, an option might be set to 'm' without the module being installed, or the feature could be disabled via the kernel command line.

Quoted 5 lines

include/tst_test.h struct tst_fs { · line 520

Quoted 2 lines
include/tst_test.h +2 -0
+ *                  has a set of additonal checks for a few config options that
+ *                  are used in the tests and need additional checks.

To address this, the kconfig library implements supplementary runtime checks for specific options required by the tests.

Thanks, will use that version for the final patchset.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by
#46 lore raw

Re: [LTP] [PATCH 16/17] lib: tst_test: Remove now unused needs_drivers

In reply to Cyril Hrubis

Hi Cyril, Li,

Quoted 26 lines

Hi!

Quoted 8 lines
Quoted 8 lines
include/tst_test.h +0 -2
@@ -498,10 +498,6 @@ struct tst_fs {
  *                  to the test temporary directory from the LTP datafiles
  *                  directory.
  *
- * @needs_drivers: A NULL terminated array of kernel modules required to run
- *                 the test. The module has to be build in or present in order
Quoted 8 lines

include/tst_test.h struct tst_fs { · line 503

Quoted 5 lines
include/tst_test.h +0 -2
- *                 for the test to run.
- *
  * @save_restore: A {} terminated array of /proc or /sys files that should
  *                saved at the start of the test and restored at the end. See
  *                tst_sys_conf_save() and :ref:`struct tst_path_val` for details.

As we add runtime_check and module_check, I think we also need to update the descrition comments of @needs_kconfigs in tst_test.h.

What about something like this:

include/tst_test.h +0 -0
index 752688c45..f2a5378cd 100644

include/tst_test.h struct tst_fs { · line 519

Quoted 9 lines
include/tst_test.h +6 -0
@@ -511,6 +511,13 @@ struct tst_fs {
  *                  and parenthesis are supported, e.g.
  *                  "CONFIG_X86_INTEL_UMIP=y | CONFIG_X86_UIMP=y" is evaluated
  *                  to true if at least one of the options is present.
+ *                  For some config options their presence in the config file
+ *                  is not enough to assure the functionality is present or
+ *                  enabled. E.g. config option may be set to 'm' but the
+ *                  module may not be installed or functionality may be
+ *                  disabled on the kernel command line. The kconfig library
+ *                  has a set of additonal checks for a few config options that

s/additonal/additional/

include/tst_test.h struct tst_fs { · line 520

Quoted 1 line
include/tst_test.h +1 -0
+ *                  are used in the tests and need additional checks.

(Please consider configuring spell checker in your editor setup, or run make check as I enabled in our checkpatch.pl configuration check for typos.)

AI would reword it, feel free to use some parts or ignore:

For some config options their presence in the config file is not enough to assure the functionality is present or enabled. E.g. config option may be set to 'm' but the module may not be installed or functionality may be disabled on the kernel command line.

The kconfig library has a set of additional checks for a few config options that are used in the tests and need additional checks. Please rebase before adding the text (I fixed typo in include/tst_test.h).

The removal is obviously ok.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#47 lore raw

Re: [LTP] [PATCH 16/17] lib: tst_test: Remove now unused needs_drivers

Hi!

Quoted 10 lines

(Please consider configuring spell checker in your editor setup, or run make check as I enabled in our checkpatch.pl configuration check for typos.)

AI would reword it, feel free to use some parts or ignore:

For some config options their presence in the config file is not enough to assure the functionality is present or enabled. E.g. config option may be set to 'm' but the module may not be installed or functionality may be disabled on the kernel command line.

The kconfig library has a set of additional checks for a few config options that are used in the tests and need additional checks. Please rebase before adding the text (I fixed typo in include/tst_test.h).

I've already agreed to use the version from Li.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#48 lore raw

PATCH 17/17 doc: metadata: Remove needs_drivers from docs

In reply to Cyril Hrubis
---
 doc/developers/writing_tests.rst |  3 ---
 doc/old/C-Test-API.asciidoc      | 13 ++++++-------
 metadata/README.md               | 15 ++++++---------
 3 files changed, 12 insertions(+), 19 deletions(-)
doc/developers/writing_tests.rst +0 -3
index 992374f8b..5b1516ba5 100644
@@ -435,9 +435,6 @@ LTP C And Shell Test API Comparison
     * - .needs_device
       - TST_NEEDS_DEVICE
 
-    * - .needs_drivers
-      - TST_NEEDS_DRIVERS
-
     * - .needs_kconfigs
       - TST_NEEDS_KCONFIGS
 
doc/old/C-Test-API.asciidoc +6 -7
index 72fd2731d..7493fc578 100644
@@ -1621,13 +1621,12 @@ test should include 'tst_checksum.h' header, then can call 'tst_crc32c()'.
 1.26 Checking kernel for the driver support
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-Some tests may need specific kernel drivers, either compiled in, or built
-as a module. If '.needs_drivers' points to a 'NULL' terminated array of kernel
-module names these are all checked and the test exits with 'TCONF' on the
-first missing driver.
-
-The detection is based on reading 'modules.dep' and 'modules.builtin' files
-generated by kmod. The check is skipped on Android.
+Some tests may need specific kernel drivers, either compiled in, or built as a
+module. For this cases a mappping of kernel config options to modules is
+maintained in the kconfig checker. When a kernel config option is requested by
+a test that has associated mapping in the kconfig source the 'modules.dep' file
+is checked for module presence when the option is set to 'm'. The check is
+skipped on Android.
 
 1.27 Saving & restoring /proc|sys values
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
metadata/README.md +6 -9
index 2cf978d39..950e49f6e 100644
@@ -144,15 +144,14 @@ struct tst_test test = {
 	/* Indicates that the test is messing with system wall clock */
 	.restore_wallclock = 1,
 
-	/* Tests needs uinput either compiled in or loaded as a module */
-	.needs_drivers = (const char *[]) {
-		"uinput",
-		NULL
-	},
-
 	/* Tests needs enabled kernel config flags */
 	.needs_kconfigs = (const char *[]) {
 		"CONFIG_X86_INTEL_UMIP=y",
+        /*
+         * For config options that enable modules we also check the presence of
+         * the module if the config option has module mapping set and is set to 'm'.
+         */
+        "CONFIG_INPUT_UINPUT",
 		NULL
 	},
 
@@ -185,11 +184,9 @@ Which will yield following JSON output:
   "dev_min_size": "1024",
   "dev_fs_type": "ext4",
   "restore_wallclock": "1",
-  "needs_drivers": [
-    "uinput",
-  ],
   "needs_kconfigs": [
     "CONFIG_X86_INTEL_UMIP=y",
+    "CONFIG_INPUT_UINPUT",
   ],
   "tags": [
     [
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v1 17/17
#49 lore raw

Re: [LTP] [PATCH 17/17] doc: metadata: Remove needs_drivers from docs

Quoted 12 lines
---
 doc/developers/writing_tests.rst |  3 ---
 doc/old/C-Test-API.asciidoc      | 13 ++++++-------
 metadata/README.md               | 15 ++++++---------
 3 files changed, 12 insertions(+), 19 deletions(-)
doc/developers/writing_tests.rst +0 -0
index 992374f8b..5b1516ba5 100644

doc/developers/writing_tests.rst LTP C And Shell Test API Comparison · line 440

Quoted 6 lines
doc/developers/writing_tests.rst +0 -3
@@ -435,9 +435,6 @@ LTP C And Shell Test API Comparison
     * - .needs_device
       - TST_NEEDS_DEVICE
 
-    * - .needs_drivers
-      - TST_NEEDS_DRIVERS
-

NOTE: this is the old comparison for tst_test.sh, it should be change:

- * - not applicable
- - TST_NEEDS_DRIVERS

Quoted 11 lines
doc/developers/writing_tests.rst +0 -0
     * - .needs_kconfigs
       - TST_NEEDS_KCONFIGS
 
doc/old/C-Test-API.asciidoc +0 -0
index 72fd2731d..7493fc578 100644
@@ -1621,13 +1621,12 @@ test should include 'tst_checksum.h' header, then can call 'tst_crc32c()'.
 1.26 Checking kernel for the driver support
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

doc/old/C-Test-API.asciidoc test should include 'tst_checksum.h' header, then can call 'tst_crc32c()'. · line 1626

Quoted 10 lines
doc/old/C-Test-API.asciidoc +3 -7
-Some tests may need specific kernel drivers, either compiled in, or built
-as a module. If '.needs_drivers' points to a 'NULL' terminated array of kernel
-module names these are all checked and the test exits with 'TCONF' on the
-first missing driver.
-
-The detection is based on reading 'modules.dep' and 'modules.builtin' files
-generated by kmod. The check is skipped on Android.
+Some tests may need specific kernel drivers, either compiled in, or built as a
+module. For this cases a mappping of kernel config options to modules is
+maintained in the kconfig checker. When a kernel config option is requested by

Please amend before merge to use formatting:
``modules.dep``

doc/old/C-Test-API.asciidoc test should include 'tst_checksum.h' header, then can call 'tst_crc32c()'. · line 1628

Quoted 2 lines
doc/old/C-Test-API.asciidoc +2 -0
+a test that has associated mapping in the kconfig source the 'modules.dep' file
+is checked for module presence when the option is set to 'm'. The check is

... set to ``m``.

doc/old/C-Test-API.asciidoc test should include 'tst_checksum.h' header, then can call 'tst_crc32c()'. · line 1629

Quoted 1 line
doc/old/C-Test-API.asciidoc +1 -0
+skipped on Android.

The rest LGTM.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on the v1 series
#50 lore raw
In reply to Cyril Hrubis

Hi Cyril,

Quoted 3 lines

The needs_drivers and needs_kconfigs options had overlapping functionality. This patchset gets rid of needs_drivers by adding module checks to needs_kconfigs.

to whole patchset:

Besides few notes I posted the main concern is whether to move to reading /sys/module/ at least for loadable modules. OTOH it can be done as a separate effort.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp