[cairo-commit] test/cairo-test.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Fri Jun 16 16:01:29 PDT 2006


 test/cairo-test.c |   33 ++++++++++++++++++++++++---------
 1 files changed, 24 insertions(+), 9 deletions(-)

New commits:
diff-tree bc4a6796f851a9f10764feb783988641d26cf2ce (from 8bc05f15ab3f2054f802cfbc9564476a4acbb4a8)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Jun 16 19:01:20 2006 -0400

    Accept CAIRO_TEST_TARGET being empty or containing a list of backends to test.
    The list can be separated by any of space, tab, comma, colon, or semicolon.
    Moreover, a CAIRO_TEST_TARGET of e.g. "glitz" matches any subtarget like
    "glitz-glx".

diff --git a/test/cairo-test.c b/test/cairo-test.c
index 0103e46..308dadd 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include <ctype.h>
 #include <assert.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -1738,17 +1739,31 @@ cairo_test_expecting (cairo_test_t *test
 	const char *tname = getenv ("CAIRO_TEST_TARGET");
 	num_targets = 0;
 	targets_to_test = NULL;
-	/* realloc isn't exactly the best thing here, but meh. */
-	for (i = 0; i < sizeof(targets)/sizeof(targets[0]); i++) {
-	    if (strcmp (targets[i].name, tname) == 0) {
-		targets_to_test = realloc (targets_to_test, sizeof(cairo_test_target_t *) * (num_targets+1));
-		targets_to_test[num_targets++] = &targets[i];
+
+	while (*tname) {
+	    int found = 0;
+	    const char *end = strpbrk (tname, " \t;:,");
+	    if (!end)
+	        end = tname + strlen (tname);
+
+	    for (i = 0; i < sizeof(targets)/sizeof(targets[0]); i++) {
+		if (strncmp (targets[i].name, tname, end - tname) == 0 &&
+		    !isalnum (targets[i].name[end - tname])) {
+		    /* realloc isn't exactly the best thing here, but meh. */
+		    targets_to_test = realloc (targets_to_test, sizeof(cairo_test_target_t *) * (num_targets+1));
+		    targets_to_test[num_targets++] = &targets[i];
+		    found = 1;
+		}
+	    }
+
+	    if (!found) {
+		fprintf (stderr, "CAIRO_TEST_TARGET '%s' not found in targets list!\n", tname);
+		exit(-1);
 	    }
-	}
 
-	if (num_targets == 0) {
-	    fprintf (stderr, "CAIRO_TEST_TARGET '%s' not found in targets list!\n", tname);
-	    exit(-1);
+	    if (*end)
+	      end++;
+	    tname = end;
 	}
     } else {
 	num_targets = sizeof(targets)/sizeof(targets[0]);


More information about the cairo-commit mailing list