[cairo-commit] 4 commits - perf/Makefile.am test/cairo-test-runner.c test/README

Chris Wilson ickle at kemper.freedesktop.org
Fri Sep 9 11:44:40 PDT 2011


 perf/Makefile.am         |    5 +++--
 test/README              |    2 +-
 test/cairo-test-runner.c |   22 +++++++++++++++++-----
 3 files changed, 21 insertions(+), 8 deletions(-)

New commits:
commit d8ac76bcec6518f99b21feb0981c4887e89700b7
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Sep 9 19:43:48 2011 +0100

    perf/Makefile.am: Add missing '\' line continuation
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/perf/Makefile.am b/perf/Makefile.am
index 28a4720..92f0dfc 100644
--- a/perf/Makefile.am
+++ b/perf/Makefile.am
@@ -48,8 +48,9 @@ cairo_perf_micro_DEPENDENCIES = \
 
 libcairoperf_la_SOURCES = \
 	$(libcairoperf_sources)	\
-	$(libcairoperf_external_sources)
-	$(libcairoperf_headers)
+	$(libcairoperf_external_sources) \
+	$(libcairoperf_headers) \
+	$(NULL)
 
 cairo_analyse_trace_SOURCES = \
 	$(cairo_analyse_trace_sources)	\
commit ee15e030d8c76df1163706b99369151a93a03524
Author: Paulo Zanoni <paulo.r.zanoni at intel.com>
Date:   Fri Sep 9 14:17:39 2011 -0300

    cairo-test-runner: don't leak argv
    
    If CAIRO_TESTS is set, argv will be replaced by a xmaloc'ed variable. We
    need to free it.
    
    This can be easily detected by running:
    CAIRO_TESTS=user-font make check-valgrind TARGETS=image
    
    Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/test/cairo-test-runner.c b/test/cairo-test-runner.c
index 4afcafc..58e4045 100644
--- a/test/cairo-test-runner.c
+++ b/test/cairo-test-runner.c
@@ -715,6 +715,7 @@ main (int argc, char **argv)
     unsigned int n, m;
     char targets[4096];
     int len;
+    char *cairo_tests_env;
 
 #ifdef _MSC_VER
     /* We don't want an assert dialog, we want stderr */
@@ -752,7 +753,9 @@ main (int argc, char **argv)
     }
 
     _parse_cmdline (&runner, &argc, &argv);
-    append_argv (&argc, &argv, getenv ("CAIRO_TESTS"));
+
+    cairo_tests_env = getenv("CAIRO_TESTS");
+    append_argv (&argc, &argv, cairo_tests_env);
 
     if (runner.full_test) {
 	runner.num_device_offsets = 2;
@@ -1072,6 +1075,9 @@ main (int argc, char **argv)
 
     }
 
+    if (cairo_tests_env)
+	free(argv);
+
     if (runner.list_only) {
 	printf ("\n");
 	return CAIRO_TEST_SUCCESS;
commit 572479ec20c967f91c22a4e49e705c105d37a1dc
Author: Paulo Zanoni <paulo.r.zanoni at intel.com>
Date:   Fri Sep 9 14:16:21 2011 -0300

    test/README: add missing "S"
    
    Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/test/README b/test/README
index f753ccb..8921c70 100644
--- a/test/README
+++ b/test/README
@@ -41,7 +41,7 @@ It should contain a (space-, comma-, etc-separated) list of backends to test.
 To limit the tests run, use the CAIRO_TESTS environment variable, which
 should be a space-separated list of tests to run.  For example:
 
-  CAIRO_TEST="zero-alpha" make test TARGETS=image,ps
+  CAIRO_TESTS="zero-alpha" make test TARGETS=image,ps
 
 Another very handy mechanism when trying to fix bugs is:
 
commit 669242c2c8009b2a257131ba1a3cf497b9472cc4
Author: Paulo Zanoni <paulo.r.zanoni at intel.com>
Date:   Fri Sep 9 14:14:48 2011 -0300

    test: fix append_argv()
    
    When I ran "CAIRO_TESTS=a1-bug make test", no test executed because of a
    bug in append_argv(). The "olen" variable was assuming that we always
    only append a single argument to argv and the resulting argc was also
    wrong.
    
    Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/test/cairo-test-runner.c b/test/cairo-test-runner.c
index 87c6db0..4afcafc 100644
--- a/test/cairo-test-runner.c
+++ b/test/cairo-test-runner.c
@@ -280,6 +280,7 @@ append_argv (int *argc, char ***argv, const char *str)
     int olen;
     int len;
     int i;
+    int args_to_add = 0;
 
     if (str == NULL)
 	return;
@@ -290,9 +291,9 @@ append_argv (int *argc, char ***argv, const char *str)
     doit = FALSE;
     do {
 	if (doit)
-	    *argv = xmalloc (sizeof (char *) * (1 + *argc) + olen);
+	    *argv = xmalloc (olen);
 
-	olen = sizeof (char *) * (1 + *argc);
+	olen = sizeof (char *) * (args_to_add + *argc);
 	for (i = 0; i < old_argc; i++) {
 	    len = strlen (old_argv[i]) + 1;
 	    if (doit) {
@@ -310,7 +311,10 @@ append_argv (int *argc, char ***argv, const char *str)
 		    (*argv)[i] = (char *) *argv + olen;
 		    memcpy ((*argv)[i], s, len);
 		    (*argv)[i][len] = '\0';
+		} else {
+		    olen += sizeof (char *);
 		}
+		args_to_add++;
 		olen += len + 1;
 		i++;
 	    }
@@ -321,13 +325,15 @@ append_argv (int *argc, char ***argv, const char *str)
 	    if (doit) {
 		(*argv)[i] = (char *) *argv + olen;
 		memcpy ((*argv)[i], s, len);
+	    } else {
+		olen += sizeof (char *);
 	    }
+	    args_to_add++;
 	    olen += len;
 	    i++;
 	}
     } while (doit++ == FALSE);
-    (*argv)[i] = NULL;
-    *argc += i;
+    *argc = i;
 }
 
 static void


More information about the cairo-commit mailing list