[PATCH i-g-t 2/6] lib: update fopen() to accomodate imgdir
Swati Sharma
swati2.sharma at intel.com
Mon Sep 23 07:10:19 UTC 2024
From: "Naladala, Ramanaidu" <ramanaidu.naladala at intel.com>
Update fopen() to accomodate imgage directory path. Tests like kms_3d
use this function while creating fb from png image.
Signed-off-by: Ramanaidu Naladala <ramanaidu.naladala at intel.com>
Signed-off-by: Swati Sharma <swati2.sharma at intel.com>
---
lib/igt_core.c | 10 ++++++++--
lib/igt_core.h | 4 ++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 407f7b551..1a7798d92 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -3306,7 +3306,7 @@ void igt_reset_timeout(void)
}
FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
- const char* filename)
+ const char* igt_imgdir, const char* filename)
{
char path[PATH_MAX];
FILE *fp;
@@ -3317,8 +3317,14 @@ FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
snprintf(path, sizeof(path), "%s/%s", igt_srcdir, filename);
fp = fopen(path, "r");
}
+
+ if (!fp) {
+ snprintf(path, sizeof(path), "%s/%s", igt_imgdir, filename);
+ fp = fopen(path, "r");
+ }
+
if (!fp) {
- snprintf(path, sizeof(path), "./%s", filename);
+ snprintf(path, sizeof(path), "./data/%s", filename);
fp = fopen(path, "r");
}
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 90f57402f..5b058a8d0 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -1457,7 +1457,7 @@ static inline uint32_t igt_seconds_elapsed(struct timespec *start)
void igt_reset_timeout(void);
FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
- const char* filename);
+ const char* igt_imgdir, const char* filename);
/**
* igt_fopen_data:
* @filename: filename to open.
@@ -1466,7 +1466,7 @@ FILE *__igt_fopen_data(const char* igt_srcdir, const char* igt_datadir,
* then from build directory, and finally from current directory.
*/
#define igt_fopen_data(filename) \
- __igt_fopen_data(IGT_SRCDIR, IGT_DATADIR, filename)
+ __igt_fopen_data(IGT_SRCDIR, IGT_DATADIR, IGT_IMGDIR, filename)
int igt_system(const char *command);
int igt_system_quiet(const char *command);
--
2.25.1
More information about the igt-dev
mailing list