From f831eff7387d9a4ae8460d639da660d5ae2ce4fa Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 2 Mar 2016 08:07:58 +0100 Subject: tmtests/tmtimer01: New test Test run performed on T4240 running at 1667MHz in uni-processor configuration. Update #2554. --- testsuites/tmtests/Makefile.am | 1 + testsuites/tmtests/configure.ac | 1 + testsuites/tmtests/tmtimer01/Makefile.am | 19 +++ testsuites/tmtests/tmtimer01/init.c | 213 +++++++++++++++++++++++++++++ testsuites/tmtests/tmtimer01/plot.py | 25 ++++ testsuites/tmtests/tmtimer01/tmtimer01.doc | 12 ++ testsuites/tmtests/tmtimer01/tmtimer01.scn | 137 +++++++++++++++++++ 7 files changed, 408 insertions(+) create mode 100644 testsuites/tmtests/tmtimer01/Makefile.am create mode 100644 testsuites/tmtests/tmtimer01/init.c create mode 100644 testsuites/tmtests/tmtimer01/plot.py create mode 100644 testsuites/tmtests/tmtimer01/tmtimer01.doc create mode 100644 testsuites/tmtests/tmtimer01/tmtimer01.scn diff --git a/testsuites/tmtests/Makefile.am b/testsuites/tmtests/Makefile.am index c1eb7b5555..b259269ac9 100644 --- a/testsuites/tmtests/Makefile.am +++ b/testsuites/tmtests/Makefile.am @@ -3,6 +3,7 @@ ACLOCAL_AMFLAGS = -I ../aclocal _SUBDIRS = tmck tmoverhd tm01 tm02 tm03 tm04 tm05 tm06 tm07 tm08 tm09 tm10 \ tm11 tm12 tm13 tm14 tm15 tm16 tm17 tm18 tm19 tm20 tm21 tm22 tm23 tm24 \ tm25 tm26 tm27 tm28 tm29 tm30 tm31 tm32 tm33 tm34 tm35 tm36 +_SUBDIRS += tmtimer01 _SUBDIRS += tmcontext01 _SUBDIRS += tmfine01 diff --git a/testsuites/tmtests/configure.ac b/testsuites/tmtests/configure.ac index 5c6138e846..b899000a3e 100644 --- a/testsuites/tmtests/configure.ac +++ b/testsuites/tmtests/configure.ac @@ -27,6 +27,7 @@ AC_SUBST(OPERATION_COUNT) # Explicitly list all Makefiles here AC_CONFIG_FILES([Makefile +tmtimer01/Makefile tmfine01/Makefile tmcontext01/Makefile tmck/Makefile diff --git a/testsuites/tmtests/tmtimer01/Makefile.am b/testsuites/tmtests/tmtimer01/Makefile.am new file mode 100644 index 0000000000..15a68282f3 --- /dev/null +++ b/testsuites/tmtests/tmtimer01/Makefile.am @@ -0,0 +1,19 @@ +rtems_tests_PROGRAMS = tmtimer01 +tmtimer01_SOURCES = init.c + +dist_rtems_tests_DATA = tmtimer01.scn tmtimer01.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 = $(tmtimer01_OBJECTS) +LINK_LIBS = $(tmtimer01_LDLIBS) + +tmtimer01$(EXEEXT): $(tmtimer01_OBJECTS) $(tmtimer01_DEPENDENCIES) + @rm -f tmtimer01$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/tmtests/tmtimer01/init.c b/testsuites/tmtests/tmtimer01/init.c new file mode 100644 index 0000000000..6b9430481f --- /dev/null +++ b/testsuites/tmtests/tmtimer01/init.c @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * 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 "tmacros.h" + +#include +#include + +#include +#include + +const char rtems_test_name[] = "TMTIMER 1"; + +typedef struct { + size_t cache_line_size; + size_t data_cache_size; + int dummy_value; + volatile int *dummy_data; + rtems_id first; +} test_context; + +static test_context test_instance; + +static void prepare_cache(test_context *ctx) +{ + volatile int *data = ctx->dummy_data; + size_t m = ctx->data_cache_size / sizeof(*data); + size_t k = ctx->cache_line_size / sizeof(*data); + size_t j = ctx->dummy_value; + size_t i; + + for (i = 0; i < m; i += k) { + data[i] = i + j; + } + + ctx->dummy_value = i + j; + rtems_cache_invalidate_entire_instruction(); +} + +static void never(rtems_id id, void *arg) +{ + rtems_test_assert(0); +} + +static rtems_interval interval(size_t i) +{ + rtems_interval d = 50000; + + return i * d + d; +} + +static void test_fire_and_cancel( + test_context *ctx, + size_t i, + size_t j, + const char *name +) +{ + rtems_status_code sc; + rtems_status_code sc2; + rtems_counter_ticks a; + rtems_counter_ticks b; + rtems_counter_ticks d; + rtems_id id; + rtems_interrupt_level level; + + id = ctx->first + i; + prepare_cache(ctx); + + rtems_interrupt_local_disable(level); + a = rtems_counter_read(); + sc = rtems_timer_fire_after(id, interval(j), never, NULL); + sc2 = rtems_timer_cancel(id); + b = rtems_counter_read(); + rtems_interrupt_local_enable(level); + + d = rtems_counter_difference(b, a); + + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + rtems_test_assert(sc2 == RTEMS_SUCCESSFUL); + + printf( + "<%s unit=\"ns\">%" PRIu64 "", + name, + rtems_counter_ticks_to_nanoseconds(d), + name + ); +} + +static void test_case(test_context *ctx, size_t j, size_t k) +{ + rtems_status_code sc; + size_t s; + size_t t; + + s = j - k; + + for (t = 0; t < s; ++t) { + size_t u = k + t; + + sc = rtems_timer_fire_after(ctx->first + u, interval(u + 1), never, NULL); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + } + + printf(" \n %zu", j); + + test_fire_and_cancel(ctx, j, 0, "First"); + test_fire_and_cancel(ctx, j, j / 2, "Middle"); + test_fire_and_cancel(ctx, j, j + 1, "Last"); + + printf("\n \n"); +} + +static void test(void) +{ + test_context *ctx = &test_instance; + rtems_status_code sc; + rtems_id id; + rtems_name n; + size_t j; + size_t k; + size_t timer_count; + + ctx->cache_line_size = rtems_cache_get_data_line_size(); + if (ctx->cache_line_size == 0) { + ctx->cache_line_size = 32; + } + + ctx->data_cache_size = rtems_cache_get_data_cache_size(0); + if (ctx->data_cache_size == 0) { + ctx->data_cache_size = ctx->cache_line_size; + } + + ctx->dummy_data = malloc(ctx->data_cache_size); + rtems_test_assert(ctx->dummy_data != NULL); + + n = 1; + timer_count = 1; + + sc = rtems_timer_create(n, &ctx->first); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + rtems_test_assert(rtems_object_id_get_index(ctx->first) == n); + + while (true) { + ++n; + + sc = rtems_timer_create(n, &id); + if (sc != RTEMS_SUCCESSFUL) { + break; + } + + rtems_test_assert(rtems_object_id_get_index(id) == n); + timer_count = n; + } + + printf("\n", timer_count); + + k = 0; + j = 0; + + while (j < timer_count) { + test_case(ctx, j, k); + k = j; + j = (123 * (j + 1) + 99) / 100; + } + + test_case(ctx, n - 2, k); + + printf("\n"); +} + +static void Init(rtems_task_argument arg) +{ + TEST_BEGIN(); + + test(); + + TEST_END(); + rtems_test_exit(0); +} + +#define CONFIGURE_MICROSECONDS_PER_TICK 50000 + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + +#define CONFIGURE_UNIFIED_WORK_AREAS + +#define CONFIGURE_MAXIMUM_TASKS 1 +#define CONFIGURE_MAXIMUM_TIMERS rtems_resource_unlimited(32) + +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT + +#include diff --git a/testsuites/tmtests/tmtimer01/plot.py b/testsuites/tmtests/tmtimer01/plot.py new file mode 100644 index 0000000000..7f3cf9ece0 --- /dev/null +++ b/testsuites/tmtests/tmtimer01/plot.py @@ -0,0 +1,25 @@ +# +# Copyright (c) 2016 embedded brains GmbH. All rights reserved. +# +# 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. +# + +import libxml2 +from libxml2 import xmlNode +import matplotlib.pyplot as plt +doc = libxml2.parseFile('tmtimer01.scn') +ctx = doc.xpathNewContext() + +plt.title('timer test') +plt.xscale('log') +plt.xlabel('active timers') +plt.ylabel('timer fire and cancel [ns]') + +x = map(xmlNode.getContent, ctx.xpathEval('/TMTimer01/Sample/ActiveTimers')) +for i in ['First', 'Middle', 'Last']: + y = map(xmlNode.getContent, ctx.xpathEval('/TMTimer01/Sample/' + i)) + plt.plot(x, y, label = i) +plt.legend(loc = 'best') +plt.show() diff --git a/testsuites/tmtests/tmtimer01/tmtimer01.doc b/testsuites/tmtests/tmtimer01/tmtimer01.doc new file mode 100644 index 0000000000..728a000ce0 --- /dev/null +++ b/testsuites/tmtests/tmtimer01/tmtimer01.doc @@ -0,0 +1,12 @@ +This file describes the directives and concepts tested by this test set. + +test set name: tmtimer01 + +directives: + + - rtems_timer_fire_after() + - rtems_timer_cancel() + +concepts: + + - Measure the time to execute the timer fire after and cancel operations. diff --git a/testsuites/tmtests/tmtimer01/tmtimer01.scn b/testsuites/tmtests/tmtimer01/tmtimer01.scn new file mode 100644 index 0000000000..ea882d415f --- /dev/null +++ b/testsuites/tmtests/tmtimer01/tmtimer01.scn @@ -0,0 +1,137 @@ + + + 0639732901527 + + + 2198615501314 + + + 4155121343072 + + + 7254535113404 + + + 10159523634287 + + + 14147327406069 + + + 19156631955993 + + + 25125127187307 + + + 322302569010269 + + + 411522822113424 + + + 521799845514820 + + + 6610621248016590 + + + 8313841171021854 + + + 10416661520030951 + + + 13013451715437942 + + + 16213692238146929 + + + 20122713562559972 + + + 24912793727169662 + + + 3088644458087633 + + + 381107853821106376 + + + 47091367021133201 + + + 580187079863169394 + + + 715173299965208901 + + + 8811503138820259314 + + + 10851096166404337461 + + + 13361383209434445806 + + + 16451787253904533644 + + + 20252082327384657141 + + + 24921843417457814380 + + + 30671980493511977427 + + + 377426956220651237577 + + + 464414638275651565553 + + + 5714186610534581914932 + + + 7030348112661982450199 + + + 8649277315583512967472 + + + 10640208620038843766161 + + + 13089391125014274619553 + + + 16101327631891595886373 + + + 19806380140050497394938 + + + 24363308849777889138839 + + + 299684089613346211361012 + + + 368622059787013814319206 + + + 453422224991710017754441 + + + 5577219791181555721907509 + + + 6550324041369459126215885 + + -- cgit v1.2.3