xref: /aosp_15_r20/external/ltp/include/tst_kernel.h (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright (c) 2017 Cyril Hrubis <[email protected]>
3  * Copyright (c) Linux Test Project, 2018-2024
4  */
5 
6 #ifndef TST_KERNEL_H__
7 #define TST_KERNEL_H__
8 
9 #include <stdbool.h>
10 
11 /**
12  * tst_kernel_bits() - Detect if running on 32bit or 64bit kernel.
13  *
14  * Return: 32 if the test process is running on 32bit kernel and 64 if on 64bit
15  * kernel.
16  */
17 int tst_kernel_bits(void);
18 
19 /**
20  * tst_is_compat_mode() - Detect if running in compat mode.
21  *
22  * Detect if the test is 32bit binary executed on a 64bit kernel,
23  * i.e. we are testing the kernel compat layer.
24  *
25  * Return: non-zero if the test process is running in compat mode.
26  */
27 int tst_is_compat_mode(void);
28 
29 /**
30  * tst_abi_bits() - Detect if compiled for required kernel ABI.
31  *
32  * @abi: kernel ABI bits (32 or 64).
33  *
34  * Return: true if compiled for required ABI or false otherwise.
35  */
36 bool tst_abi_bits(int abi);
37 
38 /**
39  * tst_check_builtin_driver() - Check if the kernel module is built-in.
40  *
41  * @driver: the name of the driver.
42  *
43  * Return: 0 if builtin driver or -1 when driver is missing or config file not
44  * available. On Android *always* 0 (always expect the driver is available).
45  */
46 int tst_check_builtin_driver(const char *driver);
47 
48 /**
49  * tst_check_driver() - Check support for the kernel module.
50  *
51  * Check support for the kernel module (both built-in and loadable).
52  *
53  * @driver: the name of the driver.
54  *
55  * Return: 0 if the kernel has the driver, -1 when driver is missing or config
56  * file not available. On Android *always* 0 (always expect the driver is
57  * available).
58  */
59 int tst_check_driver(const char *driver);
60 
61 #endif	/* TST_KERNEL_H__ */
62