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 443c7577a6a1961dde7b5a150e9a3ec25d317260 (commit) from 8ac4aa41dac9e27830da30fc1b2804f4404edaa5 (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/443c7577a6a1961dde7b5a150e9a3ec25d317...
commit 443c7577a6a1961dde7b5a150e9a3ec25d317260 Author: Cyril Hrubis metan@ucw.cz Date: Sun Mar 3 22:57:55 2013 +0100
tests: filters: Add basic test for MirrorH filter.
diff --git a/tests/filters/FilterMirrorH.c b/tests/filters/FilterMirrorH.c new file mode 100644 index 0000000..8aa50ac --- /dev/null +++ b/tests/filters/FilterMirrorH.c @@ -0,0 +1,311 @@ +/***************************************************************************** + * 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-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <errno.h> + +#include <core/GP_Context.h> +#include <filters/GP_Rotate.h> + +#include "tst_test.h" + +#include "common.h" + +struct testcase { + GP_Size w, h; + + GP_PixelType pixel_type; + + uint8_t offset; + + /* result */ + const char *res; + + /* source */ + char src[]; +}; + +static int test_mirror_h(struct testcase *t) +{ + GP_Context src, *c; + int err; + + /* Initialize source context */ + GP_ContextInit(&src, t->w, t->h, t->pixel_type, t->src); + + /* Set offset to emulate non-byte aligned subcontexts */ + src.offset = t->offset; + + /* Test with allocated destination */ + c = GP_ContextAlloc(t->w, t->h, t->pixel_type); + + if (c == NULL) { + tst_err("Failed to allocate context"); + return TST_UNTESTED; + } + + GP_FilterMirrorH(&src, c, NULL); + + err = compare_buffers(t->res, c); + + GP_ContextFree(c); + + /* And with in-place variant */ +// GP_FilterMirrorH(&src, &src, NULL); + +// err |= compare_buffers(t->res, &src); + + if (err) + return TST_FAILED; + + return TST_SUCCESS; +} + +struct testcase testcase_1x1 = { + .w = 1, + .h = 1, + + .pixel_type = GP_PIXEL_G8, + + .res = (const char[]) { + 0xf0, + }, + + .src = { + 0xf0, + } +}; + +struct testcase testcase_2x2 = { + .w = 2, + .h = 2, + + .pixel_type = GP_PIXEL_G8, + + .res = (const char[]) { + 2, 3, + 0, 1, + }, + + .src = { + 0, 1, + 2, 3, + } +}; + +struct testcase testcase_10x2 = { + .w = 10, + .h = 2, + + .pixel_type = GP_PIXEL_G8, + + .res = (const char[]) { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + }, + + .src = { + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + } +}; + +struct testcase testcase_2x3 = { + .w = 2, + .h = 3, + + .pixel_type = GP_PIXEL_G8, + + .res = (const char[]) { + 4, 5, + 2, 3, + 0, 1, + }, + + .src = { + 0, 1, + 2, 3, + 4, 5, + } +}; + + +struct testcase testcase_3x3 = { + .w = 3, + .h = 3, + + .pixel_type = GP_PIXEL_G8, + + .res = (const char[]) { + 6, 7, 8, + 3, 4, 5, + 0, 1, 2, + }, + + .src = { + 0, 1, 2, + 3, 4, 5, + 6, 7, 8, + } +}; + +struct testcase testcase_4x4 = { + .w = 4, + .h = 4, + + .pixel_type = GP_PIXEL_G8, + + .res = (const char[]) { + 12, 13, 14, 15, + 8, 9, 10, 11, + 4, 5, 6, 7, + 0, 1, 2, 3, + }, + + .src = { + 0, 1, 2, 3, + 4, 5, 6, 7, + 8, 9, 10, 11, + 12, 13, 14, 15, + } +}; + +/* Now tests with pixel types that are not byte aligned */ +//TODO: Fix comparsion +struct testcase testcase_G1_16x2 = { + .w = 3, + .h = 2, + + .pixel_type = GP_PIXEL_G1, + + .offset = 4, + + .res = (const char[]) { + 0x0f, 0xaa, 0xf0, + 0xff, 0xff, 0xff, + }, + + .src = { + 0x0f, 0xff, 0xf0, + 0xff, 0xaa, 0xff, + } +}; + +static int abort_callback_fn(GP_ProgressCallback GP_UNUSED(*self)) +{ + return 1; +} + +static GP_ProgressCallback abort_callback = { + .callback = abort_callback_fn, +}; + +static int test_abort(void) +{ + int ret; + GP_Context *c; + + c = GP_ContextAlloc(10, 10, GP_PIXEL_G8); + + if (c == NULL) { + tst_err("Failed to allocate context"); + return TST_UNTESTED; + } + + ret = GP_FilterMirrorH(c, c, &abort_callback); + + if (ret == 0) { + tst_msg("Aborted filter haven't returned non-zero"); + return TST_FAILED; + } + + if (errno != ECANCELED) { + tst_msg("Errno wasn't set to ECANCELED"); + return TST_FAILED; + } + + return TST_SUCCESS; +} + +static int all_pixels(void) +{ + GP_Pixel pixel_type; + + for (pixel_type = 1; pixel_type < GP_PIXEL_MAX; pixel_type++) { + GP_Context *c; + + tst_msg("Trying pixel %s", GP_PixelTypeName(pixel_type)); + + c = GP_ContextAlloc(10, 10, pixel_type); + + if (c == NULL) { + tst_err("Failed to allocate context"); + return TST_UNTESTED; + } + + GP_FilterMirrorH(c, c, NULL); + + GP_ContextFree(c); + } + + return TST_SUCCESS; +} + +const struct tst_suite tst_suite = { + .suite_name = "MirrorH Filter Testsuite", + .tests = { + {.name = "MirrorH 1x1", + .tst_fn = test_mirror_h, + .data = &testcase_1x1}, + + {.name = "MirrorH 2x2", + .tst_fn = test_mirror_h, + .data = &testcase_2x2}, + + {.name = "MirrorH 10x2", + .tst_fn = test_mirror_h, + .data = &testcase_10x2}, + + {.name = "MirrorH 2x3", + .tst_fn = test_mirror_h, + .data = &testcase_2x3}, + + {.name = "MirrorH 3x3", + .tst_fn = test_mirror_h, + .data = &testcase_3x3}, + + {.name = "MirrorH 4x4", + .tst_fn = test_mirror_h, + .data = &testcase_3x3}, + + {.name = "MirrorH G1 16x2", + .tst_fn = test_mirror_h, + .data = &testcase_G1_16x2}, + + {.name = "MirrorH Callback Abort", + .tst_fn = test_abort}, + + {.name = "MirrorH x Pixels", + .tst_fn = all_pixels}, + + {.name = NULL} + } +}; diff --git a/tests/filters/Makefile b/tests/filters/Makefile index aaa6125..b0a590d 100644 --- a/tests/filters/Makefile +++ b/tests/filters/Makefile @@ -3,9 +3,11 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
-APPS=LinearConvolution +APPS=FilterMirrorH
include ../tests.mk
+FilterMirrorH: common.o + include $(TOPDIR)/app.mk include $(TOPDIR)/post.mk diff --git a/tests/filters/common.c b/tests/filters/common.c new file mode 100644 index 0000000..35a6d13 --- /dev/null +++ b/tests/filters/common.c @@ -0,0 +1,87 @@ +/***************************************************************************** + * 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-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <stdio.h> + +#include "common.h" + +static void dump_buffer(const char *pattern, int w, int h) +{ + int x, y; + + for (y = 0; y < h; y++) { + for (x = 0; x < w; x++) + printf("%2x ", (uint8_t)pattern[x + y * w]); + printf("n"); + } +} + +void dump_buffers(const char *pattern, const GP_Context *c) +{ + printf("Expected pattern:n"); + dump_buffer(pattern, c->w, c->h); + 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 ", (uint8_t)pattern[idx]); + } + + } + + printf("n"); + } +} + +int compare_buffers(const char *pattern, const GP_Context *c) +{ + GP_Size x, y; + int err = 0; + + for (x = 0; x < c->w; x++) { + for (y = 0; y < c->h; y++) { + unsigned int idx = x + y * c->w; + + if (pattern[idx] != ((char*)c->pixels)[idx]) + err++; + } + } + + if (err) + dump_buffers(pattern, c); + + return err; +} diff --git a/tests/filters/common.h b/tests/filters/common.h new file mode 100644 index 0000000..65b9d19 --- /dev/null +++ b/tests/filters/common.h @@ -0,0 +1,32 @@ +/***************************************************************************** + * 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 * + * * + *****************************************************************************/ + +#ifndef __COMMON_H__ +#define __COMMON_H__ + +#include <core/GP_Context.h> + +void dump_buffers(const char *pattern, const GP_Context *c); + +int compare_buffers(const char *pattern, const GP_Context *c); + +#endif /* __COMMON_H__ */ diff --git a/tests/filters/runtest.sh b/tests/filters/runtest.sh index 9efe909..c820af1 100755 --- a/tests/filters/runtest.sh +++ b/tests/filters/runtest.sh @@ -9,4 +9,4 @@ # export LIBC_FATAL_STDERR_=1
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./LinearConvolution "$@" +LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./FilterMirrorH "$@" diff --git a/tests/filters/test_list.txt b/tests/filters/test_list.txt new file mode 100644 index 0000000..2f9a127 --- /dev/null +++ b/tests/filters/test_list.txt @@ -0,0 +1,3 @@ +# Filters test list + +FilterMirrorH
-----------------------------------------------------------------------
Summary of changes: tests/filters/FilterMirrorH.c | 311 +++++++++++++++++++++++++++++++++++++++ tests/filters/Makefile | 4 +- tests/{gfx => filters}/common.c | 0 tests/{gfx => filters}/common.h | 0 tests/filters/runtest.sh | 2 +- tests/filters/test_list.txt | 3 + 6 files changed, 318 insertions(+), 2 deletions(-) create mode 100644 tests/filters/FilterMirrorH.c copy tests/{gfx => filters}/common.c (100%) copy tests/{gfx => filters}/common.h (100%) create mode 100644 tests/filters/test_list.txt
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.