[i-g-t 3/4] lib/igt_core: Modify file opening logic to use IMGDIR environment variable
Naladala Ramanaidu
ramanaidu.naladala at intel.com
Wed Aug 7 09:12:01 UTC 2024
Modified __igt_fopen_data function to enhance file opening logic by
incorporating the IMGDIR environment variable.
- Added a new variable 'abpath' to store the value of IMGDIR.
- Updated the path construction to use IMGDIR if available.
- Implemented a fallback mechanism to use igt_datadir if the file is
not found in IMGDIR.
- Ensured the existing fallback to igt_srcdir remains intact.
Signed-off-by: Naladala Ramanaidu <ramanaidu.naladala at intel.com>
---
lib/igt_core.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 3ff3e0392..9b11c0850 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -3241,9 +3241,15 @@ FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
{
char path[PATH_MAX];
FILE *fp;
+ char *abpath;
- snprintf(path, sizeof(path), "%s/%s", igt_datadir, filename);
+ abpath = getenv("IMGDIR");
+ snprintf(path, sizeof(path), "%s/%s", abpath, filename);
fp = fopen(path, "r");
+ if (!fp) {
+ snprintf(path, sizeof(path), "%s/%s", igt_datadir, filename);
+ fp = fopen(path, "r");
+ }
if (!fp) {
snprintf(path, sizeof(path), "%s/%s", igt_srcdir, filename);
fp = fopen(path, "r");
--
2.43.0
More information about the Intel-gfx-trybot
mailing list