Skip to content

Commit

Permalink
test: Selective execution of Cairo tests based on FORMAT option
Browse files Browse the repository at this point in the history
Added a new command line option FORMAT which can take rgb and/or rgba
values which enables the execution of tests only for the given FORMAT
For ex:
(1). CAIRO_TESTS="zero-alpha" make test TARGETS=ps2,image FORMAT=rgba,rgb
This command runs the zero-alpha test for both ps2 and image backends
with argb32 and rgb24 content formats.
(2). CAIRO_TESTS="zero-alpha" make test TARGETS=ps2,image FORMAT=rgba
This command runs the zero-alpha test for both ps2 and image backends
with argb32 content format and so on.

Signed-off-by: Ravi Nanjundappa <nravi.n@samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
  • Loading branch information
Ravi Nanjundappa authored and Bryce Harrington committed Aug 14, 2014
1 parent 1d9f4ae commit f8e0ecb
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 9 deletions.
61 changes: 54 additions & 7 deletions boilerplate/cairo-boilerplate.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,28 @@ _cairo_boilerplate_register_backend (const cairo_boilerplate_target_t *targets,
}
}

static cairo_bool_t
_cairo_boilerplate_target_format_matches_name (const cairo_boilerplate_target_t *target,
const char *tcontent_name,
const char *tcontent_end)
{
char const *content_name;
const char *content_end = tcontent_end;
size_t content_len;

content_name = _cairo_boilerplate_content_visible_name (target->content);
if (tcontent_end)
content_len = content_end - tcontent_name;
else
content_len = strlen(tcontent_name);
if (strlen(content_name) != content_len)
return FALSE;
if (0 == strncmp (content_name, tcontent_name, content_len))
return TRUE;

return FALSE;
}

static cairo_bool_t
_cairo_boilerplate_target_matches_name (const cairo_boilerplate_target_t *target,
const char *tname,
Expand Down Expand Up @@ -597,13 +619,38 @@ cairo_boilerplate_get_targets (int *pnum_targets,
list != NULL;
list = list->next)
{
const cairo_boilerplate_target_t *target = list->target;
if (_cairo_boilerplate_target_matches_name (target, tname, end)) {
/* realloc isn't exactly the best thing here, but meh. */
targets_to_test = xrealloc (targets_to_test, sizeof(cairo_boilerplate_target_t *) * (num_targets+1));
targets_to_test[num_targets++] = target;
found = 1;
}
const cairo_boilerplate_target_t *target = list->target;
const char *tcontent_name;
const char *tcontent_end;
if (_cairo_boilerplate_target_matches_name (target, tname, end)) {
if ((tcontent_name = getenv ("CAIRO_TEST_TARGET_FORMAT")) != NULL && *tcontent_name) {
while(tcontent_name) {
tcontent_end = strpbrk (tcontent_name, " \t\r\n;:,");
if (tcontent_end == tcontent_name) {
tcontent_name = tcontent_end + 1;
continue;
}
if(_cairo_boilerplate_target_format_matches_name (target,
tcontent_name, tcontent_end)) {
/* realloc isn't exactly the best thing here, but meh. */
targets_to_test = xrealloc (targets_to_test,
sizeof(cairo_boilerplate_target_t *) * (num_targets+1));
targets_to_test[num_targets++] = target;
found = 1;
}

if (tcontent_end)
tcontent_end++;
tcontent_name = tcontent_end;
}
} else {
/* realloc isn't exactly the best thing here, but meh. */
targets_to_test = xrealloc (targets_to_test,
sizeof(cairo_boilerplate_target_t *) * (num_targets+1));
targets_to_test[num_targets++] = target;
found = 1;
}
}
}

if (!found) {
Expand Down
3 changes: 2 additions & 1 deletion perf/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ $(top_builddir)/util/cairo-script/libcairo-script-interpreter.la: $(top_builddir
# and TARGETS make var on the command line. Same for the rest.
TARGETS = $(CAIRO_TEST_TARGET)
TARGETS_EXCLUDE = $(CAIRO_TEST_TARGET_EXCLUDE)
FORMAT = $(CAIRO_TEST_TARGET_FORMAT)
ITERS = $(CAIRO_PERF_ITERATIONS)

CAIRO_PERF_ENVIRONMENT = CAIRO_PERF_ITERATIONS="$(ITERS)" CAIRO_TEST_TARGET="$(TARGETS)" CAIRO_TEST_TARGET_EXCLUDE="$(TARGETS_EXCLUDE)"
CAIRO_PERF_ENVIRONMENT = CAIRO_PERF_ITERATIONS="$(ITERS)" CAIRO_TEST_TARGET="$(TARGETS)" CAIRO_TEST_TARGET_FORMAT="$(FORMAT)" CAIRO_TEST_TARGET_EXCLUDE="$(TARGETS_EXCLUDE)"

perf: cairo-perf-micro$(EXEEXT) cairo-perf-trace$(EXEEXT)
-$(CAIRO_PERF_ENVIRONMENT) ./cairo-perf-micro$(EXEEXT)
Expand Down
3 changes: 2 additions & 1 deletion test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,14 @@ EXTRA_PROGRAMS += $(TESTS)
# and TARGETS make var on the command line. Same for the rest.
TARGETS = $(CAIRO_TEST_TARGET)
TARGETS_EXCLUDE = $(CAIRO_TEST_TARGET_EXCLUDE)
FORMAT = $(CAIRO_TEST_TARGET_FORMAT)
NUM_THREADS = $(CAIRO_TEST_NUM_THREADS)
MODE = $(CAIRO_TEST_MODE)

# Same about ENV vs CAIRO_TEST_ENV. ENV is used with "make run" only
ENV = $(CAIRO_TEST_ENV)

TESTS_ENVIRONMENT = CAIRO_TEST_MODE="$(MODE)" CAIRO_TEST_TARGET="$(TARGETS)" CAIRO_TEST_TARGET_EXCLUDE="$(TARGETS_EXCLUDE)" CAIRO_TEST_NUM_THREADS="$(NUM_THREADS)" $(ENV)
TESTS_ENVIRONMENT = CAIRO_TEST_MODE="$(MODE)" CAIRO_TEST_TARGET="$(TARGETS)" CAIRO_TEST_TARGET_FORMAT="$(FORMAT)" CAIRO_TEST_TARGET_EXCLUDE="$(TARGETS_EXCLUDE)" CAIRO_TEST_NUM_THREADS="$(NUM_THREADS)" $(ENV)

EXTRA_VALGRIND_FLAGS = $(CAIRO_EXTRA_VALGRIND_FLAGS)
VALGRIND_FLAGS = \
Expand Down

0 comments on commit f8e0ecb

Please sign in to comment.