Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Reddy Guddati, Santhosh" <santhosh.reddy.guddati@intel.com>
To: <igt-dev@lists.freedesktop.org>
Subject: Re: [PATCH 4/5] lib: update fopen() to accomodate imgdir
Date: Wed, 20 Nov 2024 08:36:40 +0530	[thread overview]
Message-ID: <bbadfcdf-dabe-4b55-a671-9b4cdea27167@intel.com> (raw)
In-Reply-To: <20241119075259.3048734-5-ramanaidu.naladala@intel.com>

Hi Rama,

On 19-11-2024 13:22, Naladala Ramanaidu wrote:
> 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 | 17 +++++++++++++++--
>   lib/igt_core.h |  4 ++--
>   2 files changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index 407f7b551..8dae8f51d 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -3306,10 +3306,11 @@ 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;
> +	char *abpath;
>   
>   	snprintf(path, sizeof(path), "%s/%s", igt_datadir, filename);
>   	fp = fopen(path, "r");
> @@ -3317,8 +3318,20 @@ 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) {
> +		abpath = getenv("IMGDIR");
 >> check for the return value of getenv before usig abpath.
	if (abpath) {}
> +                snprintf(path, sizeof(path), "%s/%s", abpath, filename);
> +                fp = fopen(path, "r");
> +        }
> +
>   	if (!fp) {
> -		snprintf(path, sizeof(path), "./%s", filename);
> +		snprintf(path, sizeof(path), "./data/%s", filename);
>   		fp = fopen(path, "r");
>   	}
 >> Also , imo It would be better to move the repeated code for 
constructing path to a seperate helper function.
>   
> 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);


  reply	other threads:[~2024-11-20  3:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-19  7:52 [PATCH 0/5] Update image assets Naladala Ramanaidu
2024-11-19  7:52 ` [PATCH 1/5] data: create new data directory Naladala Ramanaidu
2024-12-11  9:25   ` Kamil Konieczny
2024-11-19  7:52 ` [PATCH 2/5] runner/settings: Update absolute_path function to accept const char* parameter Naladala Ramanaidu
2024-11-19  7:52 ` [PATCH 3/5] runner/settings: Add function to set IMGDIR environment variable Naladala Ramanaidu
2024-12-11  9:14   ` Kamil Konieczny
2024-12-13 13:10     ` Sharma, Swati2
2024-11-19  7:52 ` [PATCH 4/5] lib: update fopen() to accomodate imgdir Naladala Ramanaidu
2024-11-20  3:06   ` Reddy Guddati, Santhosh [this message]
2024-11-19  7:52 ` [PATCH 5/5] HAX patch do not merge Naladala Ramanaidu
2024-11-19 22:42 ` ✗ GitLab.Pipeline: warning for Update image assets Patchwork
2024-11-19 22:45 ` ✗ CI.xeBAT: failure " Patchwork
2024-11-19 23:04 ` ✗ Fi.CI.BAT: " Patchwork
2024-11-20 11:14 ` ✗ CI.xeFULL: " Patchwork

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=bbadfcdf-dabe-4b55-a671-9b4cdea27167@intel.com \
    --to=santhosh.reddy.guddati@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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