[PATCH RESEND i-g-t v4 30/31] lib/igt_core: move igt_load_igtrc to igt_rc
Sebastian Brzezinka <[email protected]> Wed, 29 Jul 2026 13:03:47 +0200
| Newsgroups | org.freedesktop.lists.igt-dev |
|---|---|
| Message-ID | <dc06fc3a7bbec6314046d0cc9f2294853beef539.1785152675.git.sebastian.brzezinka@intel.com> |
igt_load_igtrc() reads device configuration from the igtrc file and is used by igt_core, igt_chamelium(_stream), the runner and lsgpu. The associated global, igt_key_file, is already declared in lib/igt_rc.h, so move the loader implementation there too instead of igt_core.c. Signed-off-by: Sebastian Brzezinka <[email protected]> Reviewed-by: Krzysztof Karas <[email protected]> --- lib/igt_core.c | 47 ----------------------------------- lib/igt_core.h | 2 -- lib/igt_rc.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_rc.h | 2 ++ lib/meson.build | 4 ++- runner/executor.c | 1 + 6 files changed, 68 insertions(+), 50 deletions(-) create mode 100644 lib/igt_rc.c diff --git a/lib/igt_core.c b/lib/igt_core.c index a7c097d9e..2f737b01a 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -972,53 +972,6 @@ static void oom_adjust_for_doom(void) } -/** - * load_igtrc: - * - * Load .igtrc from the path pointed to by #IGT_CONFIG_PATH or from - * home directory if that is not set. The returned keyfile needs to be - * deallocated using g_key_file_free(). - * - * Returns: Pointer to the keyfile, NULL on error. - */ -GKeyFile *igt_load_igtrc(void) -{ - char *key_file_env = NULL; - char *key_file_loc = NULL; - GError *error = NULL; - GKeyFile *file; - int ret; - - /* Determine igt config path */ - key_file_env = getenv("IGT_CONFIG_PATH"); - if (key_file_env) { - key_file_loc = key_file_env; - } else { - key_file_loc = malloc(100); - snprintf(key_file_loc, 100, "%s/.igtrc", g_get_home_dir()); - } - - /* Load igt config file */ - file = g_key_file_new(); - ret = g_key_file_load_from_file(file, key_file_loc, - G_KEY_FILE_NONE, &error); - if (!ret) { - g_error_free(error); - g_key_file_free(file); - file = NULL; - - goto out; - } - - g_clear_error(&error); - - out: - if (!key_file_env && key_file_loc) - free(key_file_loc); - - return file; -} - static void common_init_config(void) { GError *error = NULL; diff --git a/lib/igt_core.h b/lib/igt_core.h index 3337293bc..afaf35aa8 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -95,8 +95,6 @@ extern const char* __igt_test_description __attribute__((weak)); extern bool __igt_plain_output; extern char *igt_frame_dump_path; -struct _GKeyFile *igt_load_igtrc(void); - /** * IGT_TEST_DESCRIPTION: * @str: description string diff --git a/lib/igt_rc.c b/lib/igt_rc.c new file mode 100644 index 000000000..b7f1731fe --- /dev/null +++ b/lib/igt_rc.c @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright © 2026 Intel Corporation + */ + +#include <stdio.h> +#include <stdlib.h> + +#ifndef ANDROID +#include <glib.h> +#else +#include "android/glib.h" +#endif + +#include "igt_rc.h" + +/** + * igt_load_igtrc: + * + * Load .igtrc from the path pointed to by #IGT_CONFIG_PATH or from + * home directory if that is not set. The returned keyfile needs to be + * deallocated using g_key_file_free(). + * + * Returns: Pointer to the keyfile, NULL on error. + */ +GKeyFile *igt_load_igtrc(void) +{ + char *key_file_env = NULL; + char *key_file_loc = NULL; + GError *error = NULL; + GKeyFile *file; + int ret; + + /* Determine igt config path */ + key_file_env = getenv("IGT_CONFIG_PATH"); + if (key_file_env) { + key_file_loc = key_file_env; + } else { + key_file_loc = malloc(100); + snprintf(key_file_loc, 100, "%s/.igtrc", g_get_home_dir()); + } + + /* Load igt config file */ + file = g_key_file_new(); + ret = g_key_file_load_from_file(file, key_file_loc, + G_KEY_FILE_NONE, &error); + if (!ret) { + g_error_free(error); + g_key_file_free(file); + file = NULL; + + goto out; + } + + g_clear_error(&error); + + out: + if (!key_file_env && key_file_loc) + free(key_file_loc); + + return file; +} diff --git a/lib/igt_rc.h b/lib/igt_rc.h index d871b3b26..3b7179808 100644 --- a/lib/igt_rc.h +++ b/lib/igt_rc.h @@ -33,4 +33,6 @@ extern GKeyFile *igt_key_file; +struct _GKeyFile *igt_load_igtrc(void); + #endif /* IGT_RC_H */ diff --git a/lib/meson.build b/lib/meson.build index aa8eae68b..9bd484c98 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -37,6 +37,7 @@ lib_sources = [ 'igt_os.c', 'igt_params.c', 'igt_perf.c', + 'igt_rc.c', 'igt_pipe_crc.c', 'igt_power.c', 'igt_primes.c', @@ -379,8 +380,9 @@ lib_igt_device_scan_build = static_library('igt_device_scan', 'igt_map.c', 'intel_device_info.c', 'intel_cmds_info.c', + 'igt_rc.c', ], - dependencies : [scan_dep, lib_igt_drm_stub, lib_igt_tools_stub], + dependencies : [scan_dep, lib_igt_drm_stub, lib_igt_tools_stub, glib], include_directories : inc) lib_igt_device_scan = declare_dependency(link_with : lib_igt_device_scan_build, diff --git a/runner/executor.c b/runner/executor.c index a8907c575..1592feee2 100644 --- a/runner/executor.c +++ b/runner/executor.c @@ -36,6 +36,7 @@ #include "igt_aux.h" #include "igt_core.h" #include "igt_facts.h" +#include "igt_rc.h" #include "igt_taints.h" #include "igt_vec.h" #include "executor.h" -- 2.53.0