summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-11-10 12:03:11 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-03-09 16:34:16 +0100
commitcb835ec4f33bb2754663ce38684cfa70cf327e82 (patch)
tree536d3e955ce407d7f0018c2efa68a0e067d415c1
parent0312ff75c8a10338052525adb104c2f554690d0b (diff)
FIXME add runtime measurement test
-rw-r--r--testsuites/libtests/ttest02/init.c69
1 files changed, 68 insertions, 1 deletions
diff --git a/testsuites/libtests/ttest02/init.c b/testsuites/libtests/ttest02/init.c
index 7f972aec7e..01b9e8dd68 100644
--- a/testsuites/libtests/ttest02/init.c
+++ b/testsuites/libtests/ttest02/init.c
@@ -36,6 +36,73 @@
#include <rtems.h>
+typedef struct {
+ T_ticks delta;
+} clock_context;
+
+static void
+body(void *arg)
+{
+ clock_context *ctx;
+ T_ticks t0;
+ T_ticks t1;
+ rtems_interval tic;
+ rtems_interval toc;
+
+ ctx = arg;
+
+ do {
+ t0 = T_tick();
+ tic = rtems_clock_get_ticks_since_boot();
+ printk("x");
+ toc = rtems_clock_get_ticks_since_boot();
+ t1 = T_tick();
+ } while (tic == toc);
+
+ ctx->delta = t1 - t0;
+}
+
+static bool
+teardown(void *arg, T_ticks *delta, uint32_t tic, uint32_t toc,
+ unsigned int retry)
+{
+ clock_context *ctx;
+
+ (void)tic;
+ (void)toc;
+ (void)retry;
+ ctx = arg;
+ *delta = ctx->delta;
+ return true;
+}
+
+T_TEST_CASE(ClockTick)
+{
+ static const T_measure_runtime_config config = {
+ .sample_count = 100
+ };
+ int flags;
+ clock_context cctx;
+ T_measure_runtime_context *rctx;
+ T_measure_runtime_request req;
+
+ rctx = T_measure_runtime_create(&config);
+ T_assert_not_null(rctx);
+
+ flags = T_MEASURE_RUNTIME_DISABLE_FULL_CACHE |
+ T_MEASURE_RUNTIME_DISABLE_HOT_CACHE |
+ T_MEASURE_RUNTIME_DISABLE_MINOR_LOAD |
+ T_MEASURE_RUNTIME_REPORT_SAMPLES;
+
+ memset(&req, 0, sizeof(req));
+ req.name = "ClockTick";
+ req.flags = flags;
+ req.body = body;
+ req.teardown = teardown;
+ req.arg = &cctx;
+ T_measure_runtime(rctx, &req);
+}
+
static void
prepare(void *arg)
{
@@ -286,7 +353,7 @@ Init(rtems_task_argument argument)
#define CONFIGURE_MICROSECONDS_PER_TICK 1000
-#define CONFIGURE_MAXIMUM_TASKS 1
+#define CONFIGURE_MAXIMUM_TASKS 2
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE