source: rtems/testsuites/sptests/spprofiling01/init.c @ a0b1b5ed

4.115
Last change on this file since a0b1b5ed was a0b1b5ed, checked in by Sebastian Huber <sebastian.huber@…>, on 12/15/14 at 13:19:43

Delete CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM

This define was superfluous, undocumented and used inconsistently.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#ifdef HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19#include <rtems/profiling.h>
20#include <rtems/bspIo.h>
21#include <rtems.h>
22
23#include <stdio.h>
24#include <string.h>
25
26#include "tmacros.h"
27
28const char rtems_test_name[] = "SPPROFILING 1";
29
30typedef struct {
31  rtems_interrupt_lock a;
32  rtems_interrupt_lock b;
33  rtems_interrupt_lock c;
34  rtems_interrupt_lock d;
35  enum {
36    WAIT_FOR_A,
37    EXPECT_B,
38    EXPECT_D,
39    DONE
40  } state;
41} visitor_context;
42
43static bool is_equal(const rtems_profiling_smp_lock *psl, const char *name)
44{
45  return strcmp(psl->name, name) == 0;
46}
47
48static void visitor(void *arg, const rtems_profiling_data *data)
49{
50  visitor_context *ctx = arg;
51
52  if (data->header.type == RTEMS_PROFILING_SMP_LOCK) {
53    const rtems_profiling_smp_lock *psl = &data->smp_lock;
54
55    switch (ctx->state) {
56      case WAIT_FOR_A:
57        rtems_test_assert(!is_equal(psl, "b"));
58        rtems_test_assert(!is_equal(psl, "c"));
59        rtems_test_assert(!is_equal(psl, "d"));
60
61        if (is_equal(psl, "a")) {
62          ctx->state = EXPECT_B;
63        }
64        break;
65      case EXPECT_B:
66        rtems_test_assert(is_equal(psl, "b"));
67        rtems_interrupt_lock_destroy(&ctx->c);
68        ctx->state = EXPECT_D;
69        break;
70      case EXPECT_D:
71        rtems_test_assert(is_equal(psl, "d"));
72        ctx->state = DONE;
73        break;
74      case DONE:
75        rtems_test_assert(!is_equal(psl, "a"));
76        rtems_test_assert(!is_equal(psl, "b"));
77        rtems_test_assert(!is_equal(psl, "c"));
78        rtems_test_assert(!is_equal(psl, "d"));
79        break;
80    }
81  }
82}
83
84static void lock_init(rtems_interrupt_lock *lock, const char *name)
85{
86  rtems_interrupt_lock_context lock_context;
87
88  rtems_interrupt_lock_initialize(lock, name);
89  rtems_interrupt_lock_acquire(lock, &lock_context);
90  rtems_interrupt_lock_release(lock, &lock_context);
91}
92
93static void test_iterate(void)
94{
95  visitor_context ctx_instance;
96  visitor_context *ctx = &ctx_instance;
97
98  ctx->state = WAIT_FOR_A;
99  lock_init(&ctx->a, "a");
100  lock_init(&ctx->b, "b");
101  lock_init(&ctx->c, "c");
102  lock_init(&ctx->d, "d");
103
104  rtems_profiling_iterate(visitor, ctx);
105
106  rtems_interrupt_lock_destroy(&ctx->a);
107  rtems_interrupt_lock_destroy(&ctx->b);
108
109  if (ctx->state != DONE) {
110    rtems_interrupt_lock_destroy(&ctx->c);
111  }
112
113  rtems_interrupt_lock_destroy(&ctx->d);
114}
115
116static void test_report_xml(void)
117{
118  rtems_status_code sc;
119  int rv;
120
121  sc = rtems_task_wake_after(3);
122  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
123
124  rv = rtems_profiling_report_xml("X", rtems_printf_plugin, NULL, 1, "  ");
125  printf("characters produced by rtems_profiling_report_xml(): %i\n", rv);
126}
127
128static void Init(rtems_task_argument arg)
129{
130  TEST_BEGIN();
131
132  test_iterate();
133  test_report_xml();
134
135  TEST_END();
136
137  rtems_test_exit(0);
138}
139
140#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
141#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
142
143#define CONFIGURE_MAXIMUM_TASKS 1
144
145#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
146
147#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
148
149#define CONFIGURE_INIT
150
151#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.