• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2018 Cyril Hrubis <chrubis@suse.cz>
4  */
5 
6 #ifndef TST_KCONFIG_H__
7 #define TST_KCONFIG_H__
8 
9 struct tst_kconfig_var {
10 	char id[64];
11 	unsigned int id_len;
12 	char choice;
13 	char *val;
14 };
15 
16 /**
17  *
18  * Reads a kernel config, parses it and writes results into an array of
19  * tst_kconfig_var structures.
20  *
21  * The path to the kernel config should be autodetected in most of the cases as
22  * the code looks for know locations. It can be explicitely set/overrided with
23  * the KCONFIG_PATH environment variable as well.
24  *
25  * The caller has to initialize the tst_kconfig_var structure. The id has to be
26  * filled with config variable name such as 'CONFIG_FOO', the id_len should
27  * hold the id string length and the choice and val has to be zeroed.
28  *
29  * After a call to this function each choice be set as follows:
30  *
31  *  'm' - config option set to m
32  *  'y' - config option set to y
33  *  'v' - config option set to other value
34  *  'n' - config option is not set
35  *   0  - config option not found
36  *
37  * In the case that match is set to 'v' the val pointer points to a newly
38  * allocated string that holds the value.
39  *
40  * @param vars An array of caller initalized tst_kconfig_var structures.
41  * @param vars_len Length of the vars array.
42  */
43 void tst_kconfig_read(struct tst_kconfig_var vars[], size_t vars_len);
44 
45 /**
46  * Checks if required kernel configuration options are set in the kernel
47  * config. Return 0 if every config is satisfied and return 1 if at least
48  * one is missing.
49  *
50  * The config options can be passed in two different formats, either
51  * "CONFIG_FOO" in which case the option has to be set in order to continue the
52  * test or with an explicit value "CONFIG_FOO=bar" in which case the value has
53  * to match.
54  *
55  * @param kconfigs NULL-terminated array of config strings needed for the testrun.
56  */
57 int tst_kconfig_check(const char *const kconfigs[]);
58 
59 #endif	/* TST_KCONFIG_H__ */
60