source: rtems/testsuites/sptests/sptasknopreempt01/init.c @ 0562060

4.115
Last change on this file since 0562060 was 0562060, checked in by Sebastian Huber <sebastian.huber@…>, on Jun 12, 2015 at 11:57:15 AM

sptests/sptasknopreempt01: New test

Update #2365.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 * Copyright (c) 2015 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
21const char rtems_test_name[] = "SPTASKNOPREEMPT 1";
22
23static bool did_run;
24
25static void do_not_run(rtems_task_argument arg)
26{
27#if 0
28  rtems_test_assert(0);
29#else
30  did_run = true;
31  rtems_task_suspend(RTEMS_SELF);
32#endif
33}
34
35static void test(void)
36{
37  rtems_status_code sc;
38  rtems_id task;
39
40  sc = rtems_task_create(
41    rtems_build_name('T', 'E', 'S', 'T'),
42    1,
43    RTEMS_MINIMUM_STACK_SIZE,
44    RTEMS_DEFAULT_MODES,
45    RTEMS_DEFAULT_ATTRIBUTES,
46    &task
47  );
48  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
49
50  sc = rtems_task_start(task, do_not_run, 0);
51  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
52
53  /*
54   * This will start a pseudo interrupt task pre-empting the non-preemtive
55   * executing task.  Later the high priority do_not_run() task is scheduled.
56   * See also https://devel.rtems.org/ticket/2365.
57   */
58  sc = rtems_timer_initiate_server(
59    RTEMS_TIMER_SERVER_DEFAULT_PRIORITY,
60    RTEMS_MINIMUM_STACK_SIZE,
61    RTEMS_DEFAULT_ATTRIBUTES
62  );
63  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
64
65  /* This is probably a bug and not a feature */
66  rtems_test_assert(did_run);
67
68  sc = rtems_task_delete(task);
69  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
70}
71
72static void Init(rtems_task_argument arg)
73{
74  TEST_BEGIN();
75
76  test();
77
78  TEST_END();
79  rtems_test_exit(0);
80}
81
82#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
83#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
84
85#define CONFIGURE_MAXIMUM_TASKS 3
86
87#define CONFIGURE_INIT_TASK_PRIORITY 2
88
89#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
90
91#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
92
93#define CONFIGURE_INIT
94
95#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.