torture.c 19.4 KB
Newer Older
yoogx's avatar
yoogx committed
1
2
3
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
yoogx's avatar
yoogx committed
4
5
6
7
8
#include <fcntl.h>           /* For O_* constants */
#include <sys/stat.h>        /* For mode constants */
#include <semaphore.h>
#include <string.h>
#include <stdbool.h>
yoogx's avatar
yoogx committed
9
10
11
12

/* Files generated from AADL model */
#include <request.h>
#include <deployment.h>
yoogx's avatar
yoogx committed
13

yoogx's avatar
yoogx committed
14
15
#include <po_hi_transport.h>
#include <po_hi_gqueue.h>
16
#include <po_hi_returns.h>
yoogx's avatar
yoogx committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

/*****************************************************************************/
/* Helper macros to access AADL entities                                     */

#define LOCAL_PORT(THREAD_INSTANCE_NAME, PORT_NAME) THREAD_INSTANCE_NAME ## _local_ ## PORT_NAME
#define REQUEST_PORT(THREAD_INSTANCE_NAME, PORT_NAME) THREAD_INSTANCE_NAME ## _global_ ## PORT_NAME
#define PORT_VARIABLE(THREAD_INSTANCE_NAME, PORT_NAME) vars.REQUEST_PORT(THREAD_INSTANCE_NAME,PORT_NAME).REQUEST_PORT(THREAD_INSTANCE_NAME,PORT_NAME)

#define MACRO_TEST 42
#define MACRO_TEST_SECOND 33
#define MAX_TEST 0

int lvl = MACRO_TEST;
int sent_lvl;

int level = MACRO_TEST_SECOND;
int sent_level;

void test_sporad_1(__po_hi_task_id self);
void test_sporad_2(__po_hi_task_id self);
void test_sporad_3(__po_hi_task_id self);
void test_sporad_4(__po_hi_task_id self);
void test_sporad_5(__po_hi_task_id self);
40
void test_sporad_6(__po_hi_task_id self);
yoogx's avatar
yoogx committed
41
42
43
44
45

bool init = true;
bool first_iteration = true;
int number = 0;

46
47
48
/*
 * Integers allowing to count the events pending on each port
 */
yoogx's avatar
yoogx committed
49
50
int count_p1;
int count_p2;
51
int count_p3;
yoogx's avatar
yoogx committed
52
int count_p4;
yoogx's avatar
yoogx committed
53
54
int count_p5;
int count_p6;
55
int count_output;
yoogx's avatar
yoogx committed
56

57
58
59
/*
 * Declarations of port used in the connections.
 */
yoogx's avatar
yoogx committed
60
61
__po_hi_local_port_t port_p1 = LOCAL_PORT (spo_thread,p1);
__po_hi_local_port_t port_p2 = LOCAL_PORT (spo_thread,p2);
62
__po_hi_local_port_t port_p3 = LOCAL_PORT (spo_thread,p3);
yoogx's avatar
yoogx committed
63
__po_hi_local_port_t port_p4 = LOCAL_PORT (per_thread,p4);
yoogx's avatar
yoogx committed
64
__po_hi_local_port_t port_p6 = LOCAL_PORT (per_thread,p6);
65
__po_hi_local_port_t port_output = LOCAL_PORT (per_thread, p5);
yoogx's avatar
yoogx committed
66
67
68
69
70

/*
 * Semaphore used to coordinate the period and sporad tasks : At the
 * end of the first battery of test (number of message == 1), a
 * sem_post is done which liberates a sem_wait.  The number of
71
 * messages is increased by one for the second test.
yoogx's avatar
yoogx committed
72
73
74
 */
sem_t *semaphore;

75
76
77
78
79
/*********************************************************************************************************************************************/

/*
 * Periodic task receiving and sending messages depending on the case.
 */
yoogx's avatar
yoogx committed
80
void period(__po_hi_task_id self) {
yoogx's avatar
yoogx committed
81
82
  int i, j;

83
84
85
86
#if defined (TEST_VERBOSE)
    printf("Number of port_p1 = %d, port_p2 = %d, port_p3 = %d, port_p4 = %d, port_p6 = %d, port_output= %d\n", port_p1, port_p2, port_p3, port_p4, port_p6, port_output);
#endif

87
88
89
90
91
92
  if (init == true){
    semaphore = sem_open("/aadl", O_CREAT|O_EXCL, S_IRUSR | S_IWUSR, 1);
    if (semaphore == NULL) {
      sem_unlink ("/aadl");
      semaphore = sem_open("/aadl", O_CREAT|O_EXCL, S_IRUSR | S_IWUSR, 1);
    }
yoogx's avatar
yoogx committed
93
94
95
96
97
98
99
    init = false;
  }

  /* *** Boolean and semaphore launching the following test with
     *** "number" iterations *** */
  if (first_iteration){
    sem_wait(semaphore);
100
101
102
103
104
105
    if (number < 4){
      printf("\n\n**** Starting Tests **** \n");
    }
    if (number == 4){
      printf("\n**** Ending tests **** \n");
    }
yoogx's avatar
yoogx committed
106
107
108
109
110
111
112
    first_iteration = false;
    number++;
  }

  __po_hi_request_t r1;
  __po_hi_request_t r2;

yoogx's avatar
yoogx committed
113
/*****************************************************************************/
114
  /* *** SENDING FOR TEST SPORADIC 1 to 4 *** */
yoogx's avatar
yoogx committed
115
  /* *** Test of gqueue with one message *** */
116

yoogx's avatar
yoogx committed
117
118
119
120
121
122
123
124
  if (number < 2){
    /* Message sent on Period Port 1 to Sporad port 2 */
    sent_lvl = lvl;
    r1.port = REQUEST_PORT (per_thread, p1);
    r1.PORT_VARIABLE (per_thread,p1) = lvl;
    lvl++;

#if defined (TEST_VERBOSE)
125
    printf("\n Storeout Period P1 to Sporad P2, task id = %d, from port id = %d", self, LOCAL_PORT (per_thread, p1));
yoogx's avatar
yoogx committed
126
127
128
129
130
131
132
133
134
135
136
137
138
#endif

    __po_hi_gqueue_store_out
      (self,
       LOCAL_PORT (per_thread, p1),
       &r1);

    /* Message sent on Period Port 2 to Sporad Port 1 */
    sent_level = level;
    r2.port = REQUEST_PORT (per_thread, p2);
    r2.PORT_VARIABLE (per_thread,p2) = level;
    level++;
#if defined (TEST_VERBOSE)
139
    printf("\n Storeout Period P2 to Sporad P1, task id = %d, from port id = %d\n",
yoogx's avatar
yoogx committed
140
141
142
143
144
145
146
147
           self, LOCAL_PORT (per_thread, p2));
#endif
    __po_hi_gqueue_store_out
      (self,
       LOCAL_PORT (per_thread, p2),
       &r2);
  }

yoogx's avatar
yoogx committed
148
/*****************************************************************************/
149
  /* *** TEST PERIODIC 1 *** */
yoogx's avatar
yoogx committed
150
151
  /* *** Test of two messages sent on one port *** */
  /* Transmission */
152

yoogx's avatar
yoogx committed
153
154
155
156
157
  count_p4 = __po_hi_gqueue_get_count(self, port_p4);
  if ((number == 2)&&(count_p4 == 0)){
    printf("\n*** TEST PERIODIC 1 ***\n");
    count_p4 = __po_hi_gqueue_get_count(self, port_p4);
    assert (count_p4 == 0);
158
    for (i = 1; i <= number ; i++){
yoogx's avatar
yoogx committed
159
160
161
162
163
      sent_lvl = lvl;
      r1.port = REQUEST_PORT (per_thread, p3);
      r1.PORT_VARIABLE (per_thread,p3) = lvl;
      lvl++;
#if defined (TEST_VERBOSE)
164
      printf("\n Storeout Period P3 to Period P4, task id = %d, from port id = %d", self, LOCAL_PORT (per_thread, p3));
yoogx's avatar
yoogx committed
165
166
167
168
169
170
171
172
173
#endif
      __po_hi_gqueue_store_out
        (self,
         LOCAL_PORT (per_thread, p3),
         &r1);
      __po_hi_send_output (self,REQUEST_PORT(per_thread, p3));
    }
    assert (count_p4 == 0);
  }
174

yoogx's avatar
yoogx committed
175
  /* Reception */
176

yoogx's avatar
yoogx committed
177
  count_p4 = __po_hi_gqueue_get_count(self, port_p4);
178
  if ((number == 2)&&(count_p4 == number )){
yoogx's avatar
yoogx committed
179
180
181
    __po_hi_request_t request;
    int reception;
    count_p4 = __po_hi_gqueue_get_count(self, port_p4);
yoogx's avatar
yoogx committed
182
    for (j = 0; j < count_p4; j++) {
yoogx's avatar
yoogx committed
183
184
185
186
187
188
    __po_hi_gqueue_get_value(self,port_p4,&(request));
    reception = request.PORT_VARIABLE(per_thread,p4);
#if defined (TEST_VERBOSE)
    printf("\nfirst request = %d", MACRO_TEST);
    printf("\nsent_lvl = %d", sent_lvl);
    printf("\nreceived = %d", reception);
189
    printf("\nnumber received, j = %d %d\n", number , j);
yoogx's avatar
yoogx committed
190
191
192
193
#endif
    assert(reception == sent_lvl - number + j + 1);
    __po_hi_gqueue_next_value (self,port_p4);
   }
194
195
   printf ("two Messages test passed\n");
    /* Necessary to launch new tests, otherwise triggered by sporadic if it is involved */
yoogx's avatar
yoogx committed
196
197
198
199
    first_iteration = true;
    sem_post(semaphore);
  }

yoogx's avatar
yoogx committed
200
/*****************************************************************************/
201
202
203
   /* *** TEST PERIODIC 2 *** */
   /* *** Test of gqueue error messages *** */
   /* *** Test of get value on an output port error message *** */
yoogx's avatar
yoogx committed
204
205
206
   /* Transmission */

  count_p6 = __po_hi_gqueue_get_count(self, port_p6);
207
208
  if ((number == 3)&&(count_p6 == 0)){
   printf("\n*** TEST PERIODIC 2 ***\n");
yoogx's avatar
yoogx committed
209
210
   count_p6 = __po_hi_gqueue_get_count(self, port_p6);
   assert (count_p6 == 0);
yoogx's avatar
yoogx committed
211
   for (i = 1; i < number ; i++){
yoogx's avatar
yoogx committed
212
213
214
215
216
      sent_lvl = lvl;
      r1.port = REQUEST_PORT (per_thread, p5);
      r1.PORT_VARIABLE (per_thread,p5) = lvl;
      lvl++;
#if defined (TEST_VERBOSE)
217
      printf("\n Storeout Period P5 to Period P6, task id = %d, from port id = %d", self, LOCAL_PORT (per_thread, p5));
yoogx's avatar
yoogx committed
218
219
220
221
222
223
224
225
#endif
      __po_hi_gqueue_store_out
        (self,
         LOCAL_PORT (per_thread, p5),
         &r1);
      __po_hi_send_output (self,REQUEST_PORT(per_thread, p5));
    }
  }
226

yoogx's avatar
yoogx committed
227
228
229
  /* Reception */

  count_p6 = __po_hi_gqueue_get_count(self, port_p6);
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
  if (number == 3){

  /* One message only must have been received */
   assert (count_p6 == 1);
   __po_hi_request_t request;
   int reception;

  /* Verifying the only message stored is the one send in the first place */
   __po_hi_gqueue_get_value(self,port_p6,&(request));
   reception = request.PORT_VARIABLE(per_thread,p6);
   assert(reception == sent_lvl - 1);

   /* The transport send function blocks the sending of the second message to the FULL port.
    * An error message should appear */
   printf ("\n*** An error message from TRANSPORT should appear *** \n");

   /* When forcing the store_in of a random value on a FULL port, 
    * An error message must be sent by the store_in function */
    __po_hi_gqueue_store_in(self, port_p6, &r1);
    printf ("*** A second message from GQUEUE should appear *** \n");

   /* Verifying the previous store_in has failed and not overwritten the value */
   __po_hi_gqueue_get_value(self,port_p6,&(request));
   reception = request.PORT_VARIABLE(per_thread,p6);
   assert(reception == sent_lvl - 1);

yoogx's avatar
yoogx committed
256
    count_p6 = __po_hi_gqueue_get_count(self, port_p6);
yoogx's avatar
yoogx committed
257
    for (j = 0; j < count_p6; j++) {
yoogx's avatar
yoogx committed
258
259
    __po_hi_gqueue_next_value (self,port_p6);
    }
260
261
262
263
264
265
266
267
268
269
270
271
    /* The port is cleaned and at the end of the function, as all ports are flushed, the message will be sent */
     printf ("*** If so, 'error message on full queue' test passed *** \n");
   
   /* Trying to reach something on the output port of the case */
   int err = __po_hi_gqueue_get_value(self,port_output,&(request));
   assert (err == __PO_HI_INVALID);
   printf ("*** An error message from GQUEUE should appear *** \n");
   printf ("*** If so, 'get value on output port' test passed *** \n");
  
   /* Necessary to launch new tests, otherwise triggered by sporadic if it is involved */
   first_iteration = true;
   sem_post(semaphore);
yoogx's avatar
yoogx committed
272
273
  }

274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
/*****************************************************************************/
   /* *** SENDING FOR TEST SPORADIC 5 *** */
   /* *** Test of fifo indata *** */

  if (number == 4){

    /* Dequeuing the message arrived at the new iteration of the function. 
     * The message couldn't be sent previously because the port was full (cf test periodic 2).
     * The line is only present to reset the port to an empty state */
    __po_hi_gqueue_next_value (self,port_p6);
    count_p6 = __po_hi_gqueue_get_count(self, port_p6);
    assert(count_p6 == 0);

    /* Transmission towards the fifo indata port */
    sent_lvl = lvl;
    r1.port = REQUEST_PORT (per_thread, p7);
    r1.PORT_VARIABLE (per_thread,p7) = lvl;
    lvl++;

#if defined (TEST_VERBOSE)
    printf("\n Storeout Period P7 to Sporad P3, task id = %d, from port id = %d", self, LOCAL_PORT (per_thread, p7));
#endif

    __po_hi_gqueue_store_out
      (self,
       LOCAL_PORT (per_thread, p7),
       &r1);  

    /* Adding a send output through P2 "just" to awaken the sporadic task
       to process incoming data on its data port */

#if defined (TEST_VERBOSE)
    printf("\n Storeout Period P2 to Sporad P1, task id = %d, from port id = %d", self, LOCAL_PORT (per_thread, p1));
#endif

    r1.port = REQUEST_PORT (per_thread, p2);
    r1.PORT_VARIABLE (per_thread,p2) = lvl;
    __po_hi_gqueue_store_out
      (self,
       LOCAL_PORT (per_thread, p2),
       &r1);
  }

/*****************************************************************************/
   /* *** Getting out of loop *** */
  if (number > 4){
yoogx's avatar
yoogx committed
320
321
322
          sem_unlink("/aadl");
          sem_close(semaphore);
          exit(0);
yoogx's avatar
yoogx committed
323
324
325
  }
}

326
327
328
329
/*********************************************************************************************************************************************/
/*
 * Sporadic task triggered by received events.
 */
yoogx's avatar
yoogx committed
330
331
332
333
334
335
336
337
338
339
340
341
342
343
void sporad(__po_hi_task_id self) {
  /* Test with one message sent by the Period task */
  if (number == 1){
    /* Test of the get_count function */
    test_sporad_1 (self);
    /* Test of the next_value function */
    test_sporad_2 (self);
    /* Test of the function get_value on an empty port */
    test_sporad_3 (self);
    /* FIFO test on reception port P1 */
    test_sporad_4 (self);
    /* FIFO test on reception port P2 */
    test_sporad_5 (self);
  }
344
345
346
347
  
  if (number == 4){
    test_sporad_6 (self);
  }
yoogx's avatar
yoogx committed
348

yoogx's avatar
yoogx committed
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
  /* Boolean and semaphore launching the next type of test */
  first_iteration = true;
  sem_post(semaphore);
}

/*****************************************************************************/
void test_sporad_1(__po_hi_task_id self) {
  printf ("\n*** TEST SPORADIC 1 ***\n");
  /*After reception the size used must be 1 */
  count_p1 = __po_hi_gqueue_get_count(self, port_p1);
  count_p2 = __po_hi_gqueue_get_count(self, port_p2);
  assert (count_p1 == 1);
  assert (count_p2 == 1);
  printf ("get_count test passed\n");
}

/*****************************************************************************/
void test_sporad_2(__po_hi_task_id self) {
yoogx's avatar
yoogx committed
367
  int i, reception;
yoogx's avatar
yoogx committed
368
369
370
371
372
373
374
375
  __po_hi_request_t request;
  __po_hi_local_port_t tryport;
  printf ("\n*** TEST SPORADIC 2 ***\n");
  count_p1 = __po_hi_gqueue_get_count(self, port_p1);
  count_p2 = __po_hi_gqueue_get_count(self, port_p2);
  assert (count_p1 == 1);
  assert (count_p2 == 1);
  /* All values are dequeued */
yoogx's avatar
yoogx committed
376
  for (i = 0; i < count_p1 + count_p2 ; i++) {
yoogx's avatar
yoogx committed
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
    __po_hi_gqueue_wait_for_incoming_event(self, &tryport);
    if (i == 0){
      /* The sending is done first on port p1 to port p1 */
      assert(tryport == port_p2);
      printf ("wait_for_incoming_event test passed \n");
    }
    __po_hi_gqueue_get_value(self,tryport,&(request));
    if (tryport == port_p1){
      reception = request.PORT_VARIABLE(spo_thread,p1);
      assert (reception == sent_level);
      printf ("get_value first test passed \n");
    }
    if (tryport == port_p2){
      reception = request.PORT_VARIABLE(spo_thread,p2);
      assert (reception == sent_lvl);
      printf ("get_value first test passed \n");
    }
    __po_hi_gqueue_next_value (self, tryport);
  }
  /* The ports are supposedly all empty */
  count_p1 = __po_hi_gqueue_get_count(self, port_p1);
  count_p2 = __po_hi_gqueue_get_count(self, port_p2);
  assert (count_p1 == 0);
  assert (count_p2 == 0);
  printf ("next_value test passed\n");
}

/*****************************************************************************/
void test_sporad_3(__po_hi_task_id self) {
  printf ("\n*** TEST SPORADIC 3 ***\n");
  __po_hi_request_t request;

  /* Test of Get_value on an empty port: */
  /* The function supposedly blocks the thread until something is received: */
  __po_hi_gqueue_get_value(self,port_p2,&(request));

  /* Values have been received on each port*/
  count_p1 = __po_hi_gqueue_get_count(self, port_p1);
  count_p2 = __po_hi_gqueue_get_count(self, port_p2);
  assert (count_p1 == 1);
  assert (count_p2 == 1);
  printf ("get_value second test passed \n");
}
/*****************************************************************************/
void test_sporad_4(__po_hi_task_id self) {
  int reception;
  __po_hi_request_t request;

  printf ("\n*** TEST SPORADIC 4 ***\n");
  count_p1 = __po_hi_gqueue_get_count(self, port_p1);
  count_p2 = __po_hi_gqueue_get_count(self, port_p2);
  assert (count_p1 == 1);
  assert (count_p2 == 1);

  /* Dequeuing port P2 */
  __po_hi_gqueue_get_value(self,port_p2,&(request));
  __po_hi_gqueue_next_value (self, port_p2);

  count_p1 = __po_hi_gqueue_get_count(self, port_p1);
  count_p2 = __po_hi_gqueue_get_count(self, port_p2);

  assert (count_p1 == 1);
  assert (count_p2 == 0);

  /* Blocking on port P2 */
  __po_hi_gqueue_get_value(self,port_p2,&(request));

  /* Reception */

  count_p1 = __po_hi_gqueue_get_count(self, port_p1);
  count_p2 = __po_hi_gqueue_get_count(self, port_p2);
  assert (count_p1 == 2);
  assert (count_p2 == 1);
  /* We have attained optimal configuration */

  /* No issue on port P2 */
  __po_hi_gqueue_get_value(self,port_p2,&(request));
  reception = request.PORT_VARIABLE(spo_thread,p2);

#if defined (TEST_VERBOSE)
  printf("\nfirst request = %d", MACRO_TEST);
  printf("\nsent_lvl = %d", sent_lvl);
  printf("\nreceived = %d", reception);
#endif
  assert (reception == sent_lvl);

  /* On port P1 : Due to the FIFO aspect of the gqueue, the value
     received is not the one just sent, but the previous one */
  __po_hi_gqueue_get_value(self,port_p1,&(request));
  reception = request.PORT_VARIABLE(spo_thread,p1);

#if defined (TEST_VERBOSE)
  printf("\nfirst request = %d", MACRO_TEST_SECOND);
  printf("\nsent_level = %d", sent_level);
  printf("\nreceived = %d", reception);
#endif

  assert (reception != sent_level );
  assert (reception == sent_level - 1);

  /* We ensure to have only one value on each port */
  __po_hi_gqueue_next_value (self,port_p1);

  count_p1 = __po_hi_gqueue_get_count(self, port_p1);
  count_p2 = __po_hi_gqueue_get_count(self, port_p2);
  assert (count_p1 == 1);
  assert (count_p2 == 1);

  printf ("FIFO test on port p1 passed \n");

}

/*****************************************************************************/
void test_sporad_5(__po_hi_task_id self) {

yoogx's avatar
yoogx committed
492
  int i, j, reception;
yoogx's avatar
yoogx committed
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
  __po_hi_request_t request;

  printf ("\n*** TEST SPORADIC 5 ****\n");
  count_p1 = __po_hi_gqueue_get_count(self, port_p1);
  count_p2 = __po_hi_gqueue_get_count(self, port_p2);
  assert (count_p1 == 1);
  assert (count_p2 == 1);

  /* Dequeuing port P1  */
  __po_hi_gqueue_get_value(self,port_p1,&(request));
  __po_hi_gqueue_next_value (self, port_p1);

  count_p1 = __po_hi_gqueue_get_count(self, port_p1);
  count_p2 = __po_hi_gqueue_get_count(self, port_p2);

  assert (count_p1 == 0);
  assert (count_p2 == 1);

  /* Blocking on port P1 */
  __po_hi_gqueue_get_value(self,port_p1,&(request));
  count_p1 = __po_hi_gqueue_get_count(self, port_p1);
  count_p2 = __po_hi_gqueue_get_count(self, port_p2);
  assert (count_p1 == 1);
  assert (count_p2 == 2);

  /* On port p2 : Due to the FIFO aspect of the gqueue, the value
     received is not the one just sent, but the previous one */
  __po_hi_gqueue_get_value(self,port_p2,&(request));
  reception = request.PORT_VARIABLE(spo_thread,p2);

#if defined (TEST_VERBOSE)
  printf("\nfirst request = %d", MACRO_TEST);
  printf("\nsent_lvl = %d", sent_lvl);
  printf("\nreceived = %d", reception);
#endif

  assert (reception != sent_lvl);
  assert (reception == sent_lvl - 1);

  /* No issue on port P1 */
  __po_hi_gqueue_get_value(self,port_p1,&(request));
  reception = request.PORT_VARIABLE(spo_thread,p1);

#if defined (TEST_VERBOSE)
  printf("\nfirst request = %d", MACRO_TEST_SECOND);
  printf("\nsent_level = %d", sent_level);
  printf("\nreceived = %d", reception);
#endif

  assert (reception == sent_level);
  __po_hi_gqueue_next_value (self,port_p2);

  count_p1 = __po_hi_gqueue_get_count(self, port_p1);
  count_p2 = __po_hi_gqueue_get_count(self, port_p2);
  assert (count_p1 == 1);
  assert (count_p2 == 1);

yoogx's avatar
yoogx committed
550
  for (i = 0; i < count_p1; i++) {
yoogx's avatar
yoogx committed
551
552
    __po_hi_gqueue_next_value (self,port_p1);
  }
yoogx's avatar
yoogx committed
553
  for (j = 0; j < count_p2; j++) {
yoogx's avatar
yoogx committed
554
555
556
557
558
559
560
561
562
563
    __po_hi_gqueue_next_value (self,port_p2);
  }

  count_p1 = __po_hi_gqueue_get_count(self, port_p1);
  count_p2 = __po_hi_gqueue_get_count(self, port_p2);
  assert (count_p1 == 0);
  assert (count_p2 == 0);

  printf ("FIFO test on port p2 passed\n");
}
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595

/*****************************************************************************/

void test_sporad_6(__po_hi_task_id self) {
  __po_hi_request_t request;
  int reception;
  printf ("\n*** TEST SPORADIC 6 ****\n");
  printf ("*** A warning message from GQUEUE (store_in) should have appeared *** \n");
  /* Verifying that the reception has been done well */
  __po_hi_gqueue_get_value(self,port_p3,&(request));
   reception = request.PORT_VARIABLE(spo_thread,p3);
   assert(reception == sent_lvl);

  /* Asserting the used_size is always of 0 for indata port */
  count_p3 = __po_hi_gqueue_used_size(self, port_p3);
  assert(count_p3 == 0);
  printf ("*** A warning message from GQUEUE (next_value) should appear *** \n");
   __po_hi_gqueue_next_value(self,port_p3);
  count_p3 = __po_hi_gqueue_used_size(self, port_p3);
  assert(count_p3 == 0);
  /* Verifying that the get_count is Still of 1 after dequeuing */
  printf ("*** A warning message from GQUEUE (get_count) should appear *** \n");
  count_p3 = __po_hi_gqueue_get_count(self, port_p3);
  assert (count_p3 == 1);
  /* Get_value on an empty port */
  __po_hi_gqueue_get_value(self,port_p3,&(request));
  /* Dequeuing the event that has served to trigger the sporadic task */
  int a = __po_hi_gqueue_next_value (self,port_p1);
  assert (a == 1);
  printf ("\n*** If so, FIFO INDATA test passed *** ");
}