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

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.swp.api/] [openmcapi/] [1.0/] [test/] [func/] [fts_mcapi_delete_endpoint.c] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
/*
2
 * Copyright (c) 2010, Mentor Graphics Corporation
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 * 1. Redistributions of source code must retain the above copyright notice,
9
 *    this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
11
 *    this list of conditions and the following disclaimer in the documentation
12
 *    and/or other materials provided with the distribution.
13
 * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
 * POSSIBILITY OF SUCH DAMAGE.
28
 */
29
 
30
/*
31
*   FILENAME
32
*
33
*       fts_main.c
34
*
35
*
36
*************************************************************************/
37
 
38
#include "fts_defs.h"
39
#include "support_suite/mcapid_support.h"
40
#include "mcapid.h"
41
 
42
extern MCAPI_MUTEX      MCAPID_FTS_Mutex;
43
 
44
/************************************************************************
45
*
46
*   FUNCTION
47
*
48
*       MCAPI_FTS_Tx_2_6_1
49
*
50
*   DESCRIPTION
51
*
52
*       Testing mcapi_delete_endpoint with one message on the endpoint
53
*       waiting to be received.
54
*
55
*           Node 0 – Creates endpoint on boot up, transmit one message to
56
*           Node 1.
57
*
58
*           Node 1 – Create endpoint, wait for Node 0 to send data, delete
59
*           endpoint.
60
*
61
*************************************************************************/
62
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_6_1)
63
{
64
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
65
    mcapi_status_t      status;
66
 
67
    /* Don't let any other test run while this test is running. */
68
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
69
 
70
    /* Indicate that a remote endpoint should be created. */
71
    mcapi_struct->status =
72
        MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_CREATE_ENDP, 1024,
73
                               mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
74
 
75
    if (mcapi_struct->status == MCAPI_SUCCESS)
76
    {
77
        /* Wait for a response. */
78
        mcapi_struct->status = MCAPID_RX_Mgmt_Response(mcapi_struct);
79
 
80
        /* If the endpoint was created. */
81
        if (mcapi_struct->status == MCAPI_SUCCESS)
82
        {
83
            /* Indicate that a blocking TX call should be made from port
84
             * 1024.
85
             */
86
            mcapi_struct->status =
87
                MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_TX_BLCK_MSG, 1024,
88
                                       mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
89
 
90
            if (mcapi_struct->status == MCAPI_SUCCESS)
91
            {
92
                /* Wait for data to be received on the local endpoint. */
93
                while (mcapi_msg_available(mcapi_struct->local_endp, &status) == 0)
94
                {
95
                    MCAPID_Sleep(250);
96
                }
97
            }
98
 
99
            /* Tell the other side to delete the endpoint. */
100
            status =
101
                MCAPID_TX_Mgmt_Message(mcapi_struct, MCAPID_MGMT_DELETE_ENDP, 1024,
102
                                       mcapi_struct->local_endp, 0, MCAPI_DEFAULT_PRIO);
103
 
104
            if (status == MCAPI_SUCCESS)
105
            {
106
                /* Wait for a response before releasing the mutex. */
107
                status = MCAPID_RX_Mgmt_Response(mcapi_struct);
108
            }
109
 
110
            /* Delete the local endpoint. */
111
            mcapi_delete_endpoint(mcapi_struct->local_endp, &mcapi_struct->status);
112
        }
113
    }
114
 
115
    /* Set the state of the test to completed. */
116
    mcapi_struct->state = 0;
117
 
118
    /* Allow the next test to run. */
119
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
120
 
121
} /* MCAPI_FTS_Tx_2_6_1 */
122
 
123
/************************************************************************
124
*
125
*   FUNCTION
126
*
127
*       MCAPI_FTS_Tx_2_6_2
128
*
129
*   DESCRIPTION
130
*
131
*       Testing mcapi_delete_endpoint for packet channel connected
132
*       endpoint.
133
*
134
*           Node 0 – Creates endpoint on boot up, open receive side of
135
*           connection.
136
*
137
*           Node 1 – Create endpoint, get endpoint on Node 0, open send
138
*           side of connection, issue connection, delete send endpoint.
139
*
140
*************************************************************************/
141
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_6_2)
142
{
143
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
144
    mcapi_status_t      status;
145
 
146
    /* Don't let any other test run while this test is running. */
147
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
148
 
149
    /* Delete the local endpoint - the connection was made at start up, so this
150
     * call should fail.
151
     */
152
    mcapi_delete_endpoint(mcapi_struct->local_endp, &mcapi_struct->status);
153
    status_assert_code(mcapi_struct->status, MCAPI_ERR_CHAN_OPEN);
154
 
155
    /* Close the send side of the connection. */
156
    mcapi_packetchan_send_close_i(mcapi_struct->pkt_tx_handle,
157
                                  &mcapi_struct->request, &status);
158
 
159
    /* Set the state of the test to completed. */
160
    mcapi_struct->state = 0;
161
 
162
    /* Allow the next test to run. */
163
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
164
 
165
} /* MCAPI_FTS_Tx_2_6_2 */
166
 
167
/************************************************************************
168
*
169
*   FUNCTION
170
*
171
*       MCAPI_FTS_Tx_2_6_3
172
*
173
*   DESCRIPTION
174
*
175
*       Testing mcapi_delete_endpoint for scalar channel connected
176
*       endpoint.
177
*
178
*           Node 0 – Creates endpoint on boot up, open receive side of
179
*           connection.
180
*
181
*           Node 1 – Create endpoint, get endpoint on Node 0, open send
182
*           side of connection, issue connection, delete send endpoint.
183
*
184
*************************************************************************/
185
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_6_3)
186
{
187
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
188
    size_t              rx_len;
189
    mcapi_request_t     request;
190
 
191
    /* Don't let any other test run while this test is running. */
192
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
193
 
194
    /* Connect the two endpoints. */
195
    mcapi_connect_sclchan_i(mcapi_struct->local_endp,
196
                            mcapi_struct->foreign_endp,
197
                            &mcapi_struct->request,
198
                            &mcapi_struct->status);
199
    status_assert(mcapi_struct->status);
200
 
201
    mcapi_wait(&mcapi_struct->request, &rx_len,
202
               &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
203
    status_assert(mcapi_struct->status);
204
 
205
    /* Open the local endpoint as the sender. */
206
    mcapi_open_sclchan_send_i(&mcapi_struct->scl_tx_handle,
207
                              mcapi_struct->local_endp, &request,
208
                              &mcapi_struct->status);
209
    status_assert(mcapi_struct->status);
210
 
211
    /* Delete the local endpoint, which should fail. */
212
    mcapi_delete_endpoint(mcapi_struct->local_endp, &mcapi_struct->status);
213
    status_assert_code(mcapi_struct->status, MCAPI_ERR_CHAN_OPEN);
214
 
215
    /* Close the send side of the connection. */
216
    mcapi_sclchan_send_close_i(mcapi_struct->scl_tx_handle,
217
                               &mcapi_struct->request, &mcapi_struct->status);
218
    status_assert(mcapi_struct->status);
219
 
220
    /* Set the state of the test to completed. */
221
    mcapi_struct->state = 0;
222
 
223
    /* Allow the next test to run. */
224
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
225
 
226
} /* MCAPI_FTS_Tx_2_6_3 */
227
 
228
/************************************************************************
229
*
230
*   FUNCTION
231
*
232
*       MCAPI_FTS_Tx_2_6_4
233
*
234
*   DESCRIPTION
235
*
236
*       Testing mcapi_delete_endpoint for half open packet connection.
237
*
238
*           Node 0 – Creates endpoint on boot up, open receive side of
239
*           connection.
240
*
241
*           Node 1 – Create endpoint, get endpoint on Node 0,
242
*           issue connection, delete send endpoint.
243
*
244
*************************************************************************/
245
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_6_4)
246
{
247
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
248
    size_t              rx_len;
249
 
250
    /* Don't let any other test run while this test is running. */
251
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
252
 
253
    /* Get the packet server endpoint. */
254
    mcapi_struct->status =
255
        MCAPID_Get_Service("pkt_svr", &mcapi_struct->foreign_endp);
256
 
257
    if (mcapi_struct->status == MCAPI_SUCCESS)
258
    {
259
        /* Connect the two endpoints. */
260
        mcapi_connect_pktchan_i(mcapi_struct->local_endp,
261
                                mcapi_struct->foreign_endp,
262
                                &mcapi_struct->request, &mcapi_struct->status);
263
 
264
        if (mcapi_struct->status == MCAPI_SUCCESS)
265
        {
266
            /* Wait for the connection to return successfully. */
267
            mcapi_wait(&mcapi_struct->request, &rx_len,
268
                       &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
269
        }
270
 
271
        /* Delete the local endpoint.  An endpoint in a half-open connection
272
         * can be deleted.
273
         */
274
        mcapi_delete_endpoint(mcapi_struct->local_endp, &mcapi_struct->status);
275
 
276
        if (mcapi_struct->status == MCAPI_SUCCESS)
277
        {
278
            /* Let the other side process the fin. */
279
            MCAPID_Sleep(1000);
280
 
281
            /* Create another new endpoint. */
282
            mcapi_struct->local_endp =
283
                mcapi_create_endpoint(MCAPI_PORT_ANY, &mcapi_struct->status);
284
 
285
            /* Issue another connection to ensure the connection request for
286
             * the previous connection was canceled when the endpoint was
287
             * deleted.
288
             */
289
            mcapi_connect_pktchan_i(mcapi_struct->local_endp,
290
                                    mcapi_struct->foreign_endp,
291
                                    &mcapi_struct->request, &mcapi_struct->status);
292
 
293
            if (mcapi_struct->status == MCAPI_SUCCESS)
294
            {
295
                /* Wait for the connection to return successfully. */
296
                mcapi_wait(&mcapi_struct->request, &rx_len,
297
                           &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
298
 
299
                /* Delete the new endpoint. */
300
                mcapi_delete_endpoint(mcapi_struct->local_endp,
301
                                      &mcapi_struct->status);
302
            }
303
        }
304
    }
305
 
306
    /* Set the state of the test to completed. */
307
    mcapi_struct->state = 0;
308
 
309
    /* Allow the next test to run. */
310
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
311
 
312
} /* MCAPI_FTS_Tx_2_6_4 */
313
 
314
/************************************************************************
315
*
316
*   FUNCTION
317
*
318
*       MCAPI_FTS_Tx_2_6_5
319
*
320
*   DESCRIPTION
321
*
322
*       Testing mcapi_delete_endpoint for half open scalar connection.
323
*
324
*           Node 0 – Creates endpoint on boot up, open receive side of
325
*           connection.
326
*
327
*           Node 1 – Create endpoint, get endpoint on Node 0,
328
*           issue connection, delete send endpoint.
329
*
330
*************************************************************************/
331
MCAPI_THREAD_ENTRY(MCAPI_FTS_Tx_2_6_5)
332
{
333
    MCAPID_STRUCT       *mcapi_struct = (MCAPID_STRUCT*)argv;
334
    size_t              rx_len;
335
 
336
    /* Don't let any other test run while this test is running. */
337
    MCAPI_Obtain_Mutex(&MCAPID_FTS_Mutex);
338
 
339
    /* Get the packet server endpoint. */
340
    mcapi_struct->status =
341
        MCAPID_Get_Service("scl_svr", &mcapi_struct->foreign_endp);
342
 
343
    if (mcapi_struct->status == MCAPI_SUCCESS)
344
    {
345
        /* Connect the two endpoints. */
346
        mcapi_connect_sclchan_i(mcapi_struct->local_endp,
347
                                mcapi_struct->foreign_endp,
348
                                &mcapi_struct->request, &mcapi_struct->status);
349
 
350
        if (mcapi_struct->status == MCAPI_SUCCESS)
351
        {
352
            /* Wait for the connection to return successfully. */
353
            mcapi_wait(&mcapi_struct->request, &rx_len,
354
                       &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
355
        }
356
 
357
        /* Delete the local endpoint.  An endpoint in a half-open connection
358
         * can be deleted.
359
         */
360
        mcapi_delete_endpoint(mcapi_struct->local_endp, &mcapi_struct->status);
361
 
362
        if (mcapi_struct->status == MCAPI_SUCCESS)
363
        {
364
            /* Let the other side process the fin. */
365
            MCAPID_Sleep(1000);
366
 
367
            /* Create another new endpoint. */
368
            mcapi_struct->local_endp =
369
                mcapi_create_endpoint(MCAPI_PORT_ANY, &mcapi_struct->status);
370
 
371
            /* Issue another connection to ensure the connection request for
372
             * the previous connection was canceled when the endpoint was
373
             * deleted.
374
             */
375
            mcapi_connect_sclchan_i(mcapi_struct->local_endp,
376
                                    mcapi_struct->foreign_endp,
377
                                    &mcapi_struct->request, &mcapi_struct->status);
378
 
379
            if (mcapi_struct->status == MCAPI_SUCCESS)
380
            {
381
                /* Wait for the connection to return successfully. */
382
                mcapi_wait(&mcapi_struct->request, &rx_len,
383
                           &mcapi_struct->status, MCAPI_FTS_TIMEOUT);
384
 
385
                /* Delete the new endpoint. */
386
                mcapi_delete_endpoint(mcapi_struct->local_endp,
387
                                      &mcapi_struct->status);
388
            }
389
        }
390
    }
391
 
392
    /* Set the state of the test to completed. */
393
    mcapi_struct->state = 0;
394
 
395
    /* Allow the next test to run. */
396
    MCAPI_Release_Mutex(&MCAPID_FTS_Mutex);
397
 
398
} /* MCAPI_FTS_Tx_2_6_5 */

powered by: WebSVN 2.1.0

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