[Piglit] [PATCH 1/2] built-in-constants.c: Fail test if file cannot be opened

Dylan Baker baker.dylan.c at gmail.com
Mon Sep 8 22:06:35 PDT 2014


built-in-constants relies on a file being passed to it describing the
tests to run. If this file does not exist the program will segfault.
This patch adds the appropriate check after calling
piglit_load_text_file to check for a NULL value and fail if it is.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 tests/shaders/built-in-constants.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/shaders/built-in-constants.c b/tests/shaders/built-in-constants.c
index 0bfe2c1..5d4bc69 100644
--- a/tests/shaders/built-in-constants.c
+++ b/tests/shaders/built-in-constants.c
@@ -191,6 +191,11 @@ parse_file(const char *filename)
 	char *end_of_line;
 	ptrdiff_t len;
 
+	if (line == NULL) {
+		fprintf(stderr, "could not read file \"%s\"\n", filename);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+
 	/* The format of the test file is:
 	 *
 	 * major.minor
-- 
2.1.0



More information about the Piglit mailing list