source: rtems/testsuites/sptests/sptls01/init.c @ 6c0301d

4.115
Last change on this file since 6c0301d was 6c0301d, checked in by Sebastian Huber <sebastian.huber@…>, on 03/25/14 at 07:06:21

tests/sptests: Use <rtems/test.h>

  • Property mode set to 100644
File size: 2.2 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 <stdio.h>
20
21#include "tmacros.h"
22
23const char rtems_test_name[] = "SPTLS 1";
24
25static rtems_id master_task;
26
27static __thread volatile char tls_item = 123;
28
29static volatile int read_write_small = 0xdeadbeef;
30
31static const volatile int read_only_small = 0x601dc0fe;
32
33static void check_tls_item(int expected)
34{
35  printf("TLS item = %i\n", tls_item);
36  rtems_test_assert(tls_item == expected);
37}
38
39static void task(rtems_task_argument arg)
40{
41  rtems_status_code sc;
42
43  check_tls_item(123);
44
45  sc = rtems_event_transient_send(master_task);
46  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
47
48  sc = rtems_task_suspend(RTEMS_SELF);
49  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
50}
51
52static void test(void)
53{
54  rtems_id id;
55  rtems_status_code sc;
56
57  master_task = rtems_task_self();
58
59  rtems_test_assert(read_write_small == 0xdeadbeef);
60  rtems_test_assert(read_only_small == 0x601dc0fe);
61
62  check_tls_item(123);
63  tls_item = 5;
64
65  sc = rtems_task_create(
66    rtems_build_name('T', 'A', 'S', 'K'),
67    RTEMS_MINIMUM_PRIORITY,
68    RTEMS_MINIMUM_STACK_SIZE,
69    RTEMS_DEFAULT_MODES,
70    RTEMS_DEFAULT_ATTRIBUTES,
71    &id
72  );
73  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
74
75  sc = rtems_task_start(id, task, 0);
76  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
77
78  sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT);
79  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
80
81  sc = rtems_task_delete(id);
82  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
83
84  check_tls_item(5);
85}
86
87static void Init(rtems_task_argument arg)
88{
89  TEST_BEGIN();
90
91  test();
92
93  TEST_END();
94
95  rtems_test_exit(0);
96}
97
98#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
99#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
100
101#define CONFIGURE_MAXIMUM_TASKS 2
102
103#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
104
105#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
106
107#define CONFIGURE_INIT
108
109#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.