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 dbcccdb698055de18b0adb88101bb0d450cb4d43 (commit) via 2cbfeef63486a89fd16bf49e21280b1d8fa36ca9 (commit) via ac1ca3c9ac663de025c756572016f59c3da732e1 (commit) via 91a95ef7accb991b8c35c573d946fec625fabf6e (commit) from 929e7070a0d18580bbf3eeb17b02803099acbb5f (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/dbcccdb698055de18b0adb88101bb0d450cb4...
commit dbcccdb698055de18b0adb88101bb0d450cb4d43 Author: Cyril Hrubis metan@ucw.cz Date: Sun Aug 26 15:52:53 2012 +0200
tests: Add sample loaders tests.
Ah, looks like we found a memleak allready.
diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile index 7b1285a..9a5aff5 100644 --- a/tests/loaders/Makefile +++ b/tests/loaders/Makefile @@ -4,6 +4,7 @@ include $(TOPDIR)/pre.mk CSOURCES=$(shell echo *.c)
LDFLAGS+=-L../framework/ +LDLIBS+=$(shell $(TOPDIR)/gfxprim-config --libs --libs-loaders) LDLIBS+=-ltst_preload -ldl -ltst CFLAGS+=-I../framework/
diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c index 50fab55..1f05961 100644 --- a/tests/loaders/loaders_suite.c +++ b/tests/loaders/loaders_suite.c @@ -20,28 +20,117 @@ * * *****************************************************************************/
-#include <stdlib.h> -#include <unistd.h> -#include <stdio.h> -#include <errno.h> #include <string.h> +#include <errno.h> + +#include <core/GP_Context.h> +#include <loaders/GP_Loaders.h>
#include "tst_test.h" -#include "tst_alloc_barriers.h" -#include "tst_preload_FILE.h"
-int success_fn(void) +static int test_PNG_Load_Save(void) { - tst_report(0, "This test does nothing"); - tst_report(0, "But successfully"); - + GP_Context *img, *res; + + img = GP_ContextAlloc(100, 100, GP_PIXEL_RGB888); + + if (GP_SavePNG(img, "test.png", NULL)) { + tst_report(0, "Failed to save PNG: %s", strerror(errno)); + return TST_FAILED; + } + + res = GP_LoadPNG("test.png", NULL); + + if (res == NULL) { + tst_report(0, "Failed to load PNG: %s", strerror(errno)); + return TST_FAILED; + } + + GP_ContextFree(img); + GP_ContextFree(res); + + return TST_SUCCESS; +} + +static int test_JPG_Load_Save(void) +{ + GP_Context *img, *res; + + img = GP_ContextAlloc(100, 100, GP_PIXEL_RGB888); + + if (GP_SaveJPG(img, "test.jpg", NULL)) { + tst_report(0, "Failed to save JPG: %s", strerror(errno)); + return TST_FAILED; + } + + res = GP_LoadJPG("test.jpg", NULL); + + if (res == NULL) { + tst_report(0, "Failed to load JPG: %s", strerror(errno)); + return TST_FAILED; + } + + GP_ContextFree(img); + GP_ContextFree(res); + + return TST_SUCCESS; +} + +static int test_PNG_Load_fail(void) +{ + GP_Context *img; + + img = GP_LoadPNG("nonexistent.png", NULL); + + int saved_errno = errno; + + if (img != NULL) { + tst_report(0, "Test succedded unexpectedly"); + return TST_FAILED; + } + + if (saved_errno != ENOENT) { + tst_report(0, "Expected errno = ENOENT, have %s", + strerror(errno)); + return TST_FAILED; + } + + return TST_SUCCESS; +} + +static int test_JPG_Load_fail(void) +{ + GP_Context *img; + + img = GP_LoadJPG("nonexistent.png", NULL); + + int saved_errno = errno; + + if (img != NULL) { + tst_report(0, "Test succedded unexpectedly"); + return TST_FAILED; + } + + if (saved_errno != ENOENT) { + tst_report(0, "Expected errno = ENOENT, have %s", + strerror(errno)); + return TST_FAILED; + } + return TST_SUCCESS; }
const struct tst_suite tst_suite = { .suite_name = "Image Loaders testsuite", .tests = { - {.name = "Success test", .tst_fn = success_fn}, + {.name = "PNG Load/Save", .tst_fn = test_PNG_Load_Save, + .flags = TST_TMPDIR | TST_CHECK_MALLOC}, + {.name = "JPG Load/Save", .tst_fn = test_JPG_Load_Save, + .flags = TST_TMPDIR | TST_CHECK_MALLOC}, + {.name = "PNG Load fail", .tst_fn = test_PNG_Load_fail, + .flags = TST_TMPDIR}, + {.name = "JPG Load fail", .tst_fn = test_JPG_Load_fail, + .flags = TST_TMPDIR}, {.name = NULL}, } }; diff --git a/tests/loaders/runtest.sh b/tests/loaders/runtest.sh index 707cc20..acd4771 100755 --- a/tests/loaders/runtest.sh +++ b/tests/loaders/runtest.sh @@ -9,4 +9,4 @@ # export LIBC_FATAL_STDERR_=1
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so ./loaders "$@" +LD_PRELOAD=`pwd`/../framework/libtst_preload.so ./loaders_suite "$@"
http://repo.or.cz/w/gfxprim.git/commit/2cbfeef63486a89fd16bf49e21280b1d8fa36...
commit 2cbfeef63486a89fd16bf49e21280b1d8fa36ca9 Author: Cyril Hrubis metan@ucw.cz Date: Sun Aug 26 15:43:13 2012 +0200
tests: Fix / in test name bug && constant rename.
diff --git a/tests/framework/test.c b/tests/framework/test.c index 1174d14..914f2d2 100644 --- a/tests/framework/test.c +++ b/tests/framework/test.c @@ -195,8 +195,8 @@ const struct tst_suite tst_suite = { {.name = "Stack overflow test", .tst_fn = stack_overflow_fn}, {.name = "Timeout test", .tst_fn = timeout_fn, .timeout = 1}, {.name = "Tempdir test", .tst_fn = temp_dir_fn, .flags = TST_TMPDIR}, - {.name = "Mem Leak test", .tst_fn = malloc_leak_fn, .flags = TST_MALLOC_CHECK}, - {.name = "Mem Ok test", .tst_fn = malloc_ok_fn, .flags = TST_MALLOC_CHECK}, + {.name = "Mem Leak test", .tst_fn = malloc_leak_fn, .flags = TST_CHECK_MALLOC}, + {.name = "Mem Ok test", .tst_fn = malloc_ok_fn, .flags = TST_CHECK_MALLOC}, {.name = "Double free()", .tst_fn = double_free}, {.name = "Barrier allocation", .tst_fn = barrier_allocation}, {.name = "Failed FILE", .tst_fn = fail_FILE, .flags = TST_TMPDIR}, diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index 2eda133..469f22d 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -131,18 +131,23 @@ static void remove_tmpdir(const char *path) */ static void create_tmpdir(const char *name, char *template, size_t size) { - /* Create template from test name */ - snprintf(template, size, "/tmp/ctest_%s_XXXXXX", name); + char safe_name[256];
/* Fix any funny characters in test name */ - char *s = template; + snprintf(safe_name, sizeof(safe_name), "%s", name); + + char *s = safe_name;
while (*s != '0') { - if (!isalnum(*s) && *s != '/') + if (!isalnum(*s)) *s = '_'; s++; }
+ /* Create template from test name */ + snprintf(template, size, "/tmp/ctest_%s_XXXXXX", safe_name); + + if (mkdtemp(template) == NULL) { tst_warn("mkdtemp(%s) failed: %s", template, strerror(errno)); exit(TST_INTERR); @@ -262,11 +267,11 @@ void tst_job_run(struct tst_job *job) }
/* Redirect stderr/stdout TODO: catch its output */ - if (freopen("/dev/null", "w", stderr)) - tst_warn("freopen(stderr) failed: %s", strerror(errno)); +// if (freopen("/dev/null", "w", stderr)) +// tst_warn("freopen(stderr) failed: %s", strerror(errno));
- if (freopen("/dev/null", "w", stdout)) - tst_warn("freopen(stderr) failed: %s", strerror(errno)); +// if (freopen("/dev/null", "w", stdout)) +// tst_warn("freopen(stderr) failed: %s", strerror(errno));
/* Create directory in /tmp/ and chdir into it. */ if (job->test->flags & TST_TMPDIR) @@ -284,13 +289,13 @@ void tst_job_run(struct tst_job *job) clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &job->cpu_time); write_timespec(job, 'c', &job->cpu_time);
- if (job->test->flags & TST_MALLOC_CHECK) + if (job->test->flags & TST_CHECK_MALLOC) tst_malloc_check_start();
/* Run test */ ret = job->test->tst_fn();
- if (job->test->flags & TST_MALLOC_CHECK) { + if (job->test->flags & TST_CHECK_MALLOC) { tst_malloc_check_stop(); tst_malloc_check_report(&job->malloc_stats);
diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c index 57234e3..dcdaced 100644 --- a/tests/framework/tst_log.c +++ b/tests/framework/tst_log.c @@ -156,7 +156,7 @@ static int append_html(struct tst_job *job, FILE *f) struct tst_msg *msg;
/* If calculated include malloc report */ - if (job->test->flags & TST_MALLOC_CHECK) + if (job->test->flags & TST_CHECK_MALLOC) malloc_stats_html(job, f, padd);
for (msg = job->store.first; msg != NULL; msg = msg->next) { @@ -223,7 +223,7 @@ static int append_json(struct tst_job *job, FILE *f) append_msg_json(job, f); /* If calculated include malloc report */ - if (job->test->flags & TST_MALLOC_CHECK) + if (job->test->flags & TST_CHECK_MALLOC) append_malloc_stats_json(job, f); /* Time statistics */ diff --git a/tests/framework/tst_test.h b/tests/framework/tst_test.h index e38b92f..27eaff5 100644 --- a/tests/framework/tst_test.h +++ b/tests/framework/tst_test.h @@ -44,7 +44,7 @@ enum tst_flags { /* * Check malloc for memory leaks. */ - TST_MALLOC_CHECK = 0x02, + TST_CHECK_MALLOC = 0x02, };
struct tst_test {
http://repo.or.cz/w/gfxprim.git/commit/ac1ca3c9ac663de025c756572016f59c3da73...
commit ac1ca3c9ac663de025c756572016f59c3da732e1 Author: Cyril Hrubis metan@ucw.cz Date: Sun Aug 26 15:41:55 2012 +0200
tests: Add test framework build as default target.
diff --git a/tests/Makefile b/tests/Makefile index d7405d2..f965da6 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,3 +1,8 @@ TOPDIR=.. -SUBDIRS=core SDL drivers +include $(TOPDIR)/pre.mk + +SUBDIRS=core SDL drivers framework loaders + +loaders: framework + include $(TOPDIR)/post.mk
http://repo.or.cz/w/gfxprim.git/commit/91a95ef7accb991b8c35c573d946fec625fab...
commit 91a95ef7accb991b8c35c573d946fec625fabf6e Author: Cyril Hrubis metan@ucw.cz Date: Sun Aug 26 15:22:33 2012 +0200
tests: Add global test main.
diff --git a/tests/framework/Makefile b/tests/framework/Makefile index 9482807..709f907 100644 --- a/tests/framework/Makefile +++ b/tests/framework/Makefile @@ -5,19 +5,22 @@ CSOURCES=$(shell echo *.c)
INCLUDE= LDFLAGS+=-L. -LDLIBS+=-ltst_preload -ldl +LDLIBS+=-ltst_preload -ldl -ltst CFLAGS+=
-test: tst_test.o tst_job.o tst_msg.o tst_log.o +test: libtst.a
APPS=test
-ALL+=libtst_preload.so +ALL+=libtst_preload.so libtst.a
libtst_preload.so: tst_preload.o tst_alloc_barriers.o tst_preload_FILE.o gcc -Wl,-soname -Wl,tst_preload.so --shared -ldl -fPIC $^ -o $@
-CLEAN+=libtst_preload.so +libtst.a: tst_test.o tst_job.o tst_msg.o tst_log.o tst_main.o + ar rcs $@ $^ + +CLEAN+=libtst_preload.so libtst.a log.html log.json
include $(TOPDIR)/app.mk include $(TOPDIR)/post.mk diff --git a/tests/framework/runtest.sh b/tests/framework/runtest.sh index e38592d..03e99b8 100755 --- a/tests/framework/runtest.sh +++ b/tests/framework/runtest.sh @@ -9,4 +9,4 @@ # export LIBC_FATAL_STDERR_=1
-LD_PRELOAD=`pwd`/libtst_preload.so ./test +LD_PRELOAD=`pwd`/libtst_preload.so ./test "$@" diff --git a/tests/framework/test.c b/tests/framework/test.c index f10d404..1174d14 100644 --- a/tests/framework/test.c +++ b/tests/framework/test.c @@ -186,7 +186,7 @@ int fail_FILE(void) return TST_SUCCESS; }
-const struct tst_suite suite = { +const struct tst_suite tst_suite = { .suite_name = "Testing Framework Example", .tests = { {.name = "Success test", .tst_fn = success_fn}, @@ -203,17 +203,3 @@ const struct tst_suite suite = { {.name = NULL}, } }; - -int main(void) -{ - fprintf(stderr, "(Listing testsuite tests)n"); - tst_list_suite(&suite); - - fprintf(stderr, "n(Running selected test)n"); - tst_run_suite(&suite, "Sigsegv test"); - - fprintf(stderr, "n(Running whole suite)n"); - tst_run_suite(&suite, NULL); - - return 0; -} diff --git a/tests/framework/tst_main.c b/tests/framework/tst_main.c new file mode 100644 index 0000000..28020a0 --- /dev/null +++ b/tests/framework/tst_main.c @@ -0,0 +1,67 @@ +/***************************************************************************** + * 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 <unistd.h> +#include <stdlib.h> +#include <stdio.h> + +#include "tst_test.h" + +extern const struct tst_suite tst_suite; + +void print_help(void) +{ + fprintf(stderr, "Test suite '%s' Usage:nn", tst_suite.suite_name); + fprintf(stderr, "-h prints this helpn"); + fprintf(stderr, "-l list all testsn"); + fprintf(stderr, "-t name runs single test by namen"); + fprintf(stderr, "without any option, all tests are executedn"); +} + +int main(int argc, char *argv[]) +{ + int opt; + + while ((opt = getopt(argc, argv, "hlt:")) != -1) { + switch (opt) { + case 'l': + tst_list_suite(&tst_suite); + return 0; + break; + case 't': + tst_run_suite(&tst_suite, optarg); + return 0; + break; + case 'h': + print_help(); + return 0; + break; + default: + print_help(); + return 1; + } + } + + tst_run_suite(&tst_suite, NULL); + + return 0; +} diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile new file mode 100644 index 0000000..7b1285a --- /dev/null +++ b/tests/loaders/Makefile @@ -0,0 +1,15 @@ +TOPDIR=../.. +include $(TOPDIR)/pre.mk + +CSOURCES=$(shell echo *.c) + +LDFLAGS+=-L../framework/ +LDLIBS+=-ltst_preload -ldl -ltst +CFLAGS+=-I../framework/ + +APPS=loaders_suite + +CLEAN+=libtst_preload.so log.html log.json + +include $(TOPDIR)/app.mk +include $(TOPDIR)/post.mk diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c new file mode 100644 index 0000000..50fab55 --- /dev/null +++ b/tests/loaders/loaders_suite.c @@ -0,0 +1,47 @@ +/***************************************************************************** + * 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 <stdlib.h> +#include <unistd.h> +#include <stdio.h> +#include <errno.h> +#include <string.h> + +#include "tst_test.h" +#include "tst_alloc_barriers.h" +#include "tst_preload_FILE.h" + +int success_fn(void) +{ + tst_report(0, "This test does nothing"); + tst_report(0, "But successfully"); + + return TST_SUCCESS; +} + +const struct tst_suite tst_suite = { + .suite_name = "Image Loaders testsuite", + .tests = { + {.name = "Success test", .tst_fn = success_fn}, + {.name = NULL}, + } +}; diff --git a/tests/framework/runtest.sh b/tests/loaders/runtest.sh similarity index 83% copy from tests/framework/runtest.sh copy to tests/loaders/runtest.sh index e38592d..707cc20 100755 --- a/tests/framework/runtest.sh +++ b/tests/loaders/runtest.sh @@ -9,4 +9,4 @@ # export LIBC_FATAL_STDERR_=1
-LD_PRELOAD=`pwd`/libtst_preload.so ./test +LD_PRELOAD=`pwd`/../framework/libtst_preload.so ./loaders "$@"
-----------------------------------------------------------------------
Summary of changes: tests/Makefile | 7 +- tests/framework/Makefile | 11 +- tests/framework/runtest.sh | 2 +- tests/framework/test.c | 20 +--- tests/framework/tst_job.c | 25 ++-- tests/framework/tst_log.c | 4 +- .../meta_data_dump.c => tests/framework/tst_main.c | 64 +++++----- tests/framework/tst_test.h | 2 +- tests/loaders/Makefile | 16 +++ tests/loaders/loaders_suite.c | 136 ++++++++++++++++++++ tests/{framework => loaders}/runtest.sh | 2 +- 11 files changed, 220 insertions(+), 69 deletions(-) copy demos/c_simple/meta_data_dump.c => tests/framework/tst_main.c (69%) create mode 100644 tests/loaders/Makefile create mode 100644 tests/loaders/loaders_suite.c copy tests/{framework => loaders}/runtest.sh (82%)
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.