OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [itrontests/] [itronmbf01/] [init.c] - Blame information for rev 552

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  Init
2
 *
3
 *  This routine is the initialization task for this test program.
4
 *  It is called from init_exec and has the responsibility for creating
5
 *  and starting the tasks that make up the test.  If the time of day
6
 *  clock is required for the test, it should also be set to a known
7
 *  value by this function.
8
 *
9
 *  Input parameters:  NONE
10
 *
11
 *  Output parameters:  NONE
12
 *
13
 *  COPYRIGHT (c) 1989-1999.
14
 *  On-Line Applications Research Corporation (OAR).
15
 *
16
 *  The license and distribution terms for this file may be
17
 *  found in the file LICENSE in this distribution or at
18
 *  http://www.OARcorp.com/rtems/license.html.
19
 *
20
 *  $Id: init.c,v 1.2 2001-09-27 12:02:10 chris Exp $
21
 */
22
 
23
#define TEST_INIT
24
#include "system.h"
25
#include <stdio.h>
26
#include <assert.h>
27
 
28
/*
29
 *  The following is hopefully temporary.
30
 */
31
 
32
#include <time.h>
33
 
34
#define put_time(_s) \
35
do { \
36
     time_t a_time_t; \
37
     a_time_t = time( 0 ); \
38
     printf( "%s%s", _s, ctime( &a_time_t ) ); \
39
} while(0)
40
 
41
 
42
 
43
void TestCre();
44
void TestDel();
45
void TestPsnd();
46
void TestRef();
47
void TestTrcv();
48
void TestRcv();
49
void TestPrcv();
50
 
51
void ITRON_Init( void )
52
{
53
    printf( "\n\n*** ITRONMBF01 -- ITRON MESSAGE BUFFER TEST ***\n" );
54
 
55
    TestCre();
56
    TestDel();
57
    TestPsnd();
58
    TestRef();
59
    TestRcv();
60
    TestRef();
61
    TestPrcv();
62
    TestTrcv();
63
 
64
    printf("\n\n*** ITRONMBF01 --- ITRON MESSAGE BUFFER TEST ***\n");
65
    exit(0);
66
}
67
 
68
void TestCre()
69
{
70
    ER      status;
71
    T_CMBF  pk_cmbf;
72
 
73
    /*
74
     *  Exercise cre_mbf - this code seems to exercise every path.
75
     */
76
 
77
    puts( "Init - cre_mbf - NULL pk_cmbf returns E_PAR" );
78
    status = cre_mbf( 1, NULL );
79
    assert( status == E_PAR );
80
 
81
    puts( "Init - cre_mbf - negative values for bufsz returns E_PAR" );
82
    pk_cmbf.bufsz = -1;
83
    pk_cmbf.maxmsz  = 100;
84
    pk_cmbf.mbfatr  = 0;
85
    pk_cmbf.exinf   = NULL;
86
    status = cre_mbf( 1, &pk_cmbf );
87
    assert( status == E_PAR );
88
 
89
    puts( "Init - cre_mbf - negative values for maxmsz returns E_PAR" );
90
    pk_cmbf.bufsz = 100;
91
    pk_cmbf.maxmsz  = -1;
92
    status = cre_mbf( 1, &pk_cmbf );
93
    assert( status == E_PAR );
94
 
95
    puts( "Init - cre_mbf - bufsz < maxmsz returns E_PAR" );
96
    pk_cmbf.bufsz = 100;
97
    pk_cmbf.maxmsz  = 101;
98
    status = cre_mbf( 1, &pk_cmbf );
99
    assert( status == E_PAR );
100
 
101
    /*
102
     *  Now run through all the bad ID errors
103
     */
104
 
105
    pk_cmbf.bufsz = 200;
106
    pk_cmbf.maxmsz = 30;
107
    puts( "Init - cre_mbf - bad id (less than -4) - E_OACV" );
108
    status = cre_mbf( -5, &pk_cmbf );
109
    assert( status == E_OACV );
110
 
111
    puts( "Init - cre_mbf - bad id (between 0 and -4) - E_ID" );
112
    status = cre_mbf( -4, &pk_cmbf );
113
    assert( status == E_ID );
114
 
115
    puts( "Init - cre_mbf - bad id (0) - E_ID" );
116
    status = cre_mbf( 0, &pk_cmbf );
117
    assert( status == E_ID );
118
 
119
    puts( "Init - cre_mbf - bad id (too great) - E_ID" );
120
    status = cre_mbf( CONFIGURE_MAXIMUM_ITRON_MESSAGE_BUFFERS + 1, &pk_cmbf );
121
    assert( status == E_ID );
122
 
123
    puts( "Init - cre_mbf - create mbf 1 TA_TFIFO - E_OK" );
124
    pk_cmbf.bufsz = 600;
125
    pk_cmbf.maxmsz  = 200;
126
    pk_cmbf.mbfatr  = TA_TFIFO;
127
    status = cre_mbf( 1, &pk_cmbf );
128
    assert( status == E_OK );
129
 
130
    puts( "Init - cre_mbf - create mbf 1 again - E_OBJ" );
131
    status = cre_mbf( 1, &pk_cmbf );
132
    assert( status == E_OBJ );
133
 
134
    puts( "Init - cre_mbf - create mbf 2 TA_TPRI - E_OK" );
135
    pk_cmbf.bufsz = 600;
136
    pk_cmbf.maxmsz  = 200;
137
    pk_cmbf.mbfatr  = TA_TPRI;
138
    status = cre_mbf( 2, &pk_cmbf );
139
    assert( status == E_OK );
140
}
141
 
142
void TestDel()
143
{
144
    ER    status;
145
 
146
    /*
147
     *  Generate all the bad id errors for del_mbf
148
     */
149
 
150
    puts( "Init - del_mbf - bad id (less than -4) - E_OACV" );
151
    status = del_mbf( -5 );
152
    assert( status == E_OACV );
153
 
154
    puts( "Init - del_mbf - bad id (between 0 and -4) - E_ID" );
155
    status = del_mbf( -4 );
156
    assert( status == E_ID );
157
 
158
    puts( "Init - del_mbf - bad id (0) - E_ID" );
159
    status = del_mbf( 0 );
160
    assert( status == E_ID );
161
 
162
    puts( "Init - del_mbf - bad id (too great) - E_ID" );
163
    status = del_mbf( CONFIGURE_MAXIMUM_ITRON_MESSAGE_BUFFERS + 1 );
164
    assert( status == E_ID );
165
 
166
 
167
    puts("Init - del_mbf   - E_OK" );
168
    status = del_mbf(2);
169
    assert(status == E_OK);
170
}
171
 
172
void TestPsnd()
173
{
174
    ER   status;
175
    char msg[100] = "This is test message 1";
176
 
177
    /*
178
     *  Generate all the bad id errors for psnd_mbf
179
     */
180
 
181
    puts( "Init - psnd_mbf - bad id (less than -4) - E_OACV" );
182
    status = psnd_mbf(-5, msg, sizeof(msg));
183
    assert( status == E_OACV );
184
 
185
    puts( "Init - psnd_mbf - bad id (between 0 and -4) - E_ID" );
186
    status = psnd_mbf(-4, msg, sizeof(msg));
187
    assert( status == E_ID );
188
 
189
    puts( "Init - psnd_mbf - bad id (0) - E_ID" );
190
    status = psnd_mbf(0, msg, sizeof(msg));
191
    assert( status == E_ID );
192
 
193
    puts( "Init - psnd_mbf - bad id (too great) - E_ID" );
194
    status = psnd_mbf(CONFIGURE_MAXIMUM_ITRON_MESSAGE_BUFFERS + 1, msg,
195
                      sizeof(msg));
196
    assert( status == E_ID );
197
 
198
    puts( "Init - psnd_mbf - msg == 0, E_PAR" );
199
    status = psnd_mbf(1, 0, sizeof(msg));
200
    assert( status == E_PAR );
201
 
202
    puts( "Init - psnd_mbf - msgsz too big - E_PAR" );
203
    status = psnd_mbf(1, msg, 300);
204
    assert( status == E_PAR );
205
 
206
    puts( "Init - psnd_mbf - msgsz <0 - E_PAR" );
207
    status = psnd_mbf(1, msg, -10);
208
    assert( status == E_PAR );
209
 
210
    puts( "Init - psnd_mbf - E_OK" );
211
    status = psnd_mbf(1, msg, sizeof(msg));
212
    assert( status == E_OK );
213
}
214
 
215
void TestRef()
216
{
217
    ER       status;
218
    T_RMBF   pk_rmbf;
219
 
220
    puts( "Init - ref_mbf - bad id (less than -4) - E_OACV" );
221
    status = ref_mbf(&pk_rmbf, -5);
222
    assert( status == E_OACV );
223
 
224
    puts( "Init - ref_mbf - bad id (between 0 and -4) - E_ID" );
225
    status = ref_mbf(&pk_rmbf, -4);
226
    assert( status == E_ID );
227
 
228
    puts( "Init - ref_mbf - bad id (0) - E_ID" );
229
    status = ref_mbf(&pk_rmbf, 0);
230
    assert( status == E_ID );
231
 
232
    puts( "Init - ref_mbf - bad id (too great) - E_ID" );
233
    status = ref_mbf(&pk_rmbf,
234
                     CONFIGURE_MAXIMUM_ITRON_MESSAGE_BUFFERS + 1);
235
    assert( status == E_ID );
236
 
237
    puts( "Init - ref_mbf - NULL pk_mbf returns E_PAR" );
238
    status = ref_mbf( NULL, 1 );
239
    assert( status == E_PAR );
240
 
241
    puts( "Init - ref_mbf - mbf 1 - E_OK" );
242
    status = ref_mbf( &pk_rmbf, 1 );
243
    assert( status == E_OK );
244
 
245
    printf( "Init - mbf 1 msgsz = %d\n", pk_rmbf.msgsz );
246
    printf( "Init - mbf 1 frbufsz = %d\n", pk_rmbf.frbufsz );
247
    printf( "Init - mbf 1 waiting tasks = %d\n", pk_rmbf.wtsk );
248
    printf( "Init - mbf 1 sending tasks = %d\n", pk_rmbf.stsk);
249
}
250
 
251
void TestRcv()
252
{
253
    ER    status;
254
    char  buffer[200];
255
    int   s;
256
 
257
    puts( "Init - rcv_mbf - bad id (less than -4) - E_OACV" );
258
    status = rcv_mbf(buffer, &s, -5);
259
    assert( status == E_OACV );
260
 
261
    puts( "Init - rcv_mbf - bad id (between 0 and -4) - E_ID" );
262
    status = rcv_mbf(buffer, &s, -4);
263
    assert( status == E_ID );
264
 
265
    puts( "Init - rcv_mbf - bad id (0) - E_ID" );
266
    status = rcv_mbf(buffer, &s, 0);
267
    assert( status == E_ID );
268
 
269
    puts( "Init - rcv_mbf - bad id (too great) - E_ID" );
270
    status = rcv_mbf(buffer, &s, CONFIGURE_MAXIMUM_ITRON_MESSAGE_BUFFERS + 1);
271
    assert( status == E_ID );
272
 
273
    puts( "Init - rcv_mbf - NULL msg returns E_PAR" );
274
    status = rcv_mbf(NULL, &s, 1);
275
    assert( status == E_PAR );
276
 
277
    puts( "Init - rcv_mbf - NULL p_msgsz returns E_PAR" );
278
    status = rcv_mbf(buffer, 0, 1);
279
    assert( status == E_PAR );
280
 
281
    puts("Init - rcv_mbf -- OK");
282
    status = rcv_mbf(buffer, &s, 1);
283
    assert(status == E_OK);
284
    printf("Message:[%s], length:%d\n", buffer, s);
285
}
286
 
287
 
288
void TestPrcv()
289
{
290
    ER    status;
291
    char  buffer[200];
292
    int   s;
293
 
294
    puts( "Init - prcv_mbf - bad id (less than -4) - E_OACV" );
295
    status = prcv_mbf(buffer, &s, -5);
296
    assert( status == E_OACV );
297
 
298
    puts( "Init - prcv_mbf - bad id (between 0 and -4) - E_ID" );
299
    status = prcv_mbf(buffer, &s, -4);
300
    assert( status == E_ID );
301
 
302
    puts( "Init - prcv_mbf - bad id (0) - E_ID" );
303
    status = prcv_mbf(buffer, &s, 0);
304
    assert( status == E_ID );
305
 
306
    puts( "Init - prcv_mbf - bad id (too great) - E_ID" );
307
    status = prcv_mbf(buffer, &s, CONFIGURE_MAXIMUM_ITRON_MESSAGE_BUFFERS + 1);
308
    assert( status == E_ID );
309
 
310
    puts( "Init - prcv_mbf - NULL msg returns E_PAR" );
311
    status = prcv_mbf(NULL, &s, 1);
312
    assert( status == E_PAR );
313
 
314
    puts( "Init - prcv_mbf - NULL p_msgsz returns E_PAR" );
315
    status = prcv_mbf(buffer, 0, 1);
316
    assert( status == E_PAR );
317
 
318
    puts("Init - prcv_mbf -- E_TMOUT");
319
    status = prcv_mbf(buffer, &s, 1);
320
    assert(status == E_TMOUT);
321
}
322
 
323
 
324
void TestTrcv()
325
{
326
    ER    status;
327
    char  buffer[200];
328
    int   s;
329
 
330
    puts( "Init - trcv_mbf - bad id (less than -4) - E_OACV" );
331
    status = trcv_mbf(buffer, &s, -5, 5000);
332
    assert( status == E_OACV );
333
 
334
    puts( "Init - trcv_mbf - bad id (between 0 and -4) - E_ID" );
335
    status = trcv_mbf(buffer, &s, -4, 5000);
336
    assert( status == E_ID );
337
 
338
    puts( "Init - trcv_mbf - bad id (0) - E_ID" );
339
    status = trcv_mbf(buffer, &s, 0, 5000);
340
    assert( status == E_ID );
341
 
342
    puts( "Init - trcv_mbf - bad id (too great) - E_ID" );
343
    status = trcv_mbf(buffer, &s,
344
                      CONFIGURE_MAXIMUM_ITRON_MESSAGE_BUFFERS + 1,
345
                      5000);
346
    assert( status == E_ID );
347
 
348
    puts( "Init - trcv_mbf - NULL msg returns E_PAR" );
349
    status = trcv_mbf(NULL, &s, 1, 5000);
350
    assert( status == E_PAR );
351
 
352
    puts( "Init - trcv_mbf - NULL p_msgsz returns E_PAR" );
353
    status = trcv_mbf(buffer, 0, 1, 5000);
354
    assert( status == E_PAR );
355
 
356
    puts( "Init - trcv_mbf - tmout <-2  returns E_PAR" );
357
    status = trcv_mbf(buffer, &s, 1, -2);
358
    assert( status == E_PAR );
359
 
360
    puts("\nInit - trcv_mbf -- E_TMOUT");
361
    put_time( "Init - starting to block at ");
362
    status = trcv_mbf(buffer, &s, 1, 1000);
363
    assert(status == E_TMOUT);
364
    put_time( "Init - time out at ");
365
}
366
 
367
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.