[igt-dev] [PATCH i-g-t 3/5] uwildmat: Case-insensitive test selection

Petri Latvala petri.latvala at intel.com
Wed Jun 13 10:07:37 UTC 2018


Since we only use plain ascii in subtest names, using non-locale-aware
tolower() to compare case-insensitively works.

Doing this within uwildmat instead of tolowering the subtest name and
then calling uwildmat() is required, because of selection strings
like:

foo,bar,!Foo

The above line will select subtest Bar, and not select Foo.

Signed-off-by: Petri Latvala <petri.latvala at intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
Cc: Tomi Sarvela <tomi.p.sarvela at intel.com>
Cc: Martin Peres <martin.peres at linux.intel.com>
---
 lib/uwildmat/uwildmat.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/uwildmat/uwildmat.c b/lib/uwildmat/uwildmat.c
index 09155865..3beafce2 100644
--- a/lib/uwildmat/uwildmat.c
+++ b/lib/uwildmat/uwildmat.c
@@ -93,6 +93,7 @@
  **  accompanying test suite achieves 100% coverage of this file.
  */
 
+#include <ctype.h>
 #include <string.h>
 #include <stdint.h>
 #include "uwildmat/uwildmat.h"
@@ -222,6 +223,7 @@ match_class(uint32_t text, const unsigned char *start,
 	const unsigned char *p = start;
 	uint32_t first = 0;
 	uint32_t last;
+	uint32_t lc = tolower(text);
 
 	/* Check for an inverted character class (starting with ^).  If the
 	   character matches the character class, we return !reversed; that way,
@@ -244,12 +246,13 @@ match_class(uint32_t text, const unsigned char *start,
 		if (allowrange && *p == '-' && p < end) {
 			p++;
 			p += utf8_decode(p, end, &last);
-			if (text >= first && text <= last)
+			if ((text >= first && text <= last) ||
+			    (lc >= first && lc <= last))
 				return !reversed;
 			allowrange = false;
 		} else {
 			p += utf8_decode(p, end, &first);
-			if (text == first)
+			if (text == first || lc == first)
 				return !reversed;
 			allowrange = true;
 		}
@@ -272,6 +275,7 @@ match_pattern(const unsigned char *text, const unsigned char *start,
 	bool ismeta;
 	int matched, width;
 	uint32_t c;
+	unsigned char lc;
 
 	for (; p <= end; p++) {
 		if (!*text && *p != '*')
@@ -284,7 +288,8 @@ match_pattern(const unsigned char *text, const unsigned char *start,
 			/* Fall through. */
 
 		default:
-			if (*text++ != *p)
+			lc = tolower(*text);
+			if (*text++ != *p && lc != *p)
 				return false;
 			break;
 
-- 
2.14.1



More information about the igt-dev mailing list