source: rtems/testsuites/sptests/spassoc01/init.c @ 3c8eda7

4.115
Last change on this file since 3c8eda7 was 3c8eda7, checked in by Joel Sherrill <joel.sherrill@…>, on 05/12/12 at 16:01:26

sptests - Eliminate missing prototype warnings

  • Property mode set to 100644
File size: 7.1 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
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.com/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
17#include <stdio.h>
18#include <rtems/assoc.h>
19
20/* forward declarations to avoid warnings */
21rtems_task Init(rtems_task_argument argument);
22
23const rtems_assoc_t assoc_table_null[] =
24  {
25    { NULL       , 0 , 0  },
26    { "zero"     , 1 , 8  },
27    { "one"      , 2 , 4  },
28    { "two"      , 4 , 2  },
29    { "three"    , 8 , 1  },
30    { NULL       , -1, -1 }
31  };
32
33const rtems_assoc_t assoc_table_default[] =
34  {
35    { "(default)", 0 , 0  },
36    { "zero"     , 1 , 8  },
37    { "one"      , 2 , 4  },
38    { "two"      , 4 , 2  },
39    { "three"    , 8 , 1  },
40    { NULL       , -1, -1 }
41  };
42
43const rtems_assoc_t assoc_table[] =
44  {
45    { "zero" , 1 , 8  },
46    { "one"  , 2 , 4  },
47    { "two"  , 4 , 2  },
48    { "three", 8 , 1  },
49    { NULL   , -1, -1 }
50  };
51
52uint32_t local;
53uint32_t remote;
54const rtems_assoc_t *assoc_item;
55char *name;
56
57static void reset_name( void )
58{
59  memset( name, 0, 40 );
60}
61
62rtems_task Init(
63  rtems_task_argument argument
64)
65{
66  name = malloc(40);
67  puts( "\n\n*** TEST ASSOC ROUTINES - 1 ***" );
68
69  puts( "Init - get local by name -- OK" );
70  local = rtems_assoc_local_by_name( assoc_table, "zero" );
71  rtems_test_assert( local == 1 );
72
73  puts( "Init - get local by name -- expect 0" );
74  local = rtems_assoc_local_by_name( assoc_table, "four" );
75  rtems_test_assert( local == 0 );
76
77  puts( "Init - get local by remote bitfield -- OK" );
78  local = rtems_assoc_local_by_remote_bitfield( assoc_table, 1 );
79  rtems_test_assert( local == 8 );
80
81  puts( "Init - get local by remote bitfield -- expect 0" );
82  local = rtems_assoc_local_by_remote_bitfield( assoc_table, 0 );
83  rtems_test_assert( local == 0 );
84
85  puts( "Init - get local by remote -- OK" );
86  local = rtems_assoc_local_by_remote( assoc_table, 1 );
87  rtems_test_assert( local == 8 );
88
89  puts( "Init - get local by remote -- expect 0" );
90  local = rtems_assoc_local_by_remote( assoc_table, 0 );
91  rtems_test_assert( local == 0 );
92
93  reset_name();
94  puts( "Init - get name by local bitfield -- OK" );
95  name = rtems_assoc_name_by_local_bitfield( assoc_table, 1, name );
96  rtems_test_assert ( !strcmp( name, "zero" ) );
97
98  reset_name();
99  puts( "Init - get name by local bitfield -- OK" );
100  name = rtems_assoc_name_by_local_bitfield( assoc_table, 3, name );
101  rtems_test_assert ( !strcmp( name, "zero one" ) );
102
103  reset_name();
104  puts( "Init - get name by local bitfield -- expect\"\"" );
105  name = rtems_assoc_name_by_local_bitfield( assoc_table, 0, name );
106  rtems_test_assert ( !strcmp( name, "" ) );
107 
108  reset_name();
109  puts( "Init - get name by local -- OK" );
110  rtems_test_assert( !strcmp( rtems_assoc_name_by_local( assoc_table, 1 ),
111                              "zero" ) );
112 
113  reset_name();
114  puts( "Init - get name by local -- using bad value" );
115  puts( rtems_assoc_name_by_local( assoc_table, 0 ) );
116
117  reset_name();
118  puts( "Init - get name by remote bitfield -- OK" );
119  name =
120    rtems_assoc_name_by_remote_bitfield( assoc_table, 1, name );
121  rtems_test_assert ( !strcmp( name, "three" ) );
122
123  reset_name();
124  puts( "Init - get name by remote bitfield -- OK" );
125  name =
126    rtems_assoc_name_by_remote_bitfield( assoc_table, 3, name );
127  rtems_test_assert ( !strcmp( name, "three two" ) );
128
129  reset_name();
130  puts( "Init - get name by remote bitfield -- expect\"\"" );
131  name =
132    rtems_assoc_name_by_remote_bitfield( assoc_table, 0, name );
133  rtems_test_assert ( !strcmp( name, "" ) );
134 
135  reset_name();
136  puts( "Init - get name by remote -- OK" );
137  rtems_test_assert( !strcmp( rtems_assoc_name_by_remote( assoc_table, 1 ),
138                              "three" ) );
139 
140  reset_name();
141  puts( "Init - get name by remote -- using bad value" );
142  puts( rtems_assoc_name_by_remote( assoc_table, 0 ) );
143
144  puts( "Init - get ptr by local -- OK" );
145  assoc_item = rtems_assoc_ptr_by_local( assoc_table, 1 );
146  rtems_test_assert( assoc_item == assoc_table );
147
148  puts( "Init - get ptr by local -- expect NULL" );
149  assoc_item = rtems_assoc_ptr_by_local( assoc_table, 0 );
150  rtems_test_assert( assoc_item == 0 );
151
152  puts( "Init - get ptr by remote -- OK" );
153  assoc_item = rtems_assoc_ptr_by_remote( assoc_table, 8 );
154  rtems_test_assert( assoc_item == assoc_table );
155
156  puts( "Init - get ptr by remote -- expect NULL" );
157  assoc_item = rtems_assoc_ptr_by_remote( assoc_table, 0 );
158  rtems_test_assert( assoc_item == 0 );
159
160  puts( "Init - get ptr by name -- OK" );
161  assoc_item = rtems_assoc_ptr_by_name( assoc_table, "zero" );
162  rtems_test_assert( assoc_item == assoc_table );
163
164  puts( "Init - get ptr by name -- expect NULL" );
165  assoc_item = rtems_assoc_ptr_by_name( assoc_table, "six" );
166  rtems_test_assert( assoc_item == 0 );
167
168  puts( "Init - get remote by local bitfield -- OK" );
169  remote = rtems_assoc_remote_by_local_bitfield( assoc_table, 1 );
170  rtems_test_assert( remote == 8 );
171
172  puts( "Init - get remote by local bitfield -- expect 0" );
173  remote = rtems_assoc_remote_by_local_bitfield( assoc_table, 0 );
174  rtems_test_assert( remote == 0 );
175
176  puts( "Init - get remote by local -- OK" );
177  remote = rtems_assoc_remote_by_local( assoc_table, 1 );
178  rtems_test_assert( remote == 8 );
179
180  puts( "Init - get remote by local -- expect 0" );
181  remote = rtems_assoc_remote_by_local( assoc_table, 0 );
182  rtems_test_assert( remote == 0 );
183
184  puts( "Init - get remote by name -- OK" );
185  remote = rtems_assoc_remote_by_name( assoc_table, "zero" );
186  rtems_test_assert( remote == 8 );
187
188  puts( "Init - get remote by name -- expect 0" );
189  remote = rtems_assoc_remote_by_name( assoc_table, "six" );
190  rtems_test_assert( remote == 0 );
191
192  puts( "Init - get ptr by name -- expect (default)" );
193  assoc_item = rtems_assoc_ptr_by_name( assoc_table_default, "six" );
194  rtems_test_assert( assoc_item == assoc_table_default );
195
196  puts( "Init - get ptr by local -- expect (default)" );
197  assoc_item = rtems_assoc_ptr_by_local( assoc_table_default, 0 );
198  rtems_test_assert( assoc_item == assoc_table_default );
199
200  puts( "Init - get ptr by remote -- expect (default)" );
201  assoc_item = rtems_assoc_ptr_by_remote( assoc_table_default, 0 );
202  rtems_test_assert( assoc_item == assoc_table_default );
203
204  puts( "Init - get ptr by name -- expect NULL" );
205  assoc_item = rtems_assoc_ptr_by_name( assoc_table_null, "six" );
206  rtems_test_assert( assoc_item == 0 );
207
208  puts( "Init - get ptr by local -- expect NULL" );
209  assoc_item = rtems_assoc_ptr_by_local( assoc_table_null, 0 );
210  rtems_test_assert( assoc_item == 0 );
211
212  puts( "Init - get ptr by remote -- expect NULL" );
213  assoc_item = rtems_assoc_ptr_by_remote( assoc_table_null, 0 );
214  rtems_test_assert( assoc_item == 0 );
215
216  free( name );
217
218  puts( "*** END OF TEST ASSOC ROUTINES - 1 ***" );
219
220  rtems_test_exit(0);
221}
222
223/* configuration information */
224
225#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
226#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
227
228#define CONFIGURE_MAXIMUM_TASKS             1
229#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
230
231#define CONFIGURE_INIT
232
233#include <rtems/confdefs.h>
234/* end of file */
Note: See TracBrowser for help on using the repository browser.