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_res { 10 char match; 11 char *value; 12 }; 13 14 /** 15 * Reads a kernel config and parses it for values defined in kconfigs array. 16 * 17 * The path to the kernel config should be autodetected in most of the cases as 18 * the code looks for know locations. It can be explicitely set/overrided with 19 * the KCONFIG_PATH environment variable as well. 20 * 21 * The kcofings array is expected to contain strings in a format "CONFIG_FOO" 22 * or "CONFIG_FOO=bar". The result array has to be suitably sized to fit the 23 * results. 24 * 25 * @param kconfigs array of config strings to look for 26 * @param results array to store results to 27 * @param cnt size of the arrays 28 * 29 * The match in the tst_kconfig_res structure is 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 value points to a newly allocated 38 * string that holds the value. 39 */ 40 void tst_kconfig_read(const char *const kconfigs[], 41 struct tst_kconfig_res results[], size_t cnt); 42 43 /** 44 * Checks if required kernel configuration options are set in the kernel 45 * config and exits the test with TCONF if at least one is missing. 46 * 47 * The config options can be passed in two different formats, either 48 * "CONFIG_FOO" in which case the option has to be set in order to continue the 49 * test or with an explicit value "CONFIG_FOO=bar" in which case the value has 50 * to match. 51 * 52 * @param kconfigs NULL-terminated array of config strings needed for the testrun. 53 */ 54 void tst_kconfig_check(const char *const kconfigs[]); 55 56 #endif /* TST_KCONFIG_H__ */ 57