source: rtems/testsuites/psxtests/psx15/init.c @ 9a4eca5

5
Last change on this file since 9a4eca5 was 278da87, checked in by Joel Sherrill <joel.sherrill@…>, on 03/20/15 at 15:45:28

psxtests/psx15/init.c: Correct printf() warning

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 * Copyright (c) 2010 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Obere Lagerstr. 30
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#include <inttypes.h>
21
22#include <rtems.h>
23
24#include "tmacros.h"
25
26const char rtems_test_name[] = "PSX 15";
27
28/* forward declarations to avoid warnings */
29rtems_task Init(rtems_task_argument argument);
30
31/*
32 * This test case shows that post switch extension handlers must cope with
33 * already deleted resources (e.g. _POSIX_signals_Post_switch_extension()).
34 * The thread delete extensions run with thread dispatching enabled.  Only the
35 * allocation mutex is locked.
36 */
37
38static rtems_id task_0 = RTEMS_ID_NONE;
39
40static rtems_id task_1 = RTEMS_ID_NONE;
41
42static void thread_delete_hook(
43  Thread_Control *executing,
44  Thread_Control *deleted
45)
46{
47  rtems_status_code sc = RTEMS_SUCCESSFUL;
48
49  if (deleted->Object.id == task_0) {
50    rtems_task_priority old = 0;
51
52    sc = rtems_task_set_priority(task_1, 2, &old);
53    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
54  }
55}
56
57static void suicide_task(rtems_task_argument arg)
58{
59  int me = (int) arg;
60
61  printf("suicide task %d\n", me);
62
63  rtems_task_delete(RTEMS_SELF);
64  rtems_test_assert(false);
65}
66
67void Init(rtems_task_argument arg)
68{
69  rtems_status_code sc = RTEMS_SUCCESSFUL;
70
71  TEST_BEGIN();
72
73  sc = rtems_task_create(
74    rtems_build_name('T', 'S', 'K', '1'),
75    5,
76    RTEMS_MINIMUM_STACK_SIZE,
77    RTEMS_DEFAULT_MODES,
78    RTEMS_DEFAULT_ATTRIBUTES,
79    &task_1
80  );
81  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
82
83  sc = rtems_task_start(task_1, suicide_task, 1);
84  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
85
86  sc = rtems_task_create(
87    rtems_build_name('T', 'S', 'K', '0'),
88    3,
89    RTEMS_MINIMUM_STACK_SIZE,
90    RTEMS_DEFAULT_MODES,
91    RTEMS_DEFAULT_ATTRIBUTES,
92    &task_0
93  );
94  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
95
96  sc = rtems_task_start(task_0, suicide_task, 0);
97  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
98
99  TEST_END();
100
101  rtems_test_exit(0);
102  rtems_test_assert(false);
103}
104
105#define CONFIGURE_INIT
106
107#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
108#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
109
110#define CONFIGURE_MAXIMUM_TASKS 3
111#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
112
113#define CONFIGURE_INITIAL_EXTENSIONS \
114  { .thread_delete = thread_delete_hook }, \
115  RTEMS_TEST_INITIAL_EXTENSION
116
117#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
118
119#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_PREEMPT
120#define CONFIGURE_INIT_TASK_PRIORITY 4
121
122#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.