source: rtems/testsuites/smptests/smpfatal03/init.c @ 3a27248

Last change on this file since 3a27248 was 3a27248, checked in by Sebastian Huber <sebastian.huber@…>, on Oct 21, 2016 at 7:23:58 AM

score: First part of new MrsP implementation

Update #2556.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 * Copyright (c) 2016 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.com/license/LICENSE.
13 */
14
15#ifdef HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#define TESTS_USE_PRINTK
20#include "tmacros.h"
21
22const char rtems_test_name[] = "SMPFATAL 3";
23
24static void task(rtems_task_argument arg)
25{
26  rtems_status_code sc;
27  rtems_id *sem_id;
28
29  sem_id = (rtems_id *) arg;
30
31  sc = rtems_semaphore_obtain(*sem_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
32  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
33
34  sc = rtems_task_wake_after(RTEMS_YIELD_PROCESSOR);
35  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
36
37  rtems_test_assert(0);
38}
39
40static void Init(rtems_task_argument arg)
41{
42  rtems_status_code sc;
43  rtems_id task_id;
44  rtems_id sem_id;
45
46  TEST_BEGIN();
47
48  sc = rtems_semaphore_create(
49    rtems_build_name('M', 'R', 'S', 'P'),
50    1,
51    RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
52      | RTEMS_BINARY_SEMAPHORE,
53    1,
54    &sem_id
55  );
56  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
57
58  sc = rtems_task_create(
59    rtems_build_name('T', 'A', 'S', 'K'),
60    1,
61    RTEMS_MINIMUM_STACK_SIZE,
62    RTEMS_DEFAULT_MODES,
63    RTEMS_DEFAULT_ATTRIBUTES,
64    &task_id
65  );
66  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
67
68  sc = rtems_task_start(task_id, task, (rtems_task_argument) &sem_id);
69  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
70
71  sc = rtems_task_wake_after(RTEMS_YIELD_PROCESSOR);
72  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
73
74  _Thread_Dispatch_disable();
75  rtems_semaphore_obtain(sem_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
76  rtems_test_assert(0);
77}
78
79static void fatal_extension(
80  rtems_fatal_source source,
81  bool is_internal,
82  rtems_fatal_code code
83)
84{
85  if (
86    source == INTERNAL_ERROR_CORE
87      && !is_internal
88      && code == INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE
89  ) {
90    TEST_END();
91  }
92}
93
94#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
95#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
96
97#define CONFIGURE_INITIAL_EXTENSIONS \
98  { .fatal = fatal_extension }, \
99  RTEMS_TEST_INITIAL_EXTENSION
100
101#define CONFIGURE_MAXIMUM_TASKS 2
102#define CONFIGURE_MAXIMUM_MRSP_SEMAPHORES 1
103
104#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
105
106#define CONFIGURE_INIT
107
108#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.