diff mbox series

[1/4] tst_kernel: Add safe_check_driver()

Message ID 20231013074748.702214-2-pvorel@suse.cz
State Changes Requested
Headers show
Series Add .modprobe (loading modules in C API) | expand

Commit Message

Petr Vorel Oct. 13, 2023, 7:47 a.m. UTC
And use it in tst_test.c. It will be more reused in the next commit.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 include/tst_kernel.h | 9 +++++++++
 lib/tst_kernel.c     | 6 ++++++
 lib/tst_test.c       | 3 +--
 3 files changed, 16 insertions(+), 2 deletions(-)

Comments

Petr Vorel Oct. 13, 2023, 12:24 p.m. UTC | #1
Hi All,

...
>  int tst_check_driver(const char *driver);

> +/*
> + * Checks support for the kernel module (both built-in and loadable)
> + * and exit with TCONF if driver not available.
> + *
> + * @param driver The name of the driver.
> + * On Android it *always* passes (always expect the driver is available).
> + */
> +void safe_check_driver(const char *driver);

In the end, I haven't used this function in the second commit,
thus this function is useless (used only on single place).
I'll remove it in v2 (still waiting for more input if whole .modprobe option is
worth of merging).

Kind regards,
Petr

> +
>  #endif	/* TST_KERNEL_H__ */
> diff --git a/lib/tst_kernel.c b/lib/tst_kernel.c
> index 4b75ceadb..de4c28308 100644
> --- a/lib/tst_kernel.c
> +++ b/lib/tst_kernel.c
> @@ -198,3 +198,9 @@ int tst_check_driver(const char *driver)

>  	return -1;
>  }
> +
> +void safe_check_driver(const char *driver)
> +{
> +	if (tst_check_driver(driver))
> +		tst_brkm(TCONF, NULL, "%s driver not available", driver);
> +}
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index c2f8f503f..087c62a16 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -1191,8 +1191,7 @@ static void do_setup(int argc, char *argv[])
>  		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);
> +			safe_check_driver(name);
>  	}

>  	if (tst_test->mount_device)
diff mbox series

Patch

diff --git a/include/tst_kernel.h b/include/tst_kernel.h
index 9d3a8d315..8caf3f733 100644
--- a/include/tst_kernel.h
+++ b/include/tst_kernel.h
@@ -30,4 +30,13 @@  int tst_check_builtin_driver(const char *driver);
  */
 int tst_check_driver(const char *driver);
 
+/*
+ * Checks support for the kernel module (both built-in and loadable)
+ * and exit with TCONF if driver not available.
+ *
+ * @param driver The name of the driver.
+ * On Android it *always* passes (always expect the driver is available).
+ */
+void safe_check_driver(const char *driver);
+
 #endif	/* TST_KERNEL_H__ */
diff --git a/lib/tst_kernel.c b/lib/tst_kernel.c
index 4b75ceadb..de4c28308 100644
--- a/lib/tst_kernel.c
+++ b/lib/tst_kernel.c
@@ -198,3 +198,9 @@  int tst_check_driver(const char *driver)
 
 	return -1;
 }
+
+void safe_check_driver(const char *driver)
+{
+	if (tst_check_driver(driver))
+		tst_brkm(TCONF, NULL, "%s driver not available", driver);
+}
diff --git a/lib/tst_test.c b/lib/tst_test.c
index c2f8f503f..087c62a16 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1191,8 +1191,7 @@  static void do_setup(int argc, char *argv[])
 		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);
+			safe_check_driver(name);
 	}
 
 	if (tst_test->mount_device)