source: rtems/testsuites/sptests/spprivenv01/init.c @ 00d98208

5
Last change on this file since 00d98208 was 00d98208, checked in by Sebastian Huber <sebastian.huber@…>, on 05/12/17 at 08:08:34

sptests/spprivenv01: Use default task mode

There is no need to run the task with interrupts disabled.

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2011.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <tmacros.h>
15#include "test_support.h"
16#include <rtems/libio_.h>
17#include <rtems/malloc.h>
18#include <rtems/libcsupport.h>
19
20const char rtems_test_name[] = "SPPRIVENV 1";
21
22/* forward declarations to avoid warnings */
23rtems_task Init(rtems_task_argument argument);
24rtems_task task_routine(rtems_task_argument not_used);
25
26rtems_task task_routine(rtems_task_argument not_used)
27{
28  rtems_status_code sc;
29
30  puts( "task_routine - setting up a private environment" );
31
32  sc = rtems_libio_set_private_env();
33  directive_failed( sc, "set private env" );
34  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
35  rtems_test_assert( rtems_current_user_env != &rtems_global_user_env );
36
37  sleep( 1 );
38
39  rtems_task_delete( RTEMS_SELF );
40}
41
42rtems_task Init(
43  rtems_task_argument argument
44)
45{
46  rtems_status_code       sc;
47  void                   *opaque;
48  rtems_id                task_id;
49  rtems_name              another_task_name;
50  rtems_user_env_t       *current_env;
51
52  TEST_BEGIN();
53
54  puts( "Init - allocating most of heap -- OK" );
55  opaque = rtems_heap_greedy_allocate( NULL, 0 );
56
57  puts( "Init - attempt to reset env - expect RTEMS_NO_MEMORY" );
58  sc = rtems_libio_set_private_env();
59  rtems_test_assert( sc == RTEMS_NO_MEMORY );
60
61  puts( "Init - freeing the allocated memory" );
62  rtems_heap_greedy_free( opaque );
63
64  puts( "Init - allocating most of workspace memory" );
65  opaque = rtems_workspace_greedy_allocate( NULL, 0 );
66
67  puts( "Init - attempt to reset env - expect RTEMS_SUCCESSFUL" );
68  sc = rtems_libio_set_private_env();
69  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
70  rtems_test_assert( rtems_current_user_env != &rtems_global_user_env );
71
72  puts( "Init - freeing the workspace memory" );
73  rtems_workspace_greedy_free( opaque );
74
75  puts( "Init - Reset to global environment" );
76  rtems_libio_use_global_env();
77  rtems_test_assert( rtems_current_user_env == &rtems_global_user_env );
78
79  puts( "Init - Attempt to get a private environment" );
80  sc = rtems_libio_set_private_env();
81  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
82  current_env = rtems_current_user_env;
83  rtems_test_assert( current_env != &rtems_global_user_env );
84
85  puts( "Init - creating a task name and a task -- OK" );
86
87  another_task_name =
88    rtems_build_name( 'T','S','K','D' );
89
90  sc = rtems_task_create( another_task_name,
91                          1,
92                          RTEMS_MINIMUM_STACK_SIZE * 2,
93                          RTEMS_DEFAULT_MODES,
94                          RTEMS_DEFAULT_ATTRIBUTES,
95                          &task_id
96                          );
97
98  puts( "Init - starting the task_routine, to set its private environment" );
99  sc = rtems_task_start( task_id, task_routine, 0);
100  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
101
102  sleep( 1 );
103
104  puts( "Init - Check current private environment. Should be same as before." );
105  rtems_test_assert( rtems_current_user_env == current_env );
106
107  puts( "Init - Reset to global environment" );
108  rtems_libio_use_global_env();
109  rtems_test_assert( rtems_current_user_env == &rtems_global_user_env );
110
111  TEST_END();
112
113  rtems_test_exit(0);
114}
115
116/* configuration information */
117
118#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
119#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
120
121#define CONFIGURE_MAXIMUM_TASKS             3
122#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
123
124#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
125
126#define CONFIGURE_MAXIMUM_POSIX_KEYS 1
127#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS 2
128
129#define CONFIGURE_INIT
130
131#include <rtems/confdefs.h>
132/* end of file */
Note: See TracBrowser for help on using the repository browser.