[i-g-t 2/4] runner/settings: Add function to set IMGDIR environment variable

Naladala Ramanaidu ramanaidu.naladala at intel.com
Wed Aug 7 09:12:00 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/settings.c | 13 +++++++++++++
 runner/settings.h |  8 ++++++++
 2 files changed, 21 insertions(+)

diff --git a/runner/settings.c b/runner/settings.c
index 08a78ad02..1ead11c07 100644
--- a/runner/settings.c
+++ b/runner/settings.c
@@ -571,6 +571,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;
@@ -832,6 +841,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 16b45147b..8a41370ae 100644
--- a/runner/settings.h
+++ b/runner/settings.h
@@ -148,4 +148,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 Intel-gfx-trybot mailing list