summaryrefslogtreecommitdiffstats
path: root/testsuite/timeout01
diff options
context:
space:
mode:
authorChristian Mauderer <christian.mauderer@embedded-brains.de>2012-05-10 15:06:10 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-05-10 16:30:49 +0200
commitee6b343cbaa434d8c31a4d71dac5316b4404da35 (patch)
tree3ed32e5a8c1458207346eb0b203a2457ec109e44 /testsuite/timeout01
parentMove rtems_bsd_thread0_ucred (diff)
downloadrtems-libbsd-ee6b343cbaa434d8c31a4d71dac5316b4404da35.tar.bz2
Provide SWI(9) and TIMEOUT(9)
Diffstat (limited to 'testsuite/timeout01')
-rw-r--r--testsuite/timeout01/Makefile29
-rw-r--r--testsuite/timeout01/init.c81
-rw-r--r--testsuite/timeout01/timeout_helper.c142
-rw-r--r--testsuite/timeout01/timeout_helper.h46
-rw-r--r--testsuite/timeout01/timeout_test.c282
-rw-r--r--testsuite/timeout01/timeout_test.h45
6 files changed, 625 insertions, 0 deletions
diff --git a/testsuite/timeout01/Makefile b/testsuite/timeout01/Makefile
new file mode 100644
index 00000000..6e38da14
--- /dev/null
+++ b/testsuite/timeout01/Makefile
@@ -0,0 +1,29 @@
+include ../../config.inc
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+
+APP_PIECES = init timeout_test timeout_helper
+
+APP_O_FILES = $(APP_PIECES:%=%.o)
+APP_DEP_FILES = $(APP_PIECES:%=%.dep)
+
+APP = app.exe
+
+DEPFLAGS = -MT $@ -MD -MP -MF $*.dep
+AM_CPPFLAGS += -I $(INSTALL_BASE)/include -I.
+
+CFLAGS += $(DEPFLAGS) $(GCCFLAGS) $(AM_CPPFLAGS) -Wno-unused -Wl,-Map,app.map
+
+LINK_LIBS += $(INSTALL_BASE)/libbsd.a
+
+all: $(APP)
+
+$(APP): $(APP_O_FILES)
+ $(CC) $(CFLAGS) $^ $(LINK_LIBS) -o $(APP)
+
+clean:
+ rm -f app.map $(APP) $(APP_O_FILES) $(APP_DEP_FILES)
+
+-include $(APP_DEP_FILES)
diff --git a/testsuite/timeout01/init.c b/testsuite/timeout01/init.c
new file mode 100644
index 00000000..f1bd5291
--- /dev/null
+++ b/testsuite/timeout01/init.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+
+#include <rtems.h>
+
+#include <freebsd/bsd.h>
+
+#include "timeout_test.h"
+#include "timeout_helper.h"
+
+static void Init(rtems_task_argument arg)
+{
+ rtems_status_code sc;
+
+ puts("\n\n*** TEST TIMOUT 1 ***");
+
+ sc = rtems_bsd_initialize();
+ assert(sc == RTEMS_SUCCESSFUL);
+
+ timeout_table_init();
+ callout_tick_task_init();
+
+ timeout_test();
+
+ puts("*** END OF TEST TIMOUT 1 ***");
+
+ exit(0);
+}
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+
+#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
+
+#define CONFIGURE_FILESYSTEM_IMFS
+
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
+
+#define CONFIGURE_UNLIMITED_OBJECTS
+
+#define CONFIGURE_UNIFIED_WORK_AREAS
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_STACK_CHECKER_ENABLED
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
diff --git a/testsuite/timeout01/timeout_helper.c b/testsuite/timeout01/timeout_helper.c
new file mode 100644
index 00000000..88d8510d
--- /dev/null
+++ b/testsuite/timeout01/timeout_helper.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <freebsd/machine/rtems-bsd-config.h>
+
+#include <freebsd/sys/param.h>
+#include <freebsd/sys/systm.h>
+
+#include <assert.h>
+#include <malloc.h>
+
+#include "timeout_helper.h"
+
+void timeout_table_init()
+{
+ size_t size = 0;
+ caddr_t v = 0;
+ void* firstaddr = 0;
+
+ /* calculates how much memory is needed */
+ v = kern_timeout_callwheel_alloc(v);
+
+ /* allocate memory */
+ size = (size_t)v;
+ firstaddr = malloc(round_page(size));
+ assert(firstaddr != NULL);
+
+ /* now set correct addresses for callwheel */
+ v = (caddr_t) firstaddr;
+ v = kern_timeout_callwheel_alloc(v);
+
+ assert((size_t)((void *)v - firstaddr) == size);
+
+ /* Initialize the callouts we just allocated. */
+ kern_timeout_callwheel_init();
+}
+
+#define CALLOUT_TICK_TASK_PRIO (PRIORITY_DEFAULT_MAXIMUM - 1)
+#define CALLOUT_TICK_TASK_STACK_SIZE (1024)
+#define CALLOUT_TICK_TASK_NAME rtems_build_name('C', 'O', 'U', 'T')
+#define CALLOUT_TICKS_PER_CALLOUT_TICK 1
+
+static const rtems_event_set TRIGGER_EVENT = RTEMS_EVENT_13;
+
+static void callout_tick_task_trigger(rtems_id timer, void *arg)
+{
+ rtems_status_code status;
+ rtems_id *task_id = arg;
+
+ status = rtems_event_send(*task_id, TRIGGER_EVENT);
+ assert(status == RTEMS_SUCCESSFUL);
+
+ status = rtems_timer_reset(timer);
+ assert(status == RTEMS_SUCCESSFUL);
+}
+
+rtems_task callout_tick_task(rtems_task_argument arg)
+{
+ rtems_name name;
+ rtems_id timer;
+ rtems_status_code status;
+ const rtems_interval ticks_per_ms = CALLOUT_TICKS_PER_CALLOUT_TICK;
+ rtems_id self_id = rtems_task_self();
+
+ name = CALLOUT_TICK_TASK_NAME;
+
+ status = rtems_timer_create( name, &timer );
+ assert(status == RTEMS_SUCCESSFUL);
+
+ status = rtems_timer_fire_after( timer, ticks_per_ms, callout_tick_task_trigger, &self_id );
+ assert(status == RTEMS_SUCCESSFUL);
+
+ while ( 1 ) {
+ rtems_event_set event;
+
+ status = rtems_event_receive(
+ TRIGGER_EVENT,
+ RTEMS_EVENT_ALL | RTEMS_WAIT,
+ RTEMS_NO_TIMEOUT,
+ &event
+ );
+ assert(status == RTEMS_SUCCESSFUL);
+ assert(event == TRIGGER_EVENT);
+
+ callout_tick();
+ }
+}
+
+
+void callout_tick_task_init(void)
+{
+ static bool initialized = false;
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+
+ if (!initialized) {
+ rtems_id id = RTEMS_ID_NONE;
+
+ initialized = true;
+
+ sc = rtems_task_create(
+ CALLOUT_TICK_TASK_NAME,
+ CALLOUT_TICK_TASK_PRIO,
+ CALLOUT_TICK_TASK_STACK_SIZE,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &id
+ );
+ assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_task_start(id, callout_tick_task, 0);
+ assert(sc == RTEMS_SUCCESSFUL);
+ }
+}
+
diff --git a/testsuite/timeout01/timeout_helper.h b/testsuite/timeout01/timeout_helper.h
new file mode 100644
index 00000000..7e5acce1
--- /dev/null
+++ b/testsuite/timeout01/timeout_helper.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef TIMEOUT_HELPER_H
+#define TIMEOUT_HELPER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+void timeout_table_init(void);
+void callout_tick_task_init(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* TIMEOUT_HELPER_H */
diff --git a/testsuite/timeout01/timeout_test.c b/testsuite/timeout01/timeout_test.c
new file mode 100644
index 00000000..b89feb84
--- /dev/null
+++ b/testsuite/timeout01/timeout_test.c
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <assert.h>
+
+#include <stdio.h>
+#include <unistd.h>
+
+#include <freebsd/machine/rtems-bsd-config.h>
+
+#include <freebsd/sys/types.h>
+#include <freebsd/sys/systm.h>
+
+#include <freebsd/sys/param.h>
+#include <freebsd/sys/lock.h>
+#include <freebsd/sys/mutex.h>
+#include <freebsd/sys/rwlock.h>
+
+#define TIMEOUT_MILLISECONDS (100)
+
+// test after TEST_NOT_FIRED_MS, if handlar has not been executed
+#define TEST_NOT_FIRED_MS (TIMEOUT_MILLISECONDS * 80 / 100)
+// test TEST_FIRED_MS after TEST_NOT_FIRED_MS, if handlar has been executed
+#define TEST_FIRED_MS (TIMEOUT_MILLISECONDS * 40 / 100)
+// delay handler by this time with a mutex
+#define TEST_DELAY_MS (TIMEOUT_MILLISECONDS)
+
+enum arg {
+ HANDLER_NOT_VISITED,
+ HANDLER_VISITED,
+};
+
+static void timeout_handler(void *arg)
+{
+ enum arg* argument = arg;
+
+ printf("This is the timout_handler.\n");
+
+ *argument = HANDLER_VISITED;
+}
+
+void timeout_test_timeout()
+{
+ enum arg argument = HANDLER_NOT_VISITED;
+ struct callout_handle handle;
+
+ printf("== Start a timeout and test if handler has been called.\n");
+
+ callout_handle_init(&handle);
+
+ handle = timeout(timeout_handler, &argument, RTEMS_MILLISECONDS_TO_TICKS(TIMEOUT_MILLISECONDS));
+
+ usleep(TEST_NOT_FIRED_MS * 1000);
+ assert(argument == HANDLER_NOT_VISITED);
+
+ usleep(TEST_FIRED_MS * 1000);
+ assert(argument == HANDLER_VISITED);
+}
+
+void timeout_test_cancel_timeout()
+{
+ enum arg argument = HANDLER_NOT_VISITED;
+ struct callout_handle handle;
+
+ printf("== Start a timeout and cancel it.\n");
+
+ callout_handle_init(&handle);
+
+ handle = timeout(timeout_handler, &argument, RTEMS_MILLISECONDS_TO_TICKS(TIMEOUT_MILLISECONDS));
+
+ usleep(TEST_NOT_FIRED_MS * 1000);
+
+ untimeout(timeout_handler, &argument, handle);
+
+ usleep(TEST_FIRED_MS * 1000);
+ assert(argument == HANDLER_NOT_VISITED);
+}
+
+void timeout_test_callout(int mpsave)
+{
+ enum arg argument = HANDLER_NOT_VISITED;
+ struct callout callout;
+ int retval = 0;
+ printf("== Start a callout and test if handler has been called. mpsave=%d\n", mpsave);
+
+ callout_init(&callout, mpsave);
+
+ retval = callout_reset(&callout, RTEMS_MILLISECONDS_TO_TICKS(TIMEOUT_MILLISECONDS), timeout_handler, &argument);
+ assert(retval == 0);
+
+ usleep(TEST_NOT_FIRED_MS * 1000);
+ assert(argument == HANDLER_NOT_VISITED);
+
+ usleep(TEST_FIRED_MS * 1000);
+ assert(argument == HANDLER_VISITED);
+
+ callout_deactivate(&callout);
+}
+
+void timeout_test_cancel_callout(int mpsave, bool use_drain)
+{
+ enum arg argument = HANDLER_NOT_VISITED;
+ struct callout callout;
+ int retval = 0;
+ printf("== Start a callout and cancel it with %s. mpsave=%d\n", use_drain ? "drain" : "stop", mpsave);
+
+ callout_init(&callout, mpsave);
+
+ retval = callout_reset(&callout, RTEMS_MILLISECONDS_TO_TICKS(TIMEOUT_MILLISECONDS), timeout_handler, &argument);
+ assert(retval == 0);
+
+ usleep(TEST_NOT_FIRED_MS * 1000);
+
+ if(!use_drain)
+ {
+ retval = callout_stop(&callout);
+ }
+ else
+ {
+ retval = callout_drain(&callout);
+ }
+ assert(retval != 0);
+
+ usleep(TEST_FIRED_MS * 1000);
+ assert(argument == HANDLER_NOT_VISITED);
+
+ callout_deactivate(&callout);
+}
+
+void timeout_test_callout_reschedule(int mpsave, bool use_reset)
+{
+ enum arg argument = HANDLER_NOT_VISITED;
+ struct callout callout;
+ int retval = 0;
+ printf("== Start a callout and reschedule it after some time with %s. mpsave=%d\n", use_reset ? "reset" : "schedule", mpsave);
+
+ callout_init(&callout, mpsave);
+
+ retval = callout_reset(&callout, RTEMS_MILLISECONDS_TO_TICKS(TIMEOUT_MILLISECONDS), timeout_handler, &argument);
+ assert(retval == 0);
+
+ usleep(TEST_NOT_FIRED_MS * 1000);
+ assert(argument == HANDLER_NOT_VISITED);
+
+ if(!use_reset)
+ {
+ retval = callout_schedule(&callout, RTEMS_MILLISECONDS_TO_TICKS(TIMEOUT_MILLISECONDS));
+ }
+ else
+ {
+ retval = callout_reset(&callout, RTEMS_MILLISECONDS_TO_TICKS(TIMEOUT_MILLISECONDS), timeout_handler, &argument);
+ }
+ assert(retval != 0);
+
+ usleep(TEST_NOT_FIRED_MS * 1000);
+ assert(argument == HANDLER_NOT_VISITED);
+
+ usleep(TEST_FIRED_MS * 1000);
+ assert(argument == HANDLER_VISITED);
+
+ callout_deactivate(&callout);
+}
+
+void timeout_test_callout_mutex(bool delay_with_lock)
+{
+ enum arg argument = HANDLER_NOT_VISITED;
+ struct callout callout;
+ struct mtx mtx;
+ int retval = 0;
+ printf("== Start a callout with a mutex%s\n", delay_with_lock ? " and delay execution by locking it." : ".");
+
+ mtx_init(&mtx, "callouttest", NULL, MTX_DEF);
+ callout_init_mtx(&callout, &mtx, 0);
+
+ retval = callout_reset(&callout, RTEMS_MILLISECONDS_TO_TICKS(TIMEOUT_MILLISECONDS), timeout_handler, &argument);
+ assert(retval == 0);
+
+ usleep(TEST_NOT_FIRED_MS * 1000);
+ assert(argument == HANDLER_NOT_VISITED);
+
+ if(delay_with_lock)
+ {
+ retval = mtx_trylock(&mtx);
+ assert(retval != 0);
+
+ usleep(TEST_DELAY_MS * 1000);
+ assert(argument == HANDLER_NOT_VISITED);
+
+ mtx_unlock(&mtx);
+ }
+
+ usleep(TEST_FIRED_MS * 1000);
+ assert(argument == HANDLER_VISITED);
+
+ callout_deactivate(&callout);
+
+ mtx_destroy(&mtx);
+}
+
+void timeout_test_callout_rwlock(bool delay_with_lock)
+{
+ enum arg argument = HANDLER_NOT_VISITED;
+ struct callout callout;
+ struct rwlock rw;
+ int retval = 0;
+ printf("== Start a callout with a rwlock%s\n", delay_with_lock ? " and delay execution by locking it." : ".");
+
+ rw_init(&rw, "callouttest");
+ callout_init_rw(&callout, &rw, 0);
+
+ retval = callout_reset(&callout, RTEMS_MILLISECONDS_TO_TICKS(TIMEOUT_MILLISECONDS), timeout_handler, &argument);
+ assert(retval == 0);
+
+ usleep(TEST_NOT_FIRED_MS * 1000);
+ assert(argument == HANDLER_NOT_VISITED);
+
+ if(delay_with_lock)
+ {
+ retval = rw_try_wlock(&rw);
+ assert(retval != 0);
+
+ usleep(TEST_DELAY_MS * 1000);
+ assert(argument == HANDLER_NOT_VISITED);
+
+ rw_wunlock(&rw);
+ }
+
+ usleep(TEST_FIRED_MS * 1000);
+ assert(argument == HANDLER_VISITED);
+
+ callout_deactivate(&callout);
+}
+
+void timeout_test(void)
+{
+ int mpsave = 0;
+
+ timeout_test_timeout();
+ timeout_test_cancel_timeout();
+
+ for(mpsave = 0; mpsave<=1; mpsave++)
+ {
+ timeout_test_callout(mpsave);
+ timeout_test_cancel_callout(mpsave, false);
+ timeout_test_cancel_callout(mpsave, true);
+ timeout_test_callout_reschedule(mpsave, false);
+ timeout_test_callout_reschedule(mpsave, true);
+ }
+
+ timeout_test_callout_mutex(false);
+ timeout_test_callout_mutex(true);
+ timeout_test_callout_rwlock(false);
+ timeout_test_callout_rwlock(true);
+}
diff --git a/testsuite/timeout01/timeout_test.h b/testsuite/timeout01/timeout_test.h
new file mode 100644
index 00000000..25d4cb20
--- /dev/null
+++ b/testsuite/timeout01/timeout_test.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef TIMEOUT_TEST_H
+#define TIMEOUT_TEST_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+void timeout_test(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* TIMEOUT_TEST_H */