[Piglit] [PATCH 4/4] cl: Have program-tester report subtest results

Tom Stellard tom at stellard.net
Wed Dec 5 10:00:21 PST 2012


From: Tom Stellard <thomas.stellard at amd.com>

---
 tests/cl/program/program-tester.c | 38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/tests/cl/program/program-tester.c b/tests/cl/program/program-tester.c
index 645691e..ec7fc91 100644
--- a/tests/cl/program/program-tester.c
+++ b/tests/cl/program/program-tester.c
@@ -269,6 +269,8 @@ struct test {
 
 	unsigned int num_args_out;
 	struct test_arg* args_out;
+
+	enum piglit_result result;
 };
 
 unsigned int num_tests = 0;
@@ -1106,6 +1108,21 @@ get_test_arg(const char* src, struct test* test, bool arg_in)
 	}
 }
 
+/**
+ * Helper function for parsing a test name and checking for illegal characters.
+ */
+static char*
+parse_name(const char *input)
+{
+	char *name = add_dynamic_str_copy(input);
+	if (strrchr(name, '/')) {
+		fprintf(stderr,	"Illegal character in test name '%s': /\n",
+								input);
+		return NULL;
+	}
+	return name;
+}
+
 void
 parse_config(const char* config_str,
              struct piglit_cl_program_test_config* config)
@@ -1253,7 +1270,10 @@ parse_config(const char* config_str,
 				break;
 			case SECTION_CONFIG:
 				if(regex_match(key, "^name$")) {
-					config->name = add_dynamic_str_copy(value);
+					config->name = parse_name(value);
+					if (!config->name) {
+						exit_report_result(PIGLIT_FAIL);
+					}
 				} else if(regex_match(key, "^clc_version_min$")) {
 					config->clc_version_min = get_int(value);
 				} else if(regex_match(key, "clc_version_max$")) {
@@ -1318,7 +1338,10 @@ parse_config(const char* config_str,
 				break;
 			case SECTION_TEST:
 				if(regex_match(key, "^name$")) {
-					test->name = add_dynamic_str_copy(value);
+					test->name = parse_name(value);
+					if (!test->name) {
+						exit_report_result(PIGLIT_FAIL);
+					}
 				} else if(regex_match(key, "^kernel_name$")) {
 					test->kernel_name = add_dynamic_str_copy(value); // test can't have kernel_name == NULL like config section
 				} else if(regex_match(key, "^expect_test_fail$")) {
@@ -1920,6 +1943,7 @@ piglit_cl_test(const int argc,
 
 		test_result = test_kernel(config, env, tests[i]);
 		piglit_merge_result(&result, test_result);
+		tests[i].result = test_result;
 
 		switch(test_result) {
 		case PIGLIT_FAIL:
@@ -1955,5 +1979,15 @@ piglit_cl_test(const int argc,
 		}
 	}
 
+	printf("PIGLIT: { 'subtests' : {");
+	for (i = 0; i < num_tests; i++) {
+		printf("'%s' : '%s'", tests[i].name,
+				piglit_result_to_string(tests[i].result));
+		if (i != num_tests - 1) {
+			printf(",");
+		}
+	}
+	printf("}}\n");
+
 	return result;
 }
-- 
1.7.11.4



More information about the Piglit mailing list