[PATCH] Allow to override the source directory in runtime via an env var.

José Fonseca jfonseca at vmware.com
Mon May 10 11:42:30 PDT 2010


This allows to decouple building piglit from the testing with
piglit.
---
 tests/util/piglit-util.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index e0d7b1a..34cbee9 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -398,15 +398,22 @@ piglit_compile_shader(GLenum target, char *filename)
 	int err;
 	GLchar *prog_string;
 	FILE *f;
+	const char *source_dir;
 	char filename_with_path[FILENAME_MAX];
 
+	source_dir = getenv("PIGLIT_SOURCE_DIR");
+	if (source_dir == NULL) {
+		source_dir = SOURCE_DIR;
+	}
+
 	snprintf(filename_with_path, FILENAME_MAX - 1,
-		 "%stests/%s", SOURCE_DIR, filename);
+		 "%s/tests/%s", source_dir, filename);
 	filename_with_path[FILENAME_MAX - 1] = 0;
 
 	err = stat(filename_with_path, &st);
 	if (err == -1) {
 		fprintf(stderr, "Couldn't stat program %s: %s\n", filename, strerror(errno));
+		fprintf(stderr, "You can override the source dir by setting the PIGLIT_SOURCE_DIR environment variable.\n");
 		exit(1);
 	}
 
-- 
1.7.0.3


--=-FEkmHSXPG3C7Dt3KEIWN--



More information about the Piglit mailing list