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 88500942a4e2dda6951c5abaf6bc05e4bb5d6efc (commit) via d6f1b011de7a541ecd56b6479d649bb8d6a26109 (commit) via a45c066497e510b339d3b9280859530ecf6e5b0c (commit) from b287df058124c3d9039a8bfe5475927a1d5fc68e (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/88500942a4e2dda6951c5abaf6bc05e4bb5d6...
commit 88500942a4e2dda6951c5abaf6bc05e4bb5d6efc Author: Cyril Hrubis metan@ucw.cz Date: Thu Jun 27 20:26:39 2013 +0200
tests: runtest.py: Print name of tests directory.
Prints name of tests directory we are about to run testsuite from.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/runtests.py b/tests/runtests.py index d6619a5..8cd1477 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -98,10 +98,11 @@ def run_tests(resdir, testsdir): runtest = path + '/test_list.txt'
if (os.access(runtest, os.R_OK)): - # Create result directory + # Create result directory curresdir = resdir + '/' + name os.mkdir(curresdir) # Run tests + print("n========= Running " + name + " testsuites =========n") run_test(curresdir, path, runtest)
def main():
http://repo.or.cz/w/gfxprim.git/commit/d6f1b011de7a541ecd56b6479d649bb8d6a26...
commit d6f1b011de7a541ecd56b6479d649bb8d6a26109 Author: Cyril Hrubis metan@ucw.cz Date: Thu Jun 27 20:22:20 2013 +0200
tests: input: Simple test for TimeStamp.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/input/Makefile b/tests/input/Makefile index e5e49bc..7f8726c 100644 --- a/tests/input/Makefile +++ b/tests/input/Makefile @@ -2,9 +2,9 @@ TOPDIR=../..
include $(TOPDIR)/pre.mk
-CSOURCES=Timer.c +CSOURCES=Timer.c TimeStamp.c
-APPS=Timer +APPS=Timer TimeStamp
include ../tests.mk
diff --git a/tests/input/TimeStamp.c b/tests/input/TimeStamp.c new file mode 100644 index 0000000..5ab2dc2 --- /dev/null +++ b/tests/input/TimeStamp.c @@ -0,0 +1,64 @@ +/***************************************************************************** + * 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 * + * * + *****************************************************************************/ + +/* + + Test for TimeStamp monotonicity. + + */ + +#include <stdlib.h> +#include <input/GP_TimeStamp.h> + +#include "tst_test.h" + +#define MAX 2048 + +static int time_stamp_monotonicity(void) +{ + uint64_t ts = 0, nts; + int i, fail = 0; + + for (i = 0; i < MAX; i++) { + nts = GP_GetTimeStamp(); + if (nts < ts) { + tst_msg("TimeStamp failed at %i %llu < %llu", i, + (long long unsigned)nts, + (long long unsigned) ts); + fail++; + } + } + + if (fail) + return TST_FAILED; + + return TST_SUCCESS; +} + +const struct tst_suite tst_suite = { + .suite_name = "TimeStamp Testsuite", + .tests = { + {.name = "TimeStamp monotonicity", + .tst_fn = time_stamp_monotonicity}, + {.name = NULL}, + } +};
http://repo.or.cz/w/gfxprim.git/commit/a45c066497e510b339d3b9280859530ecf6e5...
commit a45c066497e510b339d3b9280859530ecf6e5b0c Author: Cyril Hrubis metan@ucw.cz Date: Thu Jun 27 20:16:57 2013 +0200
tests: input: Add timers testsuite.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/Makefile b/tests/Makefile index 6eb167d..56d5c28 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,7 +1,7 @@ TOPDIR=.. include $(TOPDIR)/pre.mk
-SUBDIRS=core framework loaders gfx filters +SUBDIRS=core framework loaders gfx filters input
loaders: framework gfx: framework diff --git a/tests/input/Makefile b/tests/input/Makefile new file mode 100644 index 0000000..e5e49bc --- /dev/null +++ b/tests/input/Makefile @@ -0,0 +1,12 @@ +TOPDIR=../.. + +include $(TOPDIR)/pre.mk + +CSOURCES=Timer.c + +APPS=Timer + +include ../tests.mk + +include $(TOPDIR)/app.mk +include $(TOPDIR)/post.mk diff --git a/tests/input/Timer.c b/tests/input/Timer.c new file mode 100644 index 0000000..34ce1eb --- /dev/null +++ b/tests/input/Timer.c @@ -0,0 +1,207 @@ +/***************************************************************************** + * 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 * + * * + *****************************************************************************/ + +/* + + Test for Timers code. + + */ + +#include <string.h> +#include <stdlib.h> +#include <input/GP_Timer.h> + +#include "tst_test.h" + +static uint32_t callback_set_priv(GP_Timer *self) +{ + self->priv = (void*)1; + + return 0; +} + +static int callback_is_called(void) +{ + GP_TIMER_DECLARE(timer, 10, 0, "Timer", callback_set_priv, NULL); + GP_Timer *head = NULL; + int fail = 0; + + GP_TimerQueueInsert(&head, 10, &timer); + + /* Now call process before the timer expiration */ + if (GP_TimerQueueProcess(&head, 10)) { + tst_msg("GP_TimerQueueProcess() reported non-zero"); + fail++; + } + + if (timer.priv) { + tst_msg("Callback was called"); + fail++; + } + + /* Now call process after the expiration time */ + if (GP_TimerQueueProcess(&head, 30) != 1) { + tst_msg("GP_TimerQueueProcess() reported wrong number"); + fail++; + } + + if (!timer.priv) { + tst_msg("Callback was not called"); + fail++; + } + + if (fail) + return TST_FAILED; + + return TST_SUCCESS; +} + +#define MAX 2048 + +static int monotonicity_failed = 0; +static uint64_t prev_expires; + +static uint32_t callback_check_monotonicity(GP_Timer *self) +{ + if (self->expires < prev_expires) { + monotonicity_failed = 1; + tst_msg("Wrong order of expirations detected"); + } + + prev_expires = self->expires; + + return 0; +} + +static int expirations_sorted(void) +{ + GP_Timer *head = NULL; + GP_Timer timers[MAX]; + int i; + uint64_t expires; + + for (i = 0; i < MAX; i++) { + timers[i].expires = random(); + timers[i].period = 0; + timers[i].Callback = callback_check_monotonicity; + timers[i].priv = &expires; + strcpy(timers[i].id, "Timer"); + GP_TimerQueueInsert(&head, 0, &timers[i]); + } + + prev_expires = head->expires; + + for (i = 0; i < MAX; i++) + GP_TimerQueueProcess(&head, head ? head->expires : 0); + + if (monotonicity_failed) + return TST_FAILED; + + return TST_SUCCESS; +} + +static int process_with_NULL_head(void) +{ + GP_Timer *head = NULL; + + if (GP_TimerQueueProcess(&head, 1024)) { + tst_msg("GP_TimerQueueProcess returned non-zero"); + return TST_FAILED; + } + + return TST_SUCCESS; +} + +/* + * Test that periodic timers are rescheduled + */ +static int periodic_timers(void) +{ + GP_TIMER_DECLARE(timer1, 0, 10, "Timer1", callback_set_priv, NULL); + GP_TIMER_DECLARE(timer2, 0, 20, "Timer2", callback_set_priv, NULL); + GP_Timer *head = NULL; + int fail = 0; + + GP_TimerQueueInsert(&head, 10, &timer1); + GP_TimerQueueInsert(&head, 10, &timer2); + + /* Make timer1 expire */ + if (GP_TimerQueueProcess(&head, 20) != 1) { + tst_msg("GP_TimerQueueProcess() reported wrong number"); + fail++; + } + + if (!timer1.priv) { + tst_msg("Timer1 callback was not called"); + fail++; + } + + /* check that there are two timers in the queue */ + if (head->sons != 1) { + tst_msg("Queue head has wrong number of sons %u", head->sons); + fail++; + } + + timer1.priv = NULL; + + /* Make both timers expire */ + if (GP_TimerQueueProcess(&head, 30) != 2) { + tst_msg("GP_TimerQueueProcess() reported wrong number"); + fail++; + } + + if (!timer1.priv) { + tst_msg("Timer1 callback was not called"); + fail++; + } + + if (!timer2.priv) { + tst_msg("Timer2 callback was not called"); + fail++; + } + + /* check that there are two timers in the queue */ + if (head->sons != 1) { + tst_msg("Queue head has wrong number of sons %u", head->sons); + fail++; + } + + if (fail) + return TST_FAILED; + + return TST_SUCCESS; +} + +const struct tst_suite tst_suite = { + .suite_name = "Timer Testsuite", + .tests = { + {.name = "Callback is called", + .tst_fn = callback_is_called}, + {.name = "Call process with NULL head", + .tst_fn = process_with_NULL_head}, + {.name = "Expirations are sorted", + .tst_fn = expirations_sorted}, + {.name = "Periodic timers", + .tst_fn = periodic_timers}, + {.name = NULL}, + } +}; diff --git a/tests/input/runtest.sh b/tests/input/runtest.sh new file mode 100755 index 0000000..b3039a3 --- /dev/null +++ b/tests/input/runtest.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# +# By default the glibc __libc_message() writes to /dev/tty before calling +# the abort(). Exporting this macro makes it to use stderr instead. +# +# The main usage of the function are malloc assertions, so this makes us catch +# the malloc error message by catching stderr output. +# +export LIBC_FATAL_STDERR_=1 + +TEST="$1" +shift + +LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ "./$TEST" "$@" diff --git a/tests/input/test_list.txt b/tests/input/test_list.txt new file mode 100644 index 0000000..777c39b --- /dev/null +++ b/tests/input/test_list.txt @@ -0,0 +1,3 @@ +# Input test list + +Timer
-----------------------------------------------------------------------
Summary of changes: tests/Makefile | 2 +- tests/{loaders => input}/Makefile | 5 +- tests/{core/Pixel.c => input/TimeStamp.c} | 46 +++---- tests/input/Timer.c | 207 +++++++++++++++++++++++++++++ tests/{core => input}/runtest.sh | 0 tests/input/test_list.txt | 3 + tests/runtests.py | 3 +- 7 files changed, 235 insertions(+), 31 deletions(-) copy tests/{loaders => input}/Makefile (64%) copy tests/{core/Pixel.c => input/TimeStamp.c} (72%) create mode 100644 tests/input/Timer.c copy tests/{core => input}/runtest.sh (100%) create mode 100644 tests/input/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.