[Piglit] [PATCH] cl: Add % to the list of illegal characters in test names

Tom Stellard tom at stellard.net
Mon Feb 11 13:34:31 PST 2013


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

% was being interpreted as a format string in some cases
---
 tests/cl/program/execute/scalar-arithmetic-int.cl     | 18 +++++++++---------
 tests/cl/program/execute/scalar-arithmetic-long.cl    | 18 +++++++++---------
 tests/cl/program/execute/scalar-arithmetic-uint.cl    | 10 +++++-----
 tests/cl/program/execute/scalar-arithmetic-ulong.cl   | 10 +++++-----
 .../execute/vector-arithmetic-int4.program_test       |  6 +++---
 tests/cl/program/program-tester.c                     | 19 ++++++++++++++++---
 6 files changed, 47 insertions(+), 34 deletions(-)

diff --git a/tests/cl/program/execute/scalar-arithmetic-int.cl b/tests/cl/program/execute/scalar-arithmetic-int.cl
index 069de62..3263df5 100644
--- a/tests/cl/program/execute/scalar-arithmetic-int.cl
+++ b/tests/cl/program/execute/scalar-arithmetic-int.cl
@@ -171,63 +171,63 @@ arg_out: 0 buffer int[1] 0
 ## Modulo ##
 
 [test]
-name: pos%pos=0
+name: pos mod pos=0
 kernel_name: mod
 arg_in:  1 int 8
 arg_in:  2 int 4
 arg_out: 0 buffer int[1] 0
 
 [test]
-name: pos%pos=pos
+name: pos mod pos=pos
 kernel_name: mod
 arg_in:  1 int 8
 arg_in:  2 int 5
 arg_out: 0 buffer int[1] 3
 
 [test]
-name: neg%pos=0
+name: neg mod pos=0
 kernel_name: mod
 arg_in:  1 int -30
 arg_in:  2 int 15
 arg_out: 0 buffer int[1] 0
 
 [test]
-name: neg%pos=neg
+name: neg mod pos=neg
 kernel_name: mod
 arg_in:  1 int -18
 arg_in:  2 int 5
 arg_out: 0 buffer int[1] -3
 
 [test]
-name: pos%neg=0
+name: pos mod neg=0
 kernel_name: mod
 arg_in:  1 int 12
 arg_in:  2 int -4
 arg_out: 0 buffer int[1] 0
 
 [test]
-name: pos%neg=pos
+name: pos mod neg=pos
 kernel_name: mod
 arg_in:  1 int 16
 arg_in:  2 int -3
 arg_out: 0 buffer int[1] 1
 
 [test]
-name: small_pos%big_pos
+name: small_pos mod big_pos
 kernel_name: mod
 arg_in:  1 int 5
 arg_in:  2 int 345234
 arg_out: 0 buffer int[1] 5
 
 [test]
-name: max_int%num
+name: max_int mod num
 kernel_name: mod
 arg_in:  1 int 2147483647
 arg_in:  2 int 12345
 arg_out: 0 buffer int[1] 9172
 
 [test]
-name: min_int%num
+name: min_int mod num
 kernel_name: mod
 arg_in:  1 int -2147483648
 arg_in:  2 int 476
diff --git a/tests/cl/program/execute/scalar-arithmetic-long.cl b/tests/cl/program/execute/scalar-arithmetic-long.cl
index 08791fd..6dd3d70 100644
--- a/tests/cl/program/execute/scalar-arithmetic-long.cl
+++ b/tests/cl/program/execute/scalar-arithmetic-long.cl
@@ -171,63 +171,63 @@ arg_out: 0 buffer long[1] 0
 ## Modulo ##
 
 [test]
-name: pos%pos=0
+name: pos mod pos=0
 kernel_name: mod
 arg_in:  1 long 8
 arg_in:  2 long 4
 arg_out: 0 buffer long[1] 0
 
 [test]
-name: pos%pos=pos
+name: pos mod pos=pos
 kernel_name: mod
 arg_in:  1 long 8
 arg_in:  2 long 5
 arg_out: 0 buffer long[1] 3
 
 [test]
-name: neg%pos=0
+name: neg mod pos=0
 kernel_name: mod
 arg_in:  1 long -30
 arg_in:  2 long 15
 arg_out: 0 buffer long[1] 0
 
 [test]
-name: neg%pos=neg
+name: neg mod pos=neg
 kernel_name: mod
 arg_in:  1 long -18
 arg_in:  2 long 5
 arg_out: 0 buffer long[1] -3
 
 [test]
-name: pos%neg=0
+name: pos mod neg=0
 kernel_name: mod
 arg_in:  1 long 12
 arg_in:  2 long -4
 arg_out: 0 buffer long[1] 0
 
 [test]
-name: pos%neg=pos
+name: pos mod neg=pos
 kernel_name: mod
 arg_in:  1 long 16
 arg_in:  2 long -3
 arg_out: 0 buffer long[1] 1
 
 [test]
-name: small_pos%big_pos
+name: small_pos mod big_pos
 kernel_name: mod
 arg_in:  1 long 5
 arg_in:  2 long 23423425534456
 arg_out: 0 buffer long[1] 5
 
 [test]
-name: max_long%num
+name: max_long mod num
 kernel_name: mod
 arg_in:  1 long 9223372036854775807
 arg_in:  2 long 99327437623
 arg_out: 0 buffer long[1] 2198836057
 
 [test]
-name: min_long%num
+name: min_long mod num
 kernel_name: mod
 arg_in:  1 long -9223372036854775808
 arg_in:  2 long 63452343342252
diff --git a/tests/cl/program/execute/scalar-arithmetic-uint.cl b/tests/cl/program/execute/scalar-arithmetic-uint.cl
index 30bbd12..1956416 100644
--- a/tests/cl/program/execute/scalar-arithmetic-uint.cl
+++ b/tests/cl/program/execute/scalar-arithmetic-uint.cl
@@ -80,35 +80,35 @@ arg_out: 0 buffer uint[1] 0
 ## Modulo ##
 
 [test]
-name: pos%pos=0
+name: pos mod pos=0
 kernel_name: mod
 arg_in:  1 uint 8
 arg_in:  2 uint 4
 arg_out: 0 buffer uint[1] 0
 
 [test]
-name: pos%pos=pos
+name: pos mod pos=pos
 kernel_name: mod
 arg_in:  1 uint 8
 arg_in:  2 uint 5
 arg_out: 0 buffer uint[1] 3
 
 [test]
-name: small_pos%big_pos
+name: small_pos mod big_pos
 kernel_name: mod
 arg_in:  1 uint 6
 arg_in:  2 uint 32004351
 arg_out: 0 buffer uint[1] 6
 
 [test]
-name: max_uint%num
+name: max_uint mod num
 kernel_name: mod
 arg_in:  1 uint 4294967295
 arg_in:  2 uint 43563
 arg_out: 0 buffer uint[1] 3999
 
 [test]
-name: min_uint%num
+name: min_uint mod num
 kernel_name: mod
 arg_in:  1 uint 0
 arg_in:  2 uint 342346853
diff --git a/tests/cl/program/execute/scalar-arithmetic-ulong.cl b/tests/cl/program/execute/scalar-arithmetic-ulong.cl
index dfb4d1e..75a23da 100644
--- a/tests/cl/program/execute/scalar-arithmetic-ulong.cl
+++ b/tests/cl/program/execute/scalar-arithmetic-ulong.cl
@@ -80,35 +80,35 @@ arg_out: 0 buffer ulong[1] 0
 ## Modulo ##
 
 [test]
-name: pos%pos=0
+name: pos mod pos=0
 kernel_name: mod
 arg_in:  1 ulong 8
 arg_in:  2 ulong 4
 arg_out: 0 buffer ulong[1] 0
 
 [test]
-name: pos%pos=pos
+name: pos mod pos=pos
 kernel_name: mod
 arg_in:  1 ulong 8
 arg_in:  2 ulong 5
 arg_out: 0 buffer ulong[1] 3
 
 [test]
-name: small_pos%big_pos
+name: small_pos mod big_pos
 kernel_name: mod
 arg_in:  1 ulong 7
 arg_in:  2 ulong 3200345334351
 arg_out: 0 buffer ulong[1] 7
 
 [test]
-name: max_ulong%num
+name: max_ulong mod num
 kernel_name: mod
 arg_in:  1 ulong 18446744073709551615
 arg_in:  2 ulong 7674334534554
 arg_out: 0 buffer ulong[1] 7547678378247
 
 [test]
-name: min_ulong%num
+name: min_ulong mod num
 kernel_name: mod
 arg_in:  1 ulong 0
 arg_in:  2 ulong 342346853345563
diff --git a/tests/cl/program/execute/vector-arithmetic-int4.program_test b/tests/cl/program/execute/vector-arithmetic-int4.program_test
index 0731a4f..acc9db7 100644
--- a/tests/cl/program/execute/vector-arithmetic-int4.program_test
+++ b/tests/cl/program/execute/vector-arithmetic-int4.program_test
@@ -103,21 +103,21 @@ arg_out: 0 buffer int4[1]  0  0  0  0
 ## Modulo ##
 
 [test]
-name: pos%pos=0, pos%neg=0, pos%pos=pos, pos%neg=pos
+name: pos mod pos=0, pos mod neg=0, pos mod pos=pos, pos mod neg=pos
 kernel_name: mod
 arg_in:  1 int4            8  12  8 16
 arg_in:  2 int4            4  -3  5 -3
 arg_out: 0 buffer int4[1]  0   0  3  1
 
 [test]
-name: neg%pos=0, neg%pos=neg, small_pos%big_pos, small_pos%big_pos
+name: neg mod pos=0, neg mod pos=neg, small_pos mod big_pos, small_pos mod big_pos
 kernel_name: mod
 arg_in:  1 int4          -30 -18     5       6
 arg_in:  2 int4           15   5 34343 3456676
 arg_out: 0 buffer int4[1]  0  -3     5       6
 
 [test]
-name: max_int%num, min_int%num
+name: max_int mod num, min_int mod num
 kernel_name: mod
 arg_in:  1 int4           0X7FFFFFFF 0X7FFFFFFF -0X80000000 -0X80000000
 arg_in:  2 int4                12345      12345         476         476
diff --git a/tests/cl/program/program-tester.c b/tests/cl/program/program-tester.c
index 189b617..31bf5a0 100644
--- a/tests/cl/program/program-tester.c
+++ b/tests/cl/program/program-tester.c
@@ -1113,9 +1113,22 @@ 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);
+	int error;
+	regex_t regex;
+	regmatch_t pmatch[1];
+
+
+	if ((error = regcomp(&regex, "\\([/%]\\)",0))) {
+		char errbuf[100];
+		regerror(error, &regex, errbuf, 100);
+		fprintf(stderr, "Failed to compile regex for parse_name():%s\n", errbuf);
+		return NULL;
+	}
+
+	if (!regexec(&regex, input, 1, &pmatch, 0)) {
+		char bad_char = *(input + pmatch[0].rm_so);
+		fprintf(stderr,	"Illegal character in test name '%s': %c\n",
+							input, bad_char);
 		return NULL;
 	}
 	return name;
-- 
1.7.11.4



More information about the Piglit mailing list