diff options
Diffstat (limited to 'testsuites')
-rw-r--r-- | testsuites/sptests/Makefile.am | 1 | ||||
-rw-r--r-- | testsuites/sptests/configure.ac | 1 | ||||
-rw-r--r-- | testsuites/sptests/spcpucounter01/Makefile.am | 19 | ||||
-rw-r--r-- | testsuites/sptests/spcpucounter01/init.c | 112 | ||||
-rw-r--r-- | testsuites/sptests/spcpucounter01/spcpucounter01.doc | 16 | ||||
-rw-r--r-- | testsuites/sptests/spcpucounter01/spcpucounter01.scn | 15 |
6 files changed, 164 insertions, 0 deletions
diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 1eacf5ceb3..9829d15b78 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -30,6 +30,7 @@ SUBDIRS = \ spsimplesched03 spnsext01 spedfsched01 spedfsched02 spedfsched03 \ spcbssched01 spcbssched02 spcbssched03 spqreslib sptimespec01 \ spregion_err01 sppartition_err01 +SUBDIRS += spcpucounter01 if HAS_CPLUSPLUS SUBDIRS += sptls02 endif diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac index 623e784fd5..c5f20b4ced 100644 --- a/testsuites/sptests/configure.ac +++ b/testsuites/sptests/configure.ac @@ -36,6 +36,7 @@ AM_CONDITIONAL(HAS_CPUSET,test x"${ac_cv_header_sys_cpuset_h}" = x"yes") # Explicitly list all Makefiles here AC_CONFIG_FILES([Makefile +spcpucounter01/Makefile sptls02/Makefile sptls01/Makefile spintrcritical20/Makefile diff --git a/testsuites/sptests/spcpucounter01/Makefile.am b/testsuites/sptests/spcpucounter01/Makefile.am new file mode 100644 index 0000000000..1cf3ee2993 --- /dev/null +++ b/testsuites/sptests/spcpucounter01/Makefile.am @@ -0,0 +1,19 @@ +rtems_tests_PROGRAMS = spcpucounter01 +spcpucounter01_SOURCES = init.c + +dist_rtems_tests_DATA = spcpucounter01.scn spcpucounter01.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 = $(spcpucounter01_OBJECTS) +LINK_LIBS = $(spcpucounter01_LDLIBS) + +spcpucounter01$(EXEEXT): $(spcpucounter01_OBJECTS) $(spcpucounter01_DEPENDENCIES) + @rm -f spcpucounter01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/sptests/spcpucounter01/init.c b/testsuites/sptests/spcpucounter01/init.c new file mode 100644 index 0000000000..1ed8a582bd --- /dev/null +++ b/testsuites/sptests/spcpucounter01/init.c @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2014 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.com/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#include <stdio.h> +#include <inttypes.h> + +#include <rtems.h> +#include <rtems/counter.h> + +#define TESTS_USE_PRINTF +#include "tmacros.h" + +#define NS_PER_TICK 1000000 + +static rtems_interval sync_with_clock_tick(void) +{ + rtems_interval start = rtems_clock_get_ticks_since_boot(); + rtems_interval current; + + do { + current = rtems_clock_get_ticks_since_boot(); + } while (current == start); + + return current; +} + +static void test_converter(void) +{ + CPU_Counter_ticks frequency = rtems_counter_nanoseconds_to_ticks(1000000000); + uint64_t ns = rtems_counter_ticks_to_nanoseconds(frequency); + + printf("CPU counter frequency: %" PRIu32 "Hz\n", frequency); + printf("nanoseconds for frequency count ticks: %" PRIu64 "\n", ns); + + rtems_test_assert(ns == 1000000000); +} + +static void test_delay_nanoseconds(void) +{ + rtems_counter_ticks start; + rtems_counter_ticks end; + rtems_counter_ticks delta; + double ns_per_tick = NS_PER_TICK; + double ns_delta; + rtems_interval tick; + int n = 10; + int i; + + printf("test delay nanoseconds (%i times)\n", n); + + for (i = 0; i < n; ++i) { + tick = sync_with_clock_tick(); + + start = rtems_counter_read(); + rtems_counter_delay_nanoseconds(NS_PER_TICK); + end = rtems_counter_read(); + + rtems_test_assert(tick < rtems_clock_get_ticks_since_boot()); + + delta = rtems_counter_difference(end, start); + ns_delta = rtems_counter_ticks_to_nanoseconds(delta); + + rtems_test_assert(ns_delta >= ns_per_tick); + + printf( + "busy wait relative to clock tick: %f\n", + (ns_delta - ns_per_tick) / ns_per_tick + ); + } +} + +static void Init(rtems_task_argument arg) +{ + puts("\n\n*** TEST SPCPUCOUNTER 1 ***"); + + test_converter(); + test_delay_nanoseconds(); + + puts("*** END OF TEST SPCPUCOUNTER 1 ***"); + + rtems_test_exit(0); +} + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + +#define CONFIGURE_MICROSECONDS_PER_TICK (NS_PER_TICK / 1000) + +#define CONFIGURE_MAXIMUM_TASKS 1 + +#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> diff --git a/testsuites/sptests/spcpucounter01/spcpucounter01.doc b/testsuites/sptests/spcpucounter01/spcpucounter01.doc new file mode 100644 index 0000000000..06ae34fd31 --- /dev/null +++ b/testsuites/sptests/spcpucounter01/spcpucounter01.doc @@ -0,0 +1,16 @@ +This file describes the directives and concepts tested by this test set. + +test set name: spcpucounter01 + +directives: + + - rtems_counter_read() + - rtems_counter_difference() + - rtems_counter_ticks_to_nanoseconds() + - rtems_counter_nanoseconds_to_ticks() + +concepts: + + - Ensure that the CPU counter converter functions produce consistent values. + - Ensure that the busy wait functions are consistent with the clock tick + durations. diff --git a/testsuites/sptests/spcpucounter01/spcpucounter01.scn b/testsuites/sptests/spcpucounter01/spcpucounter01.scn new file mode 100644 index 0000000000..fc8e84951e --- /dev/null +++ b/testsuites/sptests/spcpucounter01/spcpucounter01.scn @@ -0,0 +1,15 @@ +*** TEST SPCPUCOUNTER 1 *** +CPU counter frequency: 25000000Hz +nanoseconds for frequency count ticks: 1000000000 +test delay nanoseconds (10 times) +busy wait relative to clock tick: 0.001320 +busy wait relative to clock tick: 0.001640 +busy wait relative to clock tick: 0.001320 +busy wait relative to clock tick: 0.001160 +busy wait relative to clock tick: 0.001280 +busy wait relative to clock tick: 0.001240 +busy wait relative to clock tick: 0.001280 +busy wait relative to clock tick: 0.001280 +busy wait relative to clock tick: 0.001320 +busy wait relative to clock tick: 0.001280 +*** END OF TEST SPCPUCOUNTER 1 *** |