[PATCH 3/5] runner/settings: Add function to set IMGDIR environment variable
Naladala Ramanaidu
ramanaidu.naladala at intel.com
Tue Nov 19 07:52:57 UTC 2024
Introduced set_imgdir() function in settings.c to set the IMGDIR
environment variable. The function uses absolute_path() to convert
the relative path "../share/igt-gpu-tools" to an absolute path.
Added the declaration of set_imgdir() in settings.h with a brief
description.
Signed-off-by: Naladala Ramanaidu <ramanaidu.naladala at intel.com>
---
runner/runner.c | 2 ++
runner/settings.c | 13 +++++++++++++
runner/settings.h | 8 ++++++++
3 files changed, 23 insertions(+)
diff --git a/runner/runner.c b/runner/runner.c
index 4855ad641..a52834197 100644
--- a/runner/runner.c
+++ b/runner/runner.c
@@ -49,6 +49,8 @@ int main(int argc, char **argv)
exitcode = 1;
}
+ unsetenv("IMGDIR");
+
printf("Done.\n");
return exitcode;
}
diff --git a/runner/settings.c b/runner/settings.c
index dd4b08dd7..d42f3a68a 100644
--- a/runner/settings.c
+++ b/runner/settings.c
@@ -587,6 +587,15 @@ char *absolute_path(const char *path)
return result;
}
+int set_imgdir(void)
+{
+ const char *path = "../share/igt-gpu-tools";
+ char *abpath;
+
+ abpath = absolute_path(path);
+ return setenv("IMGDIR", abpath, 1);
+}
+
static char *bin_path(char *fname)
{
char *path, *p;
@@ -863,6 +872,10 @@ bool parse_options(int argc, char **argv,
settings->test_root = absolute_path(env_test_root);
}
+ if (set_imgdir() != 0) {
+ usage(stderr, "img dir not set");
+ }
+
if (!settings->test_root) {
usage(stderr, "Test root not set");
goto error;
diff --git a/runner/settings.h b/runner/settings.h
index 6246d0c3d..a7abe19fd 100644
--- a/runner/settings.h
+++ b/runner/settings.h
@@ -150,4 +150,12 @@ bool serialize_settings(struct settings *settings);
bool read_settings_from_file(struct settings *settings, FILE* f);
bool read_settings_from_dir(struct settings *settings, int dirfd);
+/**
+ * set_imgdir:
+ *
+ * The function will set the environment variable.
+ *
+ */
+int set_imgdir(void);
+
#endif
--
2.43.0
More information about the igt-dev
mailing list