This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 8a0c954a8e79f88f06cfc99f7a29d3a1558b21d6 (commit) via 91180ba0b4f5b211693cc1cc932fde2f21587831 (commit) via f21b5a5e55f34e78e0c5e862d3efd69f9403d6b2 (commit) via 467bccd40fa26a60ec2ecefbe78cde607347d63e (commit) via 80bfe228b1a8d10d8ef22a4014ebd8c5aeaf1a10 (commit) via 4d3ede6b7e1246658651efd6e5616baed2840fc1 (commit) via b188f0d186f6ef96f6ee337405ec53a64fc19392 (commit) via 05b99f21ccbb74999f9447dfcc922b3160c9a1f8 (commit) via 5aae2f560739a490f9a9ac203da89abad1fb3eba (commit) via 6b103927dac437610150583917b659a5983c189c (commit) via 1a6517e66dab6dc2bd8e91366f852f68b30870a4 (commit) via f277c6a354d94aa9ddd50240711a5b80eb4116a8 (commit) from b77f76c2f45a7e07893d88d7edf9016d35411f95 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/8a0c954a8e79f88f06cfc99f7a29d3a1558b2...
commit 8a0c954a8e79f88f06cfc99f7a29d3a1558b21d6 Merge: 91180ba b77f76c Author: Cyril Hrubis metan@ucw.cz Date: Sat Dec 8 20:10:27 2012 +0100
Merge ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/91180ba0b4f5b211693cc1cc932fde2f21587...
commit 91180ba0b4f5b211693cc1cc932fde2f21587831 Author: Cyril Hrubis metan@ucw.cz Date: Sat Dec 8 17:52:27 2012 +0100
tests: gfx: Add FillCircle test.
diff --git a/tests/gfx/FillCircle.c b/tests/gfx/FillCircle.c new file mode 100644 index 0000000..3ab67b9 --- /dev/null +++ b/tests/gfx/FillCircle.c @@ -0,0 +1,243 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <string.h> +#include <errno.h> +#include <sys/stat.h> + +#include <core/GP_Context.h> +#include <gfx/GP_Circle.h> + +#include "tst_test.h" + +#include "common.h" + +struct testcase { + /* cicle description */ + GP_Coord x; + GP_Coord y; + GP_Size r; + + /* expected result */ + GP_Size w, h; + const char pixmap[]; +}; + +static int test_circle(const struct testcase *t) +{ + GP_Context *c; + int err; + + c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8); + + if (c == NULL) { + tst_err("Failed to allocate context"); + return TST_UNTESTED; + } + + /* zero the pixels buffer */ + memset(c->pixels, 0, c->w * c->h); + + GP_FillCircle(c, t->x, t->y, t->r, 1); + + err = compare_buffers(t->pixmap, c); + + if (err) + return TST_FAILED; + + return TST_SUCCESS; +} + +struct testcase testcase_circle_r_0 = { + .x = 2, + .y = 2, + .r = 0, + + .w = 5, + .h = 5, + + .pixmap = { + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_circle_r_1 = { + .x = 2, + .y = 2, + .r = 1, + + .w = 5, + .h = 5, + + .pixmap = { + 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, + 0, 1, 1, 1, 0, + 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_circle_r_2 = { + .x = 3, + .y = 3, + .r = 2, + + .w = 7, + .h = 7, + + .pixmap = { + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 0, 0, + 0, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 0, + 0, 0, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_circle_r_3 = { + .x = 4, + .y = 4, + .r = 3, + + .w = 9, + .h = 9, + + .pixmap = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_circle_r_4 = { + .x = 5, + .y = 5, + .r = 4, + + .w = 11, + .h = 11, + + .pixmap = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_circle_r_5_clip = { + .x = 0, + .y = 5, + .r = 5, + + .w = 11, + .h = 11, + + .pixmap = { + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_circle_r_6_clip = { + .x = 0, + .y = 0, + .r = 6, + + .w = 8, + .h = 8, + + .pixmap = { + 1, 1, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 0, 0, + 1, 1, 1, 1, 1, 1, 0, 0, + 1, 1, 1, 1, 1, 0, 0, 0, + 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + } +}; + +const struct tst_suite tst_suite = { + .suite_name = "FillCircle Testsuite", + .tests = { + {.name = "FillCircle r=0", + .tst_fn = test_circle, + .data = &testcase_circle_r_0}, + + {.name = "FillCircle r=1", + .tst_fn = test_circle, + .data = &testcase_circle_r_1}, + + {.name = "FillCircle r=2", + .tst_fn = test_circle, + .data = &testcase_circle_r_2}, + + {.name = "FillCircle r=3", + .tst_fn = test_circle, + .data = &testcase_circle_r_3}, + + {.name = "FillCircle r=4", + .tst_fn = test_circle, + .data = &testcase_circle_r_4}, + + {.name = "FillCircle r=5 + clipping", + .tst_fn = test_circle, + .data = &testcase_circle_r_5_clip}, + + {.name = "FillCircle r=6 + clipping", + .tst_fn = test_circle, + .data = &testcase_circle_r_6_clip}, + + {.name = NULL} + } +}; diff --git a/tests/gfx/Makefile b/tests/gfx/Makefile index 1345a1f..fafb1cb 100644 --- a/tests/gfx/Makefile +++ b/tests/gfx/Makefile @@ -3,9 +3,10 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
-APPS=gfx_benchmark Circle Line CircleSeg Polygon +APPS=gfx_benchmark Circle FillCircle Line CircleSeg Polygon
Circle: common.o +FillCircle: common.o Line: common.o CircleSeg: common.o Polygon: common.o diff --git a/tests/gfx/runtest.sh b/tests/gfx/runtest.sh index 3e6cf36..0e50fb6 100755 --- a/tests/gfx/runtest.sh +++ b/tests/gfx/runtest.sh @@ -12,5 +12,6 @@ export LIBC_FATAL_STDERR_=1 #LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./gfx_benchmark "$@" LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Line "$@" LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Circle "$@" +LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./FillCircle "$@" LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./CircleSeg "$@" LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Polygon "$@"
http://repo.or.cz/w/gfxprim.git/commit/f21b5a5e55f34e78e0c5e862d3efd69f9403d...
commit f21b5a5e55f34e78e0c5e862d3efd69f9403d6b2 Author: Cyril Hrubis metan@ucw.cz Date: Sat Dec 8 17:46:12 2012 +0100
tests: gfx: Circle.c: Edhance and simplify tests.
diff --git a/tests/gfx/Circle.c b/tests/gfx/Circle.c index 34637bc..0015ebe 100644 --- a/tests/gfx/Circle.c +++ b/tests/gfx/Circle.c @@ -31,83 +31,23 @@
#include "common.h"
-static const char circle_r_0_11x11[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +struct testcase { + /* cicle description */ + GP_Coord x; + GP_Coord y; + GP_Size r; + + /* expected result */ + GP_Size w, h; + const char pixmap[]; };
-static const char circle_r_1_11x11[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static const char circle_r_2_11x11[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static const char circle_r_3_11x11[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, - 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static const char circle_r_5_half_11x11[] = { - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static int test_circle(const char *pattern, GP_Size w, GP_Size h, - GP_Coord x, GP_Coord y, const int r) +static int test_circle(const struct testcase *t) { GP_Context *c; int err;
- c = GP_ContextAlloc(w, h, GP_PIXEL_G8); + c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8);
if (c == NULL) { tst_err("Failed to allocate context"); @@ -117,63 +57,187 @@ static int test_circle(const char *pattern, GP_Size w, GP_Size h, /* zero the pixels buffer */ memset(c->pixels, 0, c->w * c->h);
- GP_Circle(c, x, y, r, 1); + GP_Circle(c, t->x, t->y, t->r, 1);
- err = compare_buffers(pattern, c); + err = compare_buffers(t->pixmap, c);
- if (err) { - tst_msg("Patterns are different"); + if (err) return TST_FAILED; - }
return TST_SUCCESS; }
-static int test_circle_r_0(void) -{ - return test_circle(circle_r_0_11x11, 11, 11, 5, 5, 0); -} +struct testcase testcase_circle_r_0 = { + .x = 2, + .y = 2, + .r = 0,
-static int test_circle_r_1(void) -{ - return test_circle(circle_r_1_11x11, 11, 11, 5, 5, 1); -} + .w = 5, + .h = 5,
-static int test_circle_r_2(void) -{ - return test_circle(circle_r_2_11x11, 11, 11, 5, 5, 2); -} + .pixmap = { + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + } +};
-static int test_circle_r_3(void) -{ - return test_circle(circle_r_3_11x11, 11, 11, 5, 5, 3); -} +struct testcase testcase_circle_r_1 = { + .x = 2, + .y = 2, + .r = 1,
-static int test_circle_r__1(void) -{ - return test_circle(circle_r_1_11x11, 11, 11, 5, 5, -1); -} + .w = 5, + .h = 5,
-static int test_circle_r__2(void) -{ - return test_circle(circle_r_2_11x11, 11, 11, 5, 5, -2); -} + .pixmap = { + 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, + 0, 1, 0, 1, 0, + 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, + } +};
-static int test_circle_r_5_half(void) -{ - return test_circle(circle_r_5_half_11x11, 11, 11, 0, 5, 5); -} +struct testcase testcase_circle_r_2 = { + .x = 3, + .y = 3, + .r = 2, + + .w = 7, + .h = 7, + + .pixmap = { + 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 0, 0, + 0, 1, 0, 0, 0, 1, 0, + 0, 1, 0, 0, 0, 1, 0, + 0, 1, 0, 0, 0, 1, 0, + 0, 0, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_circle_r_3 = { + .x = 4, + .y = 4, + .r = 3, + + .w = 9, + .h = 9, + + .pixmap = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 1, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 1, 0, + 0, 1, 0, 0, 0, 0, 0, 1, 0, + 0, 1, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 0, 0, 1, 0, 0, + 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_circle_r_4 = { + .x = 5, + .y = 5, + .r = 4, + + .w = 11, + .h = 11, + + .pixmap = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_circle_r_5_clip = { + .x = 0, + .y = 5, + .r = 5, + + .w = 11, + .h = 11, + + .pixmap = { + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + } +}; + +struct testcase testcase_circle_r_6_clip = { + .x = 0, + .y = 0, + .r = 6, + + .w = 8, + .h = 8, + + .pixmap = { + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, + 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + } +};
const struct tst_suite tst_suite = { - .suite_name = "GFX Circle Testsuite", + .suite_name = "Circle Testsuite", .tests = { - {.name = "Circle r=0", .tst_fn = test_circle_r_0}, - {.name = "Circle r=1", .tst_fn = test_circle_r_1}, - {.name = "Circle r=2", .tst_fn = test_circle_r_2}, - {.name = "Circle r=3", .tst_fn = test_circle_r_3}, - {.name = "Circle r=5 half", .tst_fn = test_circle_r_5_half}, - {.name = "Circle r=-1", .tst_fn = test_circle_r__1}, - {.name = "Circle r=-2", .tst_fn = test_circle_r__2}, + {.name = "Circle r=0", + .tst_fn = test_circle, + .data = &testcase_circle_r_0}, + + {.name = "Circle r=1", + .tst_fn = test_circle, + .data = &testcase_circle_r_1}, + + {.name = "Circle r=2", + .tst_fn = test_circle, + .data = &testcase_circle_r_2}, + + {.name = "Circle r=3", + .tst_fn = test_circle, + .data = &testcase_circle_r_3}, + + {.name = "Circle r=4", + .tst_fn = test_circle, + .data = &testcase_circle_r_4}, + + {.name = "Circle r=5 + clipping", + .tst_fn = test_circle, + .data = &testcase_circle_r_5_clip}, + + {.name = "Circle r=6 + clipping", + .tst_fn = test_circle, + .data = &testcase_circle_r_6_clip}, + {.name = NULL} } }; diff --git a/tests/gfx/runtest.sh b/tests/gfx/runtest.sh index bf430be..3e6cf36 100755 --- a/tests/gfx/runtest.sh +++ b/tests/gfx/runtest.sh @@ -10,7 +10,7 @@ export LIBC_FATAL_STDERR_=1
#LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./gfx_benchmark "$@" -LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Circle "$@" LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Line "$@" +LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Circle "$@" LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./CircleSeg "$@" LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./Polygon "$@"
http://repo.or.cz/w/gfxprim.git/commit/467bccd40fa26a60ec2ecefbe78cde607347d...
commit 467bccd40fa26a60ec2ecefbe78cde607347d63e Author: Cyril Hrubis metan@ucw.cz Date: Sat Dec 8 17:33:24 2012 +0100
tests: framework: simplify tst_log interface.
diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c index a7cf9ec..aecb8dc 100644 --- a/tests/framework/tst_log.c +++ b/tests/framework/tst_log.c @@ -117,7 +117,7 @@ static void append_benchmark_json(struct tst_job *job, FILE *f)
static int hack_json_start = 0;
-static int append_json(struct tst_job *job, FILE *f) +int tst_log_append(struct tst_job *job, FILE *f) { if (hack_json_start) hack_json_start = 0; @@ -154,19 +154,6 @@ static int append_json(struct tst_job *job, FILE *f) return 0; }
-int tst_log_append(struct tst_job *job, FILE *f, enum tst_log_fmt format) -{ - switch (format) { - case TST_LOG_JSON: - return append_json(job, f); - break; - default: - return 1; - } - - return 1; -} - static void write_system_info_json(FILE *f) { struct utsname buf; @@ -203,7 +190,7 @@ static void write_system_info_json(FILE *f) fprintf(f, "t},n"); }
-FILE *open_json(const struct tst_suite *suite, const char *path) +FILE *tst_log_open(const struct tst_suite *suite, const char *path) { FILE *f;
@@ -222,35 +209,8 @@ FILE *open_json(const struct tst_suite *suite, const char *path) return f; }
-FILE *tst_log_open(const struct tst_suite *suite, const char *path, - enum tst_log_fmt format) -{ - switch (format) { - case TST_LOG_JSON: - return open_json(suite, path); - break; - default: - return NULL; - } - - return NULL; -} - -static int close_json(FILE *f) +int tst_log_close(FILE *f) { fprintf(f, "nt]n}n"); return fclose(f); } - -int tst_log_close(FILE *f, enum tst_log_fmt format) -{ - switch (format) { - case TST_LOG_JSON: - return close_json(f); - break; - default: - return 1; - } - - return 1; -} diff --git a/tests/framework/tst_log.h b/tests/framework/tst_log.h index 28fecf1..400d9e8 100644 --- a/tests/framework/tst_log.h +++ b/tests/framework/tst_log.h @@ -34,15 +34,10 @@ struct tst_suite; struct tst_job;
-enum tst_log_fmt { - TST_LOG_JSON, -}; +FILE *tst_log_open(const struct tst_suite *suite, const char *path);
-FILE *tst_log_open(const struct tst_suite *suite, const char *path, - enum tst_log_fmt format); +int tst_log_append(struct tst_job *job, FILE *f);
-int tst_log_append(struct tst_job *job, FILE *f, enum tst_log_fmt format); - -int tst_log_close(FILE *f, enum tst_log_fmt format); +int tst_log_close(FILE *f);
#endif /* TST_LOG_H */ diff --git a/tests/framework/tst_suite.c b/tests/framework/tst_suite.c index e929225..924be43 100644 --- a/tests/framework/tst_suite.c +++ b/tests/framework/tst_suite.c @@ -135,7 +135,7 @@ static int run_test(const struct tst_test *test, FILE *json) /* report result into stdout */ test_job_report(&job);
- tst_log_append(&job, json, TST_LOG_JSON); + tst_log_append(&job, json);
/* Free the test message store */ tst_msg_clear(&job.store); @@ -153,7 +153,7 @@ void tst_run_suite(const struct tst_suite *suite, const char *tst_name) fprintf(stderr, "Running e[1;37m%se[0mnn", suite->suite_name);
//TODO: - FILE *json = tst_log_open(suite, "log.json", TST_LOG_JSON); + FILE *json = tst_log_open(suite, "log.json");
for (i = 0; suite->tests[i].name != NULL; i++) { if (tst_name == NULL || !strcmp(tst_name, suite->tests[i].name)) { @@ -165,7 +165,7 @@ void tst_run_suite(const struct tst_suite *suite, const char *tst_name) } }
- tst_log_close(json, TST_LOG_JSON); + tst_log_close(json);
float percents;
http://repo.or.cz/w/gfxprim.git/commit/80bfe228b1a8d10d8ef22a4014ebd8c5aeaf1...
commit 80bfe228b1a8d10d8ef22a4014ebd8c5aeaf1a10 Author: Cyril Hrubis metan@ucw.cz Date: Sat Dec 8 17:09:11 2012 +0100
build: Remove check for LIBNAME from gen.mk
diff --git a/gen.mk b/gen.mk index 14aac0d..6cd9b47 100644 --- a/gen.mk +++ b/gen.mk @@ -1,10 +1,6 @@ # # This is makefile rule for generating C sources from python templates # -ifndef LIBNAME -$(error LIBNAME not defined, fix your library Makefile) -endif - ifndef GENHEADERS GENHEADERS= endif diff --git a/include/core/Makefile b/include/core/Makefile index c68d42e..5606d74 100644 --- a/include/core/Makefile +++ b/include/core/Makefile @@ -1,9 +1,10 @@ TOPDIR=../.. + +include $(TOPDIR)/pre.mk + GENHEADERS=GP_Convert_Scale.gen.h GP_Pixel.gen.h GP_GetPutPixel.gen.h GP_Convert.gen.h GP_FnPerBpp.gen.h GP_MixPixels.gen.h GP_GammaCorrection.gen.h GP_GammaPixel.gen.h -LIBNAME=core
-include $(TOPDIR)/pre.mk include $(TOPDIR)/gen.mk include $(TOPDIR)/post.mk diff --git a/tests/core/Makefile b/tests/core/Makefile index 54d105a..91185c2 100644 --- a/tests/core/Makefile +++ b/tests/core/Makefile @@ -4,9 +4,6 @@ include $(TOPDIR)/pre.mk
CSOURCES=Context.c
-# hack -LIBNAME=core - GENSOURCES+=WritePixel_testsuite.gen.c GetPutPixel.gen.c
APPS=WritePixel_testsuite.gen Context GetPutPixel.gen diff --git a/tests/core/WritePixel_testsuite.gen.c.t b/tests/core/WritePixel_testsuite.gen.c.t index 365c247..df49d2d 100644 --- a/tests/core/WritePixel_testsuite.gen.c.t +++ b/tests/core/WritePixel_testsuite.gen.c.t @@ -26,7 +26,7 @@
#include <stdio.h>
-#include "GP_WritePixel.h" +#include <core/GP_WritePixel.h>
#include "tst_test.h"
http://repo.or.cz/w/gfxprim.git/commit/4d3ede6b7e1246658651efd6e5616baed2840...
commit 4d3ede6b7e1246658651efd6e5616baed2840fc1 Author: Cyril Hrubis metan@ucw.cz Date: Sat Dec 8 16:59:45 2012 +0100
tests: Remove now unused test collection code.
diff --git a/pylib/bin/generate_collected_tests.py b/pylib/bin/generate_collected_tests.py deleted file mode 100644 index 72f6efb..0000000 --- a/pylib/bin/generate_collected_tests.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/python -# -# Script generating collected_tests.gen.c -# -# 2011 - Tomas Gavenciak gavento@ucw.cz -# - -from gp_codegen import render_utils, test_collection -import jinja2 -import logging as log -from optparse import OptionParser - -template_file = "collected_tests.c.t" - -parser = OptionParser(usage="usage: %prog [options] <scan_dir> <output_file>") -parser.add_option("-t", "--templates", dest="templates", - help="Directory with templates.", default=".") -parser.add_option("-c", "--config", dest="config", - help="GfxPrim config file.", default=None) - -def main(options, args): - config = render_utils.load_gfxprimconfig(options.config) - assert config - log.info("Scanning dir %s for tests, generating %s", args[0], args[1]) - env = render_utils.create_environment(config, options.templates) - env.globals['suites'] = test_collection.collect_suites(args[0]) - render_utils.render_file(env, options.templates + '/' + template_file, args[1]) - - -if __name__ == '__main__': - log.debug("Jinja version %s", jinja2.__version__) - (options, args) = parser.parse_args() - if len(args) != 2: - parser.error() - main(options, args) diff --git a/pylib/gp_codegen/test_collection.py b/pylib/gp_codegen/test_collection.py deleted file mode 100644 index ad3b78f..0000000 --- a/pylib/gp_codegen/test_collection.py +++ /dev/null @@ -1,96 +0,0 @@ -# -# Scrapes the target directory for .test.c files, looks for -# GP_TEST and GP_SUITE macros and generates code creating all the -# tests and the suite -# -# 2011 - Tomas Gavenciak gavento@ucw.cz -# - -import os -import re -import glob -import logging as log -from .render_utils import create_environment, render_file - -testfile_patterns = ['*.test.c', '*.test.gen.c'] - -suite_re = re.compile("A\s*GP_SUITE((.*))\s*Z") -test_re = re.compile("A\s*GP_TEST((.*))\s*Z") - -# Also fixed in tests.mk -collected_tests_file = 'collected_tests.gen.c' - -# suites is a dict of tests: -# {"suitename": [Test]} - -# Test is a dict: -# {"attribute": val} -# attributes are: -# name, fname, line - -def find_tests(fname, suites): - "Finds all tests in a file, extend suites." - suite = None - f = open(fname, 'rt') - ls = list(f.readlines()) - f.close() - for i in range(len(ls)): - l = ls[i] - # Look for suite declaration - name, args = find_GP_directive("GP_SUITE", suite_re, l, fname=fname, line=i) - if name: - if args: - log.warning("%s:%s: Suite should have no arguments other than name.", fname, i) - suites.setdefault(name, []) - suite = name - # Look for test declaration - name, args = find_GP_directive("GP_TEST", test_re, l, fname=fname, line=i) - if name: - test_suite = suite - if 'suite' in args: - test_suite = args['suite'] - if not test_suite: - test_suite = 'default' - log.warning("%s:%s: No suite defined before test %s, using %r.", fname, i, name, test_suite) - args['name'] = name - args['fname'] = fname - args['line'] = i - assert ('loop_start' in args) == ('loop_end' in args) - suites.setdefault(test_suite, []) - suites[test_suite].append(args) - - -def collect_suites(fdir): - fnames = [] - suites = {} - for pat in testfile_patterns: - fnames += glob.fnmatch.filter(os.listdir(fdir), pat) - for fn in fnames: - find_tests(os.path.join(fdir, fn), suites) - if not fnames: - log.warning('No .test.c files found in "%s".', fdir) - if not suites: - log.warning('No suites found, generating an empty testsuite.') - return suites - - -def find_GP_directive(name, regexp, l, fname='unknown', line=0): - "Looks for a given GP_* directive, parses args if any, " - "retuns (name, dict_of_args) or (None, None) if not found." - if name in l: - m = regexp.search(l) - if not m: - warn("found unsuitable %s directive, ignoring." % name, fname, line) - else: - d = m.groups()[0].split(',', 1) - args = {} - if len(d)>1: - try: - s = 'dict( ' + d[1].strip(" tn"") + ' )' - args = eval(s) - except: - log.fatal("%s:%s: error parsing arguments: %r", fname, line, s) - return d[0].strip(), args - return None, None - -
http://repo.or.cz/w/gfxprim.git/commit/b188f0d186f6ef96f6ee337405ec53a64fc19...
commit b188f0d186f6ef96f6ee337405ec53a64fc19392 Author: Cyril Hrubis metan@ucw.cz Date: Sat Dec 8 16:32:52 2012 +0100
tests: Finally remove the rest of old tests.
diff --git a/tests/core_old/GP_Common.test.c b/tests/core_old/GP_Common.test.c deleted file mode 100644 index 81422fb..0000000 --- a/tests/core_old/GP_Common.test.c +++ /dev/null @@ -1,103 +0,0 @@ -/***************************************************************************** - * This file is part of gfxprim library. * - * * - * Gfxprim is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * Gfxprim is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with gfxprim; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - * Copyright (C) 2011 Tomas Gavenciak gavento@ucw.cz * - * * - *****************************************************************************/ - -#include "GP_Tests.h" - -#include <GP_Common.h> -#include <GP_GetSetBits.h> -#include <unistd.h> - -/* - * Demo ("testing" ;-) tests for GP_Common.h - */ - -GP_SUITE(GP_Common) - -GP_TEST(min_max) -{ - fail_unless(GP_MIN(-1.5, 2) == -1.5); - fail_unless(GP_MAX(4294967295ULL, 1ULL) == 4294967295ULL); - int x=0, y=0; - fail_unless(GP_MAX(x++, ++y) == 1); - fail_unless(x == 1 && y == 1); -} -GP_ENDTEST - -GP_TEST(get_bits) -{ - fail_unless(GP_GET_BITS(15, 7, 0x12345678ULL) == 0x68); - fail_unless(GP_GET_BITS(0, 0, 0x12345678ULL) == 0); - fail_unless(GP_GET_BITS(16, 16, 0x1234) == 0); - fail_unless(GP_GET_BITS(1, 32, 0x12345678ULL) == 0x091A2B3CULL); -} -GP_ENDTEST - -GP_TEST(set_bits) -{ - uint32_t x = 0x89ABC; - uint16_t *y = (uint16_t*) &x; - GP_CLEAR_BITS(3, 4, x); - fail_unless(x == 0x89A84); - GP_SET_BITS_OR(10, x, 0x0000000); - fail_unless(x == 0x89A84); - GP_SET_BITS(24, 18, x, 0x42F1); - fail_unless(x == 0xF1089A84); - /* Check that only uint16_t is affected */ -/* TODO: Fix aliasing problems with this test - GP_SET_BITS(0, 24, *y, 0x100F000LL); -# if __BYTE_ORDER == __BIG_ENDIAN - fail_unless(x == 0xF108F000); -# else - fail_unless(x == 0x100F9A84); -# endif -*/ -} -GP_ENDTEST - -GP_TEST(abort_check_assert, "loop_start=0, loop_end=9, expect_signal=6") -{ - /* Prevent output during testing */ -# ifdef stderr -# undef stderr -# endif -# define stderr stdin - if (_i==0) GP_ABORT(); - if (_i==1) GP_ABORT("MSG"); - if (_i==2) GP_ABORT("FORMAT %d", _i); - if (_i==3) GP_ASSERT(1==0); - if (_i==4) GP_ASSERT(1==0, "MSG"); - if (_i==5) GP_ASSERT(1==0, "FORMAT %d", _i); - if (_i==6) GP_CHECK(1==0); - if (_i==7) GP_CHECK(1==0, "MSG"); - if (_i==8) GP_CHECK(1==0, "FORMAT %d", _i); -} -GP_ENDTEST - -GP_TEST(assert_check_nop) -{ - /* Also tests % in conditon */ - GP_ASSERT(7 % 3 == 1); - GP_ASSERT(7 % 3 == 1, "MSG"); - GP_CHECK(7 % 3 == 1); - GP_CHECK(7 % 3 == 1, "MSG"); -} -GP_ENDTEST diff --git a/tests/core_old/GP_Convert.test.c b/tests/core_old/GP_Convert.test.c deleted file mode 100644 index 28bd28a..0000000 --- a/tests/core_old/GP_Convert.test.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 2011 - Tomas Gavenciak gavento@ucw.cz - */ - -#include "GP_Tests.h" -#include "GP_Convert.h" -#include "GP_TestingCore.h" - -GP_SUITE(GP_Convert) - -GP_TEST(BasicPixelConversions) -{ - GP_Pixel p1, p2; - p1 = GP_RGBAToPixel(255, 255, 255, 255, GP_PIXEL_RGBA8888); - fail_unless(p1 == 0xffffffff); - p1 = GP_RGBAToPixel(0, 0, 0, 0, GP_PIXEL_RGBA8888); - fail_unless(p1 == 0x0); - p1 = GP_RGBToPixel(0x12, 0x34, 0x56, GP_PIXEL_RGB888); - fail_unless(p1 == 0x123456); - GP_CHECK_EqualColors(p1, GP_PIXEL_RGB888, p1, GP_PIXEL_RGB888); - - p1 = GP_RGB888ToPixel(GP_RGBToPixel(0x12, 0x34, 0x56, GP_PIXEL_RGB888), GP_PIXEL_G4); - p2 = GP_RGBAToPixel(0x12, 0x34, 0x56, 0x78, GP_PIXEL_G2); - GP_CHECK_EqualColors(p1, GP_PIXEL_G4, p2, GP_PIXEL_G2); -} -GP_ENDTEST - diff --git a/tests/core_old/GP_Convert.test.gen.c.t b/tests/core_old/GP_Convert.test.gen.c.t deleted file mode 100644 index e8180a9..0000000 --- a/tests/core_old/GP_Convert.test.gen.c.t +++ /dev/null @@ -1,38 +0,0 @@ -%% extends "base.test.c.t" - -%% block body -#include "GP_Tests.h" -#include "GP_Convert.h" -#include "GP_TestingCore.h" - -GP_SUITE(GP_Convert) - -%% call(pt) test_for_all_pixeltypes("GP_ConvertPixel_for", - opts="loop_start=0, loop_end=4", - palette=False) - GP_Pixel p1 = GP_RandomColor(GP_PIXEL_{{ pt.name }}); - GP_Pixel p2 = GP_ConvertPixel(p1, GP_PIXEL_{{ pt.name }}, GP_PIXEL_RGBA8888); - GP_Pixel p3 = GP_ConvertPixel(p2, GP_PIXEL_RGBA8888, GP_PIXEL_{{ pt.name }}); - GP_CHECK_EqualColors(p1, GP_PIXEL_{{ pt.name }}, p3, GP_PIXEL_{{ pt.name }}); - GP_CHECK_EqualColors(p1, GP_PIXEL_{{ pt.name }}, p2, GP_PIXEL_RGBA8888); -%% endcall - -%% call(pt) test_for_all_pixeltypes("WhiteStaysWhite_via", - opts="loop_start=0, loop_end=4", - palette=False) - GP_Pixel p1 = GP_RGBToPixel(255, 255, 255, GP_PIXEL_RGB888); - GP_Pixel p2 = GP_RGB888ToPixel(p1, GP_PIXEL_{{ pt.name }}); - GP_Pixel p3 = GP_PixelToRGB888(p2, GP_PIXEL_{{ pt.name }}); - GP_CHECK_EqualColors(p1, GP_PIXEL_RGB888, p3, GP_PIXEL_RGB888); -%% endcall - -%% call(pt) test_for_all_pixeltypes("BlackStaysBlack_via", - opts="loop_start=0, loop_end=4", - palette=False) - GP_Pixel p1 = GP_RGBToPixel(0, 0, 0, GP_PIXEL_RGB888); - GP_Pixel p2 = GP_RGB888ToPixel(p1, GP_PIXEL_{{ pt.name }}); - GP_Pixel p3 = GP_PixelToRGB888(p2, GP_PIXEL_{{ pt.name }}); - GP_CHECK_EqualColors(p1, GP_PIXEL_RGB888, p3, GP_PIXEL_RGB888); -%% endcall - -%% endblock body diff --git a/tests/core_old/GP_MixPixels.test.gen.c.t b/tests/core_old/GP_MixPixels.test.gen.c.t deleted file mode 100644 index cb2a6fb..0000000 --- a/tests/core_old/GP_MixPixels.test.gen.c.t +++ /dev/null @@ -1,51 +0,0 @@ -%% extends "base.test.c.t" - -%% block body -#include "GP_Tests.h" -#include "GP_Core.h" -#include "GP_MixPixels.gen.h" -#include "GP_TestingCore.h" - -GP_SUITE(GP_MixPixels) - -%% call(pt) test_for_all_pixeltypes("MixPixelsWhiteStaysWhite_via", - opts="loop_start=0, loop_end=4", - palette=False) - GP_Pixel p1 = GP_RGBToPixel(255, 255, 255, GP_PIXEL_{{ pt.name }}); - GP_Pixel p2 = GP_RGBToPixel(255, 255, 255, GP_PIXEL_{{ pt.name }}); - GP_Pixel p3; - int i; - for (i = 0; i < 256; i++) { - p3 = GP_MIX_PIXELS_{{ pt.name }}(p1, p2, i); - GP_CHECK_EqualColors(p1, GP_PIXEL_{{ pt.name }}, p3, GP_PIXEL_{{ pt.name }}); - } -%% endcall - -%% call(pt) test_for_all_pixeltypes("MixPixelsBlackStaysBlack_via", - opts="loop_start=0, loop_end=4", - palette=False) - GP_Pixel p1 = GP_RGBToPixel(0, 0, 0, GP_PIXEL_{{ pt.name }}); - GP_Pixel p2 = GP_RGBToPixel(0, 0, 0, GP_PIXEL_{{ pt.name }}); - GP_Pixel p3; - int i; - for (i = 0; i < 256; i++) { - p3 = GP_MIX_PIXELS_{{ pt.name }}(p1, p2, i); - GP_CHECK_EqualColors(p1, GP_PIXEL_{{ pt.name }}, p3, GP_PIXEL_{{ pt.name }}); - } -%% endcall - -%% call(pt) test_for_all_pixeltypes("MixPixelsSymmetry_via", - opts="loop_start=0, loop_end=4", - palette=False) - GP_Pixel p1 = GP_RGBToPixel(0, 124, 12, GP_PIXEL_{{ pt.name }}); - GP_Pixel p2 = GP_RGBToPixel(255, 99, 0, GP_PIXEL_{{ pt.name }}); - GP_Pixel p3, p4; - int i; - for (i = 0; i < 256; i++) { - p3 = GP_MIX_PIXELS_{{ pt.name }}(p1, p2, i); - p4 = GP_MIX_PIXELS_{{ pt.name }}(p2, p1, 255 - i); - GP_CHECK_EqualColors(p3, GP_PIXEL_{{ pt.name }}, p4, GP_PIXEL_{{ pt.name }}); - } -%% endcall - -%% endblock body
http://repo.or.cz/w/gfxprim.git/commit/05b99f21ccbb74999f9447dfcc922b3160c9a...
commit 05b99f21ccbb74999f9447dfcc922b3160c9a1f8 Author: Cyril Hrubis metan@ucw.cz Date: Sat Dec 8 16:30:49 2012 +0100
tests: gfx: Line.c: Cleanup and edhance tests.
diff --git a/tests/gfx/Line.c b/tests/gfx/Line.c index 4c15718..f3739e8 100644 --- a/tests/gfx/Line.c +++ b/tests/gfx/Line.c @@ -31,69 +31,24 @@
#include "common.h"
-static const char line_5_5_5_5_11x11[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +struct testcase { + /* line description */ + GP_Coord x0; + GP_Coord y0; + GP_Coord x1; + GP_Coord y1; + + /* expected result */ + GP_Size w, h; + const char pixmap[]; };
-static const char line_1_5_9_5_11x11[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static const char line_0_0_10_10_11x11[] = { - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -}; - -static const char line_0_0_11_5_11x11[] = { - 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static int test_line(const char *pattern, GP_Size w, GP_Size h, - GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1) +static int test_line(const struct testcase *t) { GP_Context *c; int err;
- c = GP_ContextAlloc(w, h, GP_PIXEL_G8); + c = GP_ContextAlloc(t->w, t->h, GP_PIXEL_G8);
if (c == NULL) { tst_err("Failed to allocate context"); @@ -103,51 +58,142 @@ static int test_line(const char *pattern, GP_Size w, GP_Size h, /* zero the pixels buffer */ memset(c->pixels, 0, c->w * c->h);
- GP_Line(c, x0, y0, x1, y1, 1); + GP_Line(c, t->x0, t->y0, t->x1, t->y1, 1);
- err = compare_buffers(pattern, c); + err = compare_buffers(t->pixmap, c);
- if (err) { - tst_msg("Patterns are different"); + if (err) return TST_FAILED; - }
return TST_SUCCESS; }
-static int test_line_5_5_5_5(void) -{ - return test_line(line_5_5_5_5_11x11, 11, 11, 5, 5, 5, 5); -} +static struct testcase testcase_line_1px = { + .x0 = 1, + .y0 = 1, + .x1 = 1, + .y1 = 1,
-static int test_line_1_5_9_5(void) -{ - return test_line(line_1_5_9_5_11x11, 11, 11, 1, 5, 9, 5); -} + .w = 3, + .h = 3,
-static int test_line_0_0_10_10(void) -{ - return test_line(line_0_0_10_10_11x11, 11, 11, 0, 0, 10, 10); -} + .pixmap = { + 0, 0, 0, + 0, 1, 0, + 0, 0, 0, + } +};
-static int test_line__1__1_11_11(void) -{ - return test_line(line_0_0_10_10_11x11, 11, 11, -1, -1, 11, 11); -} +static struct testcase testcase_line_horiz = { + .x0 = 2, + .y0 = 2, + .x1 = 8, + .y1 = 2, + + .w = 11, + .h = 5, + + .pixmap = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + } +};
-static int test_line_0_0_11_5(void) -{ - return test_line(line_0_0_11_5_11x11, 11, 11, 0, 0, 11, 5); -} +static struct testcase testcase_line_vert = { + .x0 = 2, + .y0 = 2, + .x1 = 2, + .y1 = 8, + + .w = 5, + .h = 11, + + .pixmap = { + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + } +}; + +static struct testcase testcase_line_45 = { + .x0 = 0, + .y0 = 0, + .x1 = 10, + .y1 = 10, + + .w = 11, + .h = 11, + + .pixmap = { + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + } +}; + +static struct testcase testcase_line_15 = { + .x0 = 0, + .y0 = 1, + .x1 = 11, + .y1 = 6, + + .w = 11, + .h = 8, + + .pixmap = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + } +};
const struct tst_suite tst_suite = { .suite_name = "GFX Line Testsuite", .tests = { - {.name = "Line 5x5 - 5x5", .tst_fn = test_line_5_5_5_5}, - {.name = "Line 1x5 - 9x5", .tst_fn = test_line_1_5_9_5}, - {.name = "Line 0x0 - 10x10", .tst_fn = test_line_0_0_10_10}, - {.name = "Line 0x0 - 11x5", .tst_fn = test_line_0_0_11_5}, - {.name = "Line -1x-1 - 11x11", .tst_fn = test_line__1__1_11_11}, + {.name = "Line 1px", + .tst_fn = test_line, + .data = &testcase_line_1px}, + + {.name = "Line Horizontal", + .tst_fn = test_line, + .data = &testcase_line_horiz}, + + {.name = "Line Vertical", + .tst_fn = test_line, + .data = &testcase_line_vert}, + + {.name = "Line 45 degrees", + .tst_fn = test_line, + .data = &testcase_line_45}, + + {.name = "Line 15 degrees", + .tst_fn = test_line, + .data = &testcase_line_15}, + {.name = NULL} } };
http://repo.or.cz/w/gfxprim.git/commit/5aae2f560739a490f9a9ac203da89abad1fb3...
commit 5aae2f560739a490f9a9ac203da89abad1fb3eba Author: Cyril Hrubis metan@ucw.cz Date: Sat Dec 8 16:11:50 2012 +0100
tests: gfx: common.c: Edhance the error output.
diff --git a/tests/gfx/common.c b/tests/gfx/common.c index 34bbf12..a52d007 100644 --- a/tests/gfx/common.c +++ b/tests/gfx/common.c @@ -37,10 +37,33 @@ static void dump_buffer(const char *pattern, int w, int h)
void dump_buffers(const char *pattern, const GP_Context *c) { - printf("Expected patternn"); + printf("Expected pattern:n"); dump_buffer(pattern, c->w, c->h); - printf("Rendered patternn"); + printf("Rendered pattern:n"); dump_buffer((char*)c->pixels, c->w, c->h); + printf("Difference:n"); + + unsigned int x, y; + + for (y = 0; y < c->h; y++) { + for (x = 0; x < c->w; x++) { + unsigned int idx = x + y * c->w; + char p = ((char*)c->pixels)[idx]; + + if (pattern[idx] != p) { + /* TODO: we expect background to be 0 */ + if (p == 0) + printf(" x "); + else + printf(" * "); + } else { + printf("%2x ", pattern[idx]); + } + + } + + printf("n"); + } }
int compare_buffers(const char *pattern, const GP_Context *c) @@ -50,10 +73,10 @@ int compare_buffers(const char *pattern, const GP_Context *c)
for (x = 0; x < c->w; x++) { for (y = 0; y < c->h; y++) { - if (pattern[x + y * c->w] != - ((char*)c->pixels)[x + y * c->w]) { + unsigned int idx = x + y * c->w; + + if (pattern[idx] != ((char*)c->pixels)[idx]) err++; - } } }
http://repo.or.cz/w/gfxprim.git/commit/6b103927dac437610150583917b659a5983c1...
commit 6b103927dac437610150583917b659a5983c189c Author: Cyril Hrubis metan@ucw.cz Date: Sat Dec 8 16:02:29 2012 +0100
tst: gfx: common.c: Fix another typo.
diff --git a/tests/gfx/common.c b/tests/gfx/common.c index 57d5db4..34bbf12 100644 --- a/tests/gfx/common.c +++ b/tests/gfx/common.c @@ -50,7 +50,7 @@ int compare_buffers(const char *pattern, const GP_Context *c)
for (x = 0; x < c->w; x++) { for (y = 0; y < c->h; y++) { - if (pattern[x + y * c->h] != + if (pattern[x + y * c->w] != ((char*)c->pixels)[x + y * c->w]) { err++; }
http://repo.or.cz/w/gfxprim.git/commit/1a6517e66dab6dc2bd8e91366f852f68b3087...
commit 1a6517e66dab6dc2bd8e91366f852f68b30870a4 Author: Cyril Hrubis metan@ucw.cz Date: Sat Dec 8 16:01:31 2012 +0100
tests: gfx: Polygon.c: Make use of new tst interface.
diff --git a/tests/gfx/Polygon.c b/tests/gfx/Polygon.c index 16affdd..c683102 100644 --- a/tests/gfx/Polygon.c +++ b/tests/gfx/Polygon.c @@ -260,75 +260,53 @@ struct testcase testcase_6px_triangle = { } };
-static int test_1_edge(void) -{ - return test_polygon(&testcase_1_edge); -} - -static int test_5_edges_1px(void) -{ - return test_polygon(&testcase_5_edges_1px); -} - -static int test_line_vert_3px(void) -{ - return test_polygon(&testcase_line_vert_3px); -} - -static int test_line_horiz_3px(void) -{ - return test_polygon(&testcase_line_horiz_3px); -} - -static int test_line_3px(void) -{ - return test_polygon(&testcase_line_3px); -} - -static int test_line_4px(void) -{ - return test_polygon(&testcase_line_4px); -} - -static int test_2x2_square(void) -{ - return test_polygon(&testcase_2x2_square); -} - -static int test_3x3_square(void) -{ - return test_polygon(&testcase_3x3_square); -} - -static int test_4x4_square(void) -{ - return test_polygon(&testcase_4x4_square); -} - -static int test_4px_triangle(void) -{ - return test_polygon(&testcase_4px_triangle); -} - -static int test_6px_triangle(void) -{ - return test_polygon(&testcase_6px_triangle); -} - const struct tst_suite tst_suite = { .suite_name = "Polygon Testsuite", .tests = { - {.name = "1 Edge Polygon", .tst_fn = test_1_edge}, - {.name = "5 Edges 1px Polygon", .tst_fn = test_5_edges_1px}, - {.name = "Vertical Line 3px Polygon", .tst_fn = test_line_vert_3px}, - {.name = "Horizonval Line 3px Polygon", .tst_fn = test_line_horiz_3px}, - {.name = "Line 3px Polygon", .tst_fn = test_line_3px}, - {.name = "Line 4px Polygon", .tst_fn = test_line_4px}, - {.name = "2x2 Square Polygon", .tst_fn = test_2x2_square}, - {.name = "3x3 Square Polygon", .tst_fn = test_3x3_square}, - {.name = "4x4 Square Polygon", .tst_fn = test_4x4_square}, - {.name = "Triangle 4px Polygon", .tst_fn = test_4px_triangle}, - {.name = "Triangle 6px Polygon", .tst_fn = test_6px_triangle}, + {.name = "1 Edge Polygon", + .tst_fn = test_polygon, + .data = &testcase_1_edge}, + + {.name = "5 Edges 1px Polygon", + .tst_fn = test_polygon, + .data = &testcase_5_edges_1px}, + + {.name = "Vertical Line 3px Polygon", + .tst_fn = test_polygon, + .data = &testcase_line_vert_3px}, + + {.name = "Horizontal Line 3px Polygon", + .tst_fn = test_polygon, + .data = &testcase_line_horiz_3px}, + + {.name = "Line 3px Polygon", + .tst_fn = test_polygon, + .data = &testcase_line_3px}, + + {.name = "Line 4px Polygon", + .tst_fn = test_polygon, + .data = &testcase_line_4px}, + + {.name = "2x2 Square Polygon", + .tst_fn = test_polygon, + .data = &testcase_2x2_square}, + + {.name = "3x3 Square Polygon", + .tst_fn = test_polygon, + .data = &testcase_3x3_square}, + + {.name = "4x4 Square Polygon", + .tst_fn = test_polygon, + .data = &testcase_4x4_square}, + + {.name = "Triangle 4px Polygon", + .tst_fn = test_polygon, + .data = &testcase_4px_triangle}, + + {.name = "Triangle 6px Polygon", + .tst_fn = test_polygon, + .data = &testcase_6px_triangle}, + {.name = NULL} } };
http://repo.or.cz/w/gfxprim.git/commit/f277c6a354d94aa9ddd50240711a5b80eb411...
commit f277c6a354d94aa9ddd50240711a5b80eb4116a8 Author: Cyril Hrubis metan@ucw.cz Date: Sat Dec 8 15:55:37 2012 +0100
tests: framework: Change tst interface slightly.
Now it's possible to pass a pointer to the test function which simplifies usage of the framework greatly.
diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index e60736b..ca2b079 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -268,6 +268,18 @@ int tst_err(const char *fmt, ...) return ret; }
+static int job_run(struct tst_job *job) +{ + int (*fn1)(void) = job->test->tst_fn; + int (*fn2)(void*) = job->test->tst_fn; + void *data = job->test->data; + + if (data) + return fn2(data); + + return fn1(); +} + /* * Run benchmark job and compute result */ @@ -282,7 +294,7 @@ static int tst_job_benchmark(struct tst_job *job) int ret; /* Warm up */ - ret = job->test->tst_fn(); + ret = job_run(job); if (ret) return ret; @@ -291,7 +303,7 @@ static int tst_job_benchmark(struct tst_job *job) for (i = 0; i < iter; i++) { clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &cputime_start); - ret = job->test->tst_fn(); + ret = job_run(job); if (ret) return ret; @@ -404,7 +416,7 @@ void tst_job_run(struct tst_job *job) if (job->test->bench_iter) ret = tst_job_benchmark(job); else - ret = job->test->tst_fn(); + ret = job_run(job);
if (job->test->flags & TST_CHECK_MALLOC) { tst_malloc_check_stop(); diff --git a/tests/framework/tst_test.h b/tests/framework/tst_test.h index 937f1cf..b19e40d 100644 --- a/tests/framework/tst_test.h +++ b/tests/framework/tst_test.h @@ -65,8 +65,13 @@ struct tst_test { * data are filled. */ unsigned int bench_iter; + /* test function */ - int (*tst_fn)(void); + void *tst_fn; + + /* test private data pointer */ + void *data; + /* time limit in seconds 0 == unlimited */ unsigned int timeout; /* test flags */
-----------------------------------------------------------------------
Summary of changes: gen.mk | 4 - include/core/Makefile | 5 +- pylib/bin/generate_collected_tests.py | 35 ---- pylib/gp_codegen/test_collection.py | 96 ---------- tests/core/Makefile | 3 - tests/core/WritePixel_testsuite.gen.c.t | 2 +- tests/core_old/GP_Common.test.c | 103 ----------- tests/core_old/GP_Convert.test.c | 27 --- tests/core_old/GP_Convert.test.gen.c.t | 38 ---- tests/core_old/GP_MixPixels.test.gen.c.t | 51 ------ tests/framework/tst_job.c | 18 ++- tests/framework/tst_log.c | 46 +----- tests/framework/tst_log.h | 11 +- tests/framework/tst_suite.c | 6 +- tests/framework/tst_test.h | 7 +- tests/gfx/Circle.c | 288 ++++++++++++++++++------------ tests/gfx/FillCircle.c | 243 +++++++++++++++++++++++++ tests/gfx/Line.c | 220 ++++++++++++++--------- tests/gfx/Makefile | 3 +- tests/gfx/Polygon.c | 110 +++++------- tests/gfx/common.c | 33 +++- tests/gfx/runtest.sh | 3 +- 22 files changed, 662 insertions(+), 690 deletions(-) delete mode 100644 pylib/bin/generate_collected_tests.py delete mode 100644 pylib/gp_codegen/test_collection.py delete mode 100644 tests/core_old/GP_Common.test.c delete mode 100644 tests/core_old/GP_Convert.test.c delete mode 100644 tests/core_old/GP_Convert.test.gen.c.t delete mode 100644 tests/core_old/GP_MixPixels.test.gen.c.t create mode 100644 tests/gfx/FillCircle.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.