summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests
diff options
context:
space:
mode:
authorAlexander Krutwig <alexander.krutwig@embedded-brains.de>2015-04-20 11:08:22 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-05-20 08:40:29 +0200
commit31be41653a659a52460734cb8fe1da27e6d5629e (patch)
tree098c18a376b2f180a719af07406aaadf275b3716 /testsuites/sptests
parenttimecounter: Honor FFCLOCK define (diff)
downloadrtems-31be41653a659a52460734cb8fe1da27e6d5629e.tar.bz2
timecounter: Port to RTEMS
New test sptests/timecounter01. Update #2271.
Diffstat (limited to 'testsuites/sptests')
-rw-r--r--testsuites/sptests/Makefile.am1
-rw-r--r--testsuites/sptests/configure.ac1
-rw-r--r--testsuites/sptests/sptimecounter01/Makefile.am19
-rw-r--r--testsuites/sptests/sptimecounter01/init.c133
-rw-r--r--testsuites/sptests/sptimecounter01/sptimecounter01.doc29
-rw-r--r--testsuites/sptests/sptimecounter01/sptimecounter01.scn2
6 files changed, 185 insertions, 0 deletions
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am
index 9025ff3535..8844436876 100644
--- a/testsuites/sptests/Makefile.am
+++ b/testsuites/sptests/Makefile.am
@@ -38,6 +38,7 @@ else
_SUBDIRS += sp29
endif
_SUBDIRS += spintrcritical23
+_SUBDIRS += sptimecounter01
_SUBDIRS += spatomic01
_SUBDIRS += spintrcritical22
_SUBDIRS += spsem03
diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac
index ae3c763848..d463532124 100644
--- a/testsuites/sptests/configure.ac
+++ b/testsuites/sptests/configure.ac
@@ -41,6 +41,7 @@ AM_CONDITIONAL(HAS_SMP,test "$rtems_cv_RTEMS_SMP" = "yes")
# Explicitly list all Makefiles here
AC_CONFIG_FILES([Makefile
spintrcritical23/Makefile
+sptimecounter01/Makefile
spatomic01/Makefile
spglobalcon01/Makefile
spintrcritical22/Makefile
diff --git a/testsuites/sptests/sptimecounter01/Makefile.am b/testsuites/sptests/sptimecounter01/Makefile.am
new file mode 100644
index 0000000000..b2310886fc
--- /dev/null
+++ b/testsuites/sptests/sptimecounter01/Makefile.am
@@ -0,0 +1,19 @@
+rtems_tests_PROGRAMS = sptimecounter01
+sptimecounter01_SOURCES = init.c
+
+dist_rtems_tests_DATA = sptimecounter01.scn sptimecounter01.doc
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/leaf.am
+
+AM_CPPFLAGS += -I$(top_srcdir)/../support/include
+
+LINK_OBJS = $(sptimecounter01_OBJECTS)
+LINK_LIBS = $(sptimecounter01_LDLIBS)
+
+sptimecounter01$(EXEEXT): $(sptimecounter01_OBJECTS) $(sptimecounter01_DEPENDENCIES)
+ @rm -f sptimecounter01$(EXEEXT)
+ $(make-exe)
+
+include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/sptests/sptimecounter01/init.c b/testsuites/sptests/sptimecounter01/init.c
new file mode 100644
index 0000000000..47ebb2722c
--- /dev/null
+++ b/testsuites/sptests/sptimecounter01/init.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2015 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <assert.h>
+
+#include <bsp/bootcard.h>
+
+#include <rtems/test.h>
+
+#include <rtems/score/timecounterimpl.h>
+#include <rtems/score/watchdogimpl.h>
+#include <rtems/timecounter.h>
+#include <rtems/bsd.h>
+
+const char rtems_test_name[] = "SPTIMECOUNTER_1";
+
+typedef struct {
+ struct timecounter tc_soft;
+ u_int tc_soft_counter;
+} test_context;
+
+static test_context test_instance;
+
+static uint32_t test_get_timecount_soft(struct timecounter *tc)
+{
+ test_context *ctx = tc->tc_priv;
+
+ ++ctx->tc_soft_counter;
+
+ return ctx->tc_soft_counter;
+}
+
+void boot_card(const char *cmdline)
+{
+ test_context *ctx = &test_instance;
+ struct timecounter *tc_soft = &ctx->tc_soft;
+ uint64_t soft_freq = 1000000;
+ struct bintime bt;
+
+ rtems_test_begink();
+
+ _Timecounter_Initialize();
+ _Watchdog_Handler_initialization();
+
+ rtems_bsd_binuptime(&bt);
+ assert(bt.sec == 1);
+ assert(bt.frac== 0);
+
+ rtems_bsd_binuptime(&bt);
+ assert(bt.sec == 1);
+ assert(bt.frac == 0);
+
+ rtems_timecounter_tick();
+ rtems_bsd_binuptime(&bt);
+ assert(bt.sec == 1);
+ assert(bt.frac == 0);
+
+ ctx->tc_soft_counter = 0;
+ tc_soft->tc_get_timecount = test_get_timecount_soft;
+ tc_soft->tc_counter_mask = 0x0fffffff;
+ tc_soft->tc_frequency = soft_freq;
+ tc_soft->tc_quality = 1234;
+ tc_soft->tc_priv = ctx;
+ _Timecounter_Install(tc_soft);
+ assert(ctx->tc_soft_counter == 3);
+
+ rtems_bsd_binuptime(&bt);
+ assert(ctx->tc_soft_counter == 4);
+
+ assert(bt.sec == 1);
+ assert(bt.frac == 18446744073708);
+
+ ctx->tc_soft_counter = 0xf0000000 | 3;
+ rtems_bsd_binuptime(&bt);
+ assert(ctx->tc_soft_counter == (0xf0000000 | 4));
+
+ assert(bt.sec == 1);
+ assert(bt.frac == 18446744073708);
+
+ /* Ensure that the fraction overflows and the second remains constant */
+ ctx->tc_soft_counter = (0xf0000000 | 3) + soft_freq;
+ rtems_bsd_binuptime(&bt);
+ assert(ctx->tc_soft_counter == (0xf0000000 | 4) + soft_freq);
+ assert(bt.sec == 1);
+ assert(bt.frac == 18446742522092);
+
+ rtems_test_endk();
+
+ _Terminate(RTEMS_FATAL_SOURCE_EXIT, false, 0);
+}
+
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
+
+#define CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
+
+#define CONFIGURE_DISABLE_NEWLIB_REENTRANCY
+
+#define CONFIGURE_SCHEDULER_USER
+
+#define CONFIGURE_SCHEDULER_CONTEXT
+
+#define CONFIGURE_SCHEDULER_CONTROLS { }
+
+#define CONFIGURE_MEMORY_PER_TASK_FOR_SCHEDULER 0
+
+#define CONFIGURE_TASK_STACK_ALLOCATOR NULL
+
+#define CONFIGURE_TASK_STACK_DEALLOCATOR NULL
+
+#define CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION
+
+#define CONFIGURE_IDLE_TASK_BODY NULL
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_INIT
+
+#include <rtems/confdefs.h>
diff --git a/testsuites/sptests/sptimecounter01/sptimecounter01.doc b/testsuites/sptests/sptimecounter01/sptimecounter01.doc
new file mode 100644
index 0000000000..4a7442c2e6
--- /dev/null
+++ b/testsuites/sptests/sptimecounter01/sptimecounter01.doc
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2015 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+This file describes the directives and concepts tested by this test set.
+
+test set name: sptimecounter01
+
+directives:
+
+ _Timecounter_Initialize
+ rtems_timecounter_tick
+ _Timecounter_Install
+ rtems_bsd_bintime
+
+concepts:
+
+ This test checks the correct functioning of the FreeBSD timecounter startup
+ process
diff --git a/testsuites/sptests/sptimecounter01/sptimecounter01.scn b/testsuites/sptests/sptimecounter01/sptimecounter01.scn
new file mode 100644
index 0000000000..5fa9c0f281
--- /dev/null
+++ b/testsuites/sptests/sptimecounter01/sptimecounter01.scn
@@ -0,0 +1,2 @@
+*** BEGIN OF TEST SPTIMECOUNTER_1 ***
+*** END OF TEST SPTIMECOUNTER_1 ***