source: rtems/testsuites/smptests/smpschededf03/init.c @ af43554

5
Last change on this file since af43554 was af43554, checked in by Sebastian Huber <sebastian.huber@…>, on 10/26/17 at 11:59:11

tests: Remove TEST_INIT

The TEST_EXTERN is a used only by the system.h style tests and they use
CONFIGURE_INIT appropriately.

Update #3170.
Update #3199.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 * Copyright (c) 2017 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 "tmacros.h"
20
21#include <rtems.h>
22
23const char rtems_test_name[] = "SMPSCHEDEDF 3";
24
25#define CPU_COUNT 32
26
27#define TASK_COUNT (3 * CPU_COUNT)
28
29typedef struct {
30  rtems_id task_ids[TASK_COUNT];
31} test_context;
32
33static test_context test_instance;
34
35static void wait_task(rtems_task_argument arg)
36{
37  (void) arg;
38
39  while (true) {
40    rtems_status_code sc;
41
42    sc = rtems_task_wake_after(1);
43    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
44  }
45}
46
47static uint32_t simple_random(uint32_t v)
48{
49  v *= 1664525;
50  v += 1013904223;
51  return v;
52}
53
54static void affinity_task(rtems_task_argument arg)
55{
56  uint32_t v;
57  uint32_t n;
58
59  v = (uint32_t) arg;
60  n = rtems_get_processor_count();
61
62  while (true) {
63    rtems_status_code sc;
64    cpu_set_t set;
65
66    CPU_ZERO(&set);
67    CPU_SET((v >> 13) % n, &set);
68    v = simple_random(v);
69
70    sc = rtems_task_set_affinity(RTEMS_SELF, sizeof(set), &set);
71    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
72  }
73}
74
75static void create_and_start_task(
76  test_context *ctx,
77  rtems_task_entry entry,
78  size_t i,
79  size_t j
80)
81{
82  rtems_status_code sc;
83
84  j = j * CPU_COUNT + i;
85
86  sc = rtems_task_create(
87    rtems_build_name('E', 'D', 'F', ' '),
88    i + 2,
89    RTEMS_MINIMUM_STACK_SIZE,
90    RTEMS_DEFAULT_MODES,
91    RTEMS_DEFAULT_ATTRIBUTES,
92    &ctx->task_ids[j]
93  );
94  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
95
96  sc = rtems_task_start(ctx->task_ids[j], entry, j);
97  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
98}
99
100static void delete_task(
101  test_context *ctx,
102  size_t i,
103  size_t j
104)
105{
106  rtems_status_code sc;
107
108  j = j * CPU_COUNT + i;
109
110  sc = rtems_task_delete(ctx->task_ids[j]);
111  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
112}
113
114static void test(test_context *ctx)
115{
116  rtems_status_code sc;
117  size_t i;
118
119  for (i = 0; i < CPU_COUNT; ++i) {
120    create_and_start_task(ctx, wait_task, i, 0);
121    create_and_start_task(ctx, affinity_task, i, 1);
122    create_and_start_task(ctx, affinity_task, i, 2);
123  }
124
125  sc = rtems_task_wake_after(10 * rtems_clock_get_ticks_per_second());
126  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
127
128  for (i = 0; i < CPU_COUNT; ++i) {
129    delete_task(ctx, i, 0);
130    delete_task(ctx, i, 1);
131    delete_task(ctx, i, 2);
132  }
133}
134
135static void Init(rtems_task_argument arg)
136{
137  TEST_BEGIN();
138  test(&test_instance);
139  TEST_END();
140  rtems_test_exit(0);
141}
142
143#define CONFIGURE_MICROSECONDS_PER_TICK 1000
144
145#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
146#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
147
148#define CONFIGURE_MAXIMUM_TASKS (1 + TASK_COUNT)
149
150#define CONFIGURE_MAXIMUM_PROCESSORS CPU_COUNT
151
152#define CONFIGURE_SCHEDULER_EDF_SMP
153
154#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
155
156#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
157
158#define CONFIGURE_INIT
159
160#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.