[perf] Warn if no traces were found

This commit is contained in:
Chris Wilson 2009-06-02 21:54:44 +01:00
parent f0366f0f32
commit ce7e633942

View file

@ -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)