[cairo-commit] perf/cairo-perf-trace.c

Chris Wilson ickle at kemper.freedesktop.org
Tue Jun 2 13:59:43 PDT 2009


 perf/cairo-perf-trace.c |   28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

New commits:
commit ce7e6339428703069f798dffcf23ec3e98cb554f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jun 2 21:54:44 2009 +0100

    [perf] Warn if no traces were found

diff --git a/perf/cairo-perf-trace.c b/perf/cairo-perf-trace.c
index 898fed6..91eadaf 100644
--- a/perf/cairo-perf-trace.c
+++ b/perf/cairo-perf-trace.c
@@ -432,6 +432,18 @@ cairo_perf_trace (cairo_perf_t *perf,
 	target->cleanup (closure);
 }
 
+static void
+warn_no_traces (const char *message, const char *trace_dir)
+{
+    fprintf (stderr,
+"Error: %s '%s'.\n"
+"Have you cloned the cairo-traces repository and uncompressed the traces?\n"
+"  git clone git://git.freedesktop.org/cairo-traces\n"
+"  cd cairo-traces && make\n"
+"Or set the env.var CAIRO_TRACE_DIR to point to your traces?\n",
+	    message, trace_dir);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -484,17 +496,11 @@ main (int argc, char *argv[])
 	} else {
 	    DIR *dir;
 	    struct dirent *de;
+	    int num_traces = 0;
 
 	    dir = opendir (trace_dir);
 	    if (dir == NULL) {
-		fprintf (stderr,
-"Error: Failed to open trace directory '%s'.\n"
-"Have you cloned the trace repository?\n"
-"  git clone git://git.freedesktop.org/cairo-traces\n"
-"  cd cairo-traces && make\n"
-"Or set the env.var CAIRO_TRACE_DIR to point to your traces?\n",
-			 trace_dir);
-
+		warn_no_traces ("Failed to open directory", trace_dir);
 		return 1;
 	    }
 
@@ -508,6 +514,7 @@ main (int argc, char *argv[])
 		if (strcmp (dot, ".trace"))
 		    continue;
 
+		num_traces++;
 		if (! cairo_perf_can_run (&perf, de->d_name))
 		    continue;
 
@@ -517,6 +524,11 @@ main (int argc, char *argv[])
 
 	    }
 	    closedir (dir);
+
+	    if (num_traces == 0) {
+		warn_no_traces ("Found no traces in", trace_dir);
+		return 1;
+	    }
 	}
 
 	if (perf.list_only)


More information about the cairo-commit mailing list