Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Swati Sharma <swati2.sharma@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Naladala, Ramanaidu" <ramanaidu.naladala@intel.com>,
	Swati Sharma <swati2.sharma@intel.com>
Subject: [PATCH i-g-t 2/6] lib: update fopen() to accomodate imgdir
Date: Mon, 23 Sep 2024 12:40:19 +0530	[thread overview]
Message-ID: <20240923071023.1170127-3-swati2.sharma@intel.com> (raw)
In-Reply-To: <20240923071023.1170127-1-swati2.sharma@intel.com>

From: "Naladala, Ramanaidu" <ramanaidu.naladala@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@intel.com>
Signed-off-by: Swati Sharma <swati2.sharma@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


  parent reply	other threads:[~2024-09-23  7:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-23  7:10 [PATCH i-g-t 0/6] New sharpness tool Swati Sharma
2024-09-23  7:10 ` [PATCH i-g-t 1/6] data: create new data directory Swati Sharma
2024-09-23  7:10 ` Swati Sharma [this message]
2024-10-14 14:26   ` [PATCH i-g-t 2/6] lib: update fopen() to accomodate imgdir Kamil Konieczny
2024-09-23  7:10 ` [PATCH i-g-t 3/6] [HAX] lib/igt_kms: Added "sharpness strength" as crtc property Swati Sharma
2024-09-23  7:10 ` [PATCH i-g-t 4/6] tools: Add new sharpness tool Swati Sharma
2024-09-23  7:10 ` [PATCH i-g-t 6/6] meson: Add " Swati Sharma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240923071023.1170127-3-swati2.sharma@intel.com \
    --to=swati2.sharma@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=ramanaidu.naladala@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox