-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathut_edroombp_pr_task.cpp
1196 lines (932 loc) · 28.2 KB
/
ut_edroombp_pr_task.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
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
492
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
550
551
552
553
554
555
556
557
558
559
560
561
562
563
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
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* \file ut_edroombp_pr_task.cpp
*
* \brief This swpackage implements the test suites applied over the edroombp
* Task Manager (Pr_Task) services for the RTEMSAPI 4.8 improvement
*
* \author Santiago Carmona Meco, <[email protected]>
* \internal
* Created: 06-nov-2013
* Compiler: gcc,g++
* Company: Space Research Group, Universidad de Alcalá.
* Copyright: Copyright (c) 2013, Santiago Carmona Meco
*
* For further information, please visit http://srg.aut.uah.es
*
* This software is provided under the terms of the GNU General Public v2
* Licence. A full copy of the GNU GPL is provided in the file COPYING
* found in the development root of the project.
*
*/
#include "ut_edroombp_pr_task_iface_v1.h"
#include <stdio.h>
///*This include is required to the CUT_EDROOMBP_PR_TASK_DELETE_TASK test*/
//#include <public/rtemsapi_4_8_impr.h>
#define ERROR_NOTIFY() CUT_EDROOMBP::WriteFail("error", __LINE__, __FILE__)
/*
* The next set of tests are identified under the rtems improvement validation
* test suites, but each of these tests has been adapted to be applied for one
* or more of the edroombp Task Manager service
*/
/*----------------------------------------------------------------------------*/
/*------------------------------- val_02_03_010 ------------------------------*/
/*----------------------------------------------------------------------------*/
bool_t taskSuccessOk=false;
bool_t taskStackSizeErrorOk=false;
static Pr_TaskRV_t TASK_SUCCESS(Pr_TaskP_t)
{
taskSuccessOk = true;
}
static Pr_TaskRV_t TASK_STACK_SIZE_ERROR(Pr_TaskP_t)
{
taskStackSizeErrorOk = true;
}
CUT_EDROOMBP_PR_TASK_CREATION_AND_START::CUT_EDROOMBP_PR_TASK_CREATION_AND_START(const char * id) :
CUTBase(id, true, true, 9873829),
kernel(),
taskSuccess(TASK_SUCCESS, EDROOMprioVeryHigh, 512),
taskCodeError(NULL, EDROOMprioVeryHigh, 512),
taskStackSizeError(TASK_STACK_SIZE_ERROR, EDROOMprioVeryHigh,
4 * 1024 * 1024),
pTaskSuccessOk(&taskSuccessOk),
pTaskStackSizeErrorOk(&taskStackSizeErrorOk)
{
/* Initializing the test values*/
taskSuccessOk = false;
taskStackSizeErrorOk = false;
}
bool_t CUT_EDROOMBP_PR_TASK_CREATION_AND_START::DoTest(void)
{
/*Instantiating the tests (objects) that we want to execute*/
Pr_DelayIn(Pr_Time(10,0));
return ((*pTaskSuccessOk) && (!(*pTaskStackSizeErrorOk)));
}
/*----------------------------------------------------------------------------*/
/*------------------------------- val_02_03_020 ------------------------------*/
/*----------------------------------------------------------------------------*/
extern Pr_Task * pPr_Task;
static Pr_TaskRV_t TASK_DELETED(Pr_TaskP_t)
{
}
CUT_EDROOMBP_PR_TASK_DELETE_TASK::CUT_EDROOMBP_PR_TASK_DELETE_TASK(const char * id) :
CUTBase(id, true, true, 9873829),
kernel(),
testOk(true)
{
Pr_Task taskDeleted(TASK_DELETED, EDROOMprioVeryHigh, 512);
Pr_DelayIn(Pr_Time(1,0));
/*
* We try to restart the task with the aim of check that after to be
* executed was deleted, i.e., the rtems_task_restart must return a error
* state
*/
//TODO: este test habrá que rediseñarlo para no usar primitivas de rtems
// if (RTEMS_SUCCESSFUL== rtems_task_restart(taskDeleted.GetTaskID(),
// (rtems_task_argument) pPr_Task))
// {
// testOk = false;
// }
}
bool_t CUT_EDROOMBP_PR_TASK_DELETE_TASK::DoTest(void)
{
Pr_DelayIn(Pr_Time(10,0));
return (testOk);
}
/*----------------------------------------------------------------------------*/
/*------------------------------- val_02_03_060 ------------------------------*/
/*----------------------------------------------------------------------------*/
Pr_Task *pTaskPriority;
bool_t testPriorityOk=true;
static Pr_TaskRV_t TASK_PRIORITY(Pr_TaskP_t)
{
/*check the initial priority*/
if (EDROOMprioNormal != pTaskPriority->GetTaskPrio()
&& EDROOMprioNormal != pTaskPriority->GetTmpTaskPrio())
{
printf("ERROR: check the initial priority\n");
testPriorityOk = false;
return;
}
/*SetMaxPrioTmp*/
pTaskPriority->SetMaxPrioTmp(EDROOMprioLow);
if (EDROOMprioNormal != pTaskPriority->GetTaskPrio()
&& EDROOMprioNormal != pTaskPriority->GetTmpTaskPrio())
{
printf("ERROR: pTaskPriority->SetMaxPrioTmp(EDROOMprioLow)\n");
testPriorityOk = false;
return;
}
pTaskPriority->SetMaxPrioTmp(EDROOMprioVeryHigh);
if (EDROOMprioNormal != pTaskPriority->GetTaskPrio()
&& EDROOMprioVeryHigh != pTaskPriority->GetTmpTaskPrio())
{
printf("ERROR: pTaskPriority->SetMaxPrioTmp(EDROOMprioVeryHigh)\n");
testPriorityOk = false;
return;
}
/*SetMaxPrioMsg*/
pTaskPriority->SetMaxPrioMsg(EDROOMprioLow);
if (EDROOMprioNormal != pTaskPriority->GetTaskPrio()
&& EDROOMprioVeryHigh != pTaskPriority->GetTmpTaskPrio())
{
printf("ERROR: pTaskPriority->SetMaxPrioMsg(EDROOMprioHigh)\n");
testPriorityOk = false;
return;
}
pTaskPriority->SetMaxPrioMsg(EDROOMprioHigh);
if (EDROOMprioHigh != pTaskPriority->GetTaskPrio()
&& EDROOMprioVeryHigh != pTaskPriority->GetTmpTaskPrio())
{
printf("ERROR: pTaskPriority->SetMaxPrioMsg(EDROOMprioHigh)\n");
testPriorityOk = false;
return;
}
pTaskPriority->SetMaxPrioMsg(EDROOMprioURGENT);
if (EDROOMprioURGENT != pTaskPriority->GetTaskPrio()
&& EDROOMprioURGENT != pTaskPriority->GetTmpTaskPrio())
{
printf("ERROR: pTaskPriority->SetMaxPrioMsg(EDROOMprioURGENT)\n");
testPriorityOk = false;
return;
}
/*SetPriority*/
pTaskPriority->SetPriority(EDROOMprioNormal);
if (EDROOMprioNormal != pTaskPriority->GetTaskPrio()
&& EDROOMprioNormal != pTaskPriority->GetTmpTaskPrio())
{
printf("ERROR: pTaskPriority->SetPriority(EDROOMprioNormal)\n");
testPriorityOk = false;
return;
}
pTaskPriority->SetPriority(EDROOMprioNormal);
pTaskPriority->SetMaxPrioTmp(EDROOMprioVeryHigh);
pTaskPriority->RestorePrioMsg();
pTaskPriority->RestorePrioMsg();
if (EDROOMprioNormal != pTaskPriority->GetTaskPrio()
&& EDROOMprioNormal != pTaskPriority->GetTmpTaskPrio())
{
printf("ERROR: pTaskPriority->SetPriority(EDROOMprioNormal)\n");
testPriorityOk = false;
return;
}
}
CUT_EDROOMBP_PR_TASK_CHANGE_PRIORITIES_OPERATIONS::CUT_EDROOMBP_PR_TASK_CHANGE_PRIORITIES_OPERATIONS(const char * id) :
CUTBase(id, true, true, 9873829),
kernel(),
taskPriority(TASK_PRIORITY, EDROOMprioNormal, 512),
pTestOk(&testPriorityOk)
{
testPriorityOk = true;
pTaskPriority = &taskPriority;
}
bool_t CUT_EDROOMBP_PR_TASK_CHANGE_PRIORITIES_OPERATIONS::DoTest(void)
{
Pr_DelayIn(Pr_Time(10,0));
return (*pTestOk);
}
/*----------------------------------------------------------------------------*/
/*------------------------------- val_02_03_102 ------------------------------*/
/*----------------------------------------------------------------------------*/
Pr_Task *pTaskASenderReceiver;
Pr_Task *pTaskCReceiverSender;
Pr_Task *pTaskBSenderReceiver;
Pr_Task *pTaskDReceiverSender;
bool_t testSendAndReceiveOk = false;
uint8_t orderControlSendReceive=0;
static Pr_TaskRV_t TASK_A_SEND_AND_RECEIVE(Pr_TaskP_t)
{
uint8_t dataToSend = 0xAC;
uint8_t dataToReceive = 0;
Pr_Send(*pTaskCReceiverSender,(void*)&dataToSend);
Pr_Receive(&dataToReceive, sizeof(uint8_t));
if (0xDA != dataToReceive || orderControlSendReceive!=2)
{
printf("TASK_A_SEND_AND_RECEIVE data 0x%X order %d\n",dataToReceive,orderControlSendReceive);
return;
}
else
{
orderControlSendReceive++;
}
}
static Pr_TaskRV_t TASK_B_SEND_AND_RECEIVE(Pr_TaskP_t)
{
uint8_t dataToSend = 0xBD;
uint8_t dataToReceive = 0;
Pr_Send(*pTaskDReceiverSender,(void*)&dataToSend);
Pr_Receive(&dataToReceive, sizeof(uint8_t));
if (0xCB != dataToReceive || orderControlSendReceive!=3)
{
printf("TASK_B_SEND_AND_RECEIVE data 0x%X order %d\n",dataToReceive,orderControlSendReceive);
return;
}
else
{
testSendAndReceiveOk=true;
}
}
static Pr_TaskRV_t TASK_C_RECEIVE_AND_SEND(Pr_TaskP_t)
{
uint8_t dataToSend = 0xCB;
uint8_t dataToReceive = 0;
Pr_Receive(&dataToReceive, sizeof(uint8_t));
if (0xAC != dataToReceive || orderControlSendReceive!=0)
{
printf("TASK_C_RECEIVE_AND_SEND data 0x%X order %d\n",dataToReceive,orderControlSendReceive);
return;
}
else
{
orderControlSendReceive++;
}
Pr_DelayIn(Pr_Time(1,0));
Pr_Send(*pTaskBSenderReceiver,(void*)&dataToSend);
}
static Pr_TaskRV_t TASK_D_RECEIVE_AND_SEND(Pr_TaskP_t)
{
uint8_t dataToSend = 0xDA;
uint8_t dataToReceive = 0;
Pr_Receive(&dataToReceive, sizeof(uint8_t));
if (0xBD != dataToReceive || orderControlSendReceive!=1)
{
printf("TASK_D_RECEIVE_AND_SEND data 0x%X order %d\n",dataToReceive,orderControlSendReceive);
return;
}
else
{
orderControlSendReceive++;
}
Pr_Send(*pTaskASenderReceiver,(void*)&dataToSend);
}
CUT_EDROOMBP_PR_TASK_SEND_AND_RECEIVE::CUT_EDROOMBP_PR_TASK_SEND_AND_RECEIVE(const char * id) :
CUTBase(id, true, true, 9873829),
kernel(),
taskASenderReceiver(TASK_A_SEND_AND_RECEIVE, EDROOMprioVeryHigh, 2048),
taskBSenderReceiver(TASK_B_SEND_AND_RECEIVE, EDROOMprioHigh, 2048),
taskCReceiverSender(TASK_C_RECEIVE_AND_SEND, EDROOMprioNormal, 2048),
taskDReceiverSender(TASK_D_RECEIVE_AND_SEND, EDROOMprioLow, 2048),
pTaskSendAndReceiveOk(&testSendAndReceiveOk)
{
pTaskASenderReceiver = &taskASenderReceiver;
pTaskCReceiverSender = &taskCReceiverSender;
pTaskBSenderReceiver = &taskBSenderReceiver;
pTaskDReceiverSender = &taskDReceiverSender;
testSendAndReceiveOk = false;
}
bool_t CUT_EDROOMBP_PR_TASK_SEND_AND_RECEIVE::DoTest(void)
{
Pr_DelayIn(Pr_Time(10,0));
return (*pTaskSendAndReceiveOk);
}
Pr_Task *pTaskAReceiverSender;
Pr_Task *pTaskCSenderReceiver;
Pr_Task *pTaskBReceiverSender;
Pr_Task *pTaskDSenderReceiver;
bool_t testReceiveAndSendOk = false;
uint8_t orderControlReceiveSend=0;
static Pr_TaskRV_t TASK_A_RECEIVE_AND_SEND(Pr_TaskP_t)
{
uint8_t dataToSend = 0xAD;
uint8_t dataToReceive = 0;
Pr_Receive(&dataToReceive, sizeof(uint8_t));
if (0xCA != dataToReceive || orderControlReceiveSend!=0)
{
printf("TASK_A_RECEIVE_AND_SEND data 0x%X order %d\n",dataToReceive,orderControlReceiveSend);
return;
}
else
{
orderControlReceiveSend++;
}
Pr_Send(*pTaskDSenderReceiver,(void*)&dataToSend);
}
static Pr_TaskRV_t TASK_B_RECEIVE_AND_SEND(Pr_TaskP_t)
{
uint8_t dataToSend = 0xBC;
uint8_t dataToReceive = 0;
Pr_Receive(&dataToReceive, sizeof(uint8_t));
if (0xDB != dataToReceive || orderControlReceiveSend!=1)
{
printf("TASK_B_RECEIVE_AND_SEND data 0x%X order %d\n",dataToReceive,orderControlReceiveSend);
return;
}
else
{
orderControlReceiveSend++;
}
Pr_Send(*pTaskCSenderReceiver,(void*)&dataToSend);
}
static Pr_TaskRV_t TASK_C_SEND_AND_RECEIVE(Pr_TaskP_t)
{
uint8_t dataToSend = 0xCA;
uint8_t dataToReceive = 0;
Pr_Send(*pTaskAReceiverSender,(void*)&dataToSend);
Pr_Receive(&dataToReceive, sizeof(uint8_t));
if (0xBC != dataToReceive || orderControlReceiveSend!=2)
{
printf("TASK_C_SEND_AND_RECEIVE data 0x%X order %d\n",dataToReceive,orderControlReceiveSend);
return;
}
else
{
orderControlReceiveSend++;
}
}
static Pr_TaskRV_t TASK_D_SEND_AND_RECEIVE(Pr_TaskP_t)
{
uint8_t dataToSend = 0xDB;
uint8_t dataToReceive = 0;
Pr_Send(*pTaskBReceiverSender,(void*)&dataToSend);
Pr_Receive(&dataToReceive, sizeof(uint8_t));
if (0xAD != dataToReceive || orderControlReceiveSend!=3)
{
printf("TASK_D_SEND_AND_RECEIVE data 0x%X order %d\n",dataToReceive,orderControlReceiveSend);
return;
}
else
{
testReceiveAndSendOk=true;
}
}
CUT_EDROOMBP_PR_TASK_RECEIVE_AND_SEND::CUT_EDROOMBP_PR_TASK_RECEIVE_AND_SEND(const char * id) :
CUTBase(id, true, true, 9873829),
kernel(),
taskAReceiverSender(TASK_A_RECEIVE_AND_SEND, EDROOMprioVeryHigh, 2048),
taskBReceiverSender(TASK_B_RECEIVE_AND_SEND, EDROOMprioHigh, 2048),
taskCSenderReceiver(TASK_C_SEND_AND_RECEIVE, EDROOMprioNormal, 2048),
taskDSenderReceiver(TASK_D_SEND_AND_RECEIVE, EDROOMprioLow, 2048),
pTaskSendAndReceiveOk(&testReceiveAndSendOk)
{
pTaskAReceiverSender = &taskAReceiverSender;
pTaskCSenderReceiver = &taskCSenderReceiver;
pTaskBReceiverSender = &taskBReceiverSender;
pTaskDSenderReceiver = &taskDSenderReceiver;
testReceiveAndSendOk = false;
}
bool_t CUT_EDROOMBP_PR_TASK_RECEIVE_AND_SEND::DoTest(void)
{
Pr_DelayIn(Pr_Time(10,0));
return (*pTaskSendAndReceiveOk);
}
/*----------------------------------------------------------------------------*/
/*------------------------------- val_02_03_101 ------------------------------*/
/*----------------------------------------------------------------------------*/
Pr_Task * pTaskQueuePrioFifoA;
Pr_Task * pTaskQueuePrioFifoB;
Pr_Task * pTaskQueuePrioFifoC;
Pr_Task * pTaskQueuePrioFifoD;
bool_t taskQueuePrioFifoBOk=false;
bool_t taskQueuePrioFifoCOk=false;
bool_t taskQueuePrioFifoDOk=false;
Pr_SemaphoreBin * pSemQueuePrioFifo;
uint32_t orderControlFifo = 0;
static Pr_TaskRV_t TASK_A_PRIORITY_FIFO(Pr_TaskP_t)
{
/*obtain a semaphore*/
pSemQueuePrioFifo->Wait();
Pr_DelayIn(Pr_Time(1,0));
if (0 != orderControlFifo)
{
DEBUG("0!=orderControl");
return;
}
orderControlFifo++;
pTaskQueuePrioFifoD->SetPriority(EDROOMprioVeryHigh); //2
pTaskQueuePrioFifoC->SetPriority(EDROOMprioNormal); //4
pTaskQueuePrioFifoB->SetPriority(EDROOMprioVeryLow); //6
pSemQueuePrioFifo->Signal();
}
static Pr_TaskRV_t TASK_B_PRIORITY_FIFO(Pr_TaskP_t)
{
/*obtain a semaphore*/
pSemQueuePrioFifo->Wait();
if (1 != orderControlFifo)
{
DEBUG("1!=orderControl %d",orderControlFifo );
return;
}
orderControlFifo++;
pSemQueuePrioFifo->Signal();
taskQueuePrioFifoBOk = true;
}
static Pr_TaskRV_t TASK_C_PRIORITY_FIFO(Pr_TaskP_t)
{
pSemQueuePrioFifo->Wait();
if (2 != orderControlFifo)
{
DEBUG("2!=orderControl");
return;
}
orderControlFifo++;
pSemQueuePrioFifo->Signal();
taskQueuePrioFifoCOk = true;
}
static Pr_TaskRV_t TASK_D_PRIORITY_FIFO(Pr_TaskP_t)
{
pSemQueuePrioFifo->Wait();
if (3 != orderControlFifo)
{
DEBUG("3!=orderControl");
return;
}
orderControlFifo++;
pSemQueuePrioFifo->Signal();
taskQueuePrioFifoDOk = true;
}
CUT_EDROOMBP_PR_TASK_CHANGE_TASK_PRIORITY_QUEUED_FIFO::CUT_EDROOMBP_PR_TASK_CHANGE_TASK_PRIORITY_QUEUED_FIFO(const char * id) :
CUTBase(id, true, true, 9873829),
kernel(),
taskA(TASK_A_PRIORITY_FIFO, EDROOMprioURGENT, 2048), //1
taskB(TASK_B_PRIORITY_FIFO, EDROOMprioHigh, 2048), //3
taskC(TASK_C_PRIORITY_FIFO, EDROOMprioLow, 2048), //5
taskD(TASK_D_PRIORITY_FIFO, EDROOMprioIDLE, 2048), //7
pTaskBOk(&taskQueuePrioFifoBOk),
pTaskCOk(&taskQueuePrioFifoCOk),
pTaskDOk(&taskQueuePrioFifoDOk),
semQueuePrio(1)
{
taskQueuePrioFifoBOk = false;
taskQueuePrioFifoCOk = false;
taskQueuePrioFifoDOk = false;
orderControlFifo = 0;
pSemQueuePrioFifo = &semQueuePrio;
pTaskQueuePrioFifoA = &taskA;
pTaskQueuePrioFifoB = &taskB;
pTaskQueuePrioFifoC = &taskC;
pTaskQueuePrioFifoD = &taskD;
}
bool_t CUT_EDROOMBP_PR_TASK_CHANGE_TASK_PRIORITY_QUEUED_FIFO::DoTest(void)
{
Pr_DelayIn(Pr_Time(10,0));
return ((*pTaskBOk) && (*pTaskCOk) && (*pTaskDOk));
}
/*----------------------------------------------------------------------------*/
/*------------------------------- val_02_03_103 ------------------------------*/
/*----------------------------------------------------------------------------*/
Pr_Task * pTaskQueuePrioCeilingA;
Pr_Task * pTaskQueuePrioCeilingB;
Pr_Task * pTaskQueuePrioCeilingC;
Pr_Task * pTaskQueuePrioCeilingD;
bool_t taskQueuePrioCeilingBOk=false;
bool_t taskQueuePrioCeilingCOk=false;
bool_t taskQueuePrioCeilingDOk=false;
Pr_SemaphoreRec * pSemQueuePrioCeiling;
uint32_t orderControlCeiling = 0;
static Pr_TaskRV_t TASK_A_PRIORITY_CEILING(Pr_TaskP_t)
{
/*obtain a semaphore*/
pSemQueuePrioCeiling->Wait();
printf("LA tarea A obtiene el semáforo\n");
printf("Prioridad A %i\n",pTaskQueuePrioCeilingA->GetTaskPrio());
Pr_DelayIn(Pr_Time(1,0));
if (0 != orderControlCeiling)
{
DEBUG("0!=orderControl");
return;
}
orderControlCeiling++;
pTaskQueuePrioCeilingD->SetPriority(EDROOMprioVeryHigh); //2
printf("nueva prioridad D: %i \n", pTaskQueuePrioCeilingD->GetTaskPrio());
pTaskQueuePrioCeilingC->SetPriority(EDROOMprioNormal); //4
printf("nueva prioridad C: %i \n", pTaskQueuePrioCeilingC->GetTaskPrio());
pTaskQueuePrioCeilingB->SetPriority(EDROOMprioVeryLow); //6
printf("nueva prioridad B: %i \n", pTaskQueuePrioCeilingB->GetTaskPrio());
pSemQueuePrioCeiling->Signal();
printf("LA tarea A suelta el semáforo\n");
}
static Pr_TaskRV_t TASK_B_PRIORITY_CEILING(Pr_TaskP_t)
{
/*obtain a semaphore*/
pSemQueuePrioCeiling->Wait();
printf("LA tarea B obtiene el semáforo\n");
printf("Prioridad B %i\n",pTaskQueuePrioCeilingB->GetTaskPrio());
if (3 != orderControlCeiling)
{
DEBUG("3!=orderControl %d",orderControlCeiling );
return;
}
orderControlCeiling++;
printf("AQUI\n");
pSemQueuePrioCeiling->Signal();
taskQueuePrioCeilingBOk = true;
printf("LA tarea B suelta el semáforo\n");
}
static Pr_TaskRV_t TASK_C_PRIORITY_CEILING(Pr_TaskP_t)
{
pSemQueuePrioCeiling->Wait();
printf("LA tarea C obtiene el semáforo\n");
printf("Prioridad C %i\n",pTaskQueuePrioCeilingC->GetTaskPrio());
if (2 != orderControlCeiling)
{
DEBUG("2!=orderControl");
return;
}
orderControlCeiling++;
pSemQueuePrioCeiling->Signal();
taskQueuePrioCeilingCOk = true;
printf("LA tarea C suelta el semáforo\n");
}
static Pr_TaskRV_t TASK_D_PRIORITY_CEILING(Pr_TaskP_t)
{
pSemQueuePrioCeiling->Wait();
printf("LA tarea D obtiene el semáforo\n");
printf("Prioridad D %i\n",pTaskQueuePrioCeilingD->GetTaskPrio());
if (1 != orderControlCeiling)
{
DEBUG("1!=orderControl");
return;
}
orderControlCeiling++;
pSemQueuePrioCeiling->Signal();
taskQueuePrioCeilingDOk = true;
printf("LA tarea D suelta el semáforo\n");
}
CUT_EDROOMBP_PR_TASK_CHANGE_TASK_PRIORITY_QUEUED_CEILING::CUT_EDROOMBP_PR_TASK_CHANGE_TASK_PRIORITY_QUEUED_CEILING(const char * id) :
CUTBase(id, true, true, 9873829),
kernel(),
taskA(TASK_A_PRIORITY_CEILING, EDROOMprioURGENT, 2048), //1
taskB(TASK_B_PRIORITY_CEILING, EDROOMprioHigh, 2048), //3
taskC(TASK_C_PRIORITY_CEILING, EDROOMprioLow, 2048), //5
taskD(TASK_D_PRIORITY_CEILING, EDROOMprioIDLE, 2048), //7
pTaskBOk(&taskQueuePrioCeilingBOk),
pTaskCOk(&taskQueuePrioCeilingCOk),
pTaskDOk(&taskQueuePrioCeilingDOk),
semQueuePrio(1)
{
taskQueuePrioCeilingBOk = false;
taskQueuePrioCeilingCOk = false;
taskQueuePrioCeilingDOk = false;
orderControlCeiling = 0;
pSemQueuePrioCeiling = &semQueuePrio;
pTaskQueuePrioCeilingA = &taskA;
pTaskQueuePrioCeilingB = &taskB;
pTaskQueuePrioCeilingC = &taskC;
pTaskQueuePrioCeilingD = &taskD;
}
bool_t CUT_EDROOMBP_PR_TASK_CHANGE_TASK_PRIORITY_QUEUED_CEILING::DoTest(void)
{
Pr_DelayIn(Pr_Time(10,0));
return ((*pTaskBOk) && (*pTaskCOk) && (*pTaskDOk));
}
Pr_Task * pTaskQueuePrioInheritA;
Pr_Task * pTaskQueuePrioInheritB;
Pr_Task * pTaskQueuePrioInheritC;
Pr_Task * pTaskQueuePrioInheritD;
bool_t taskQueuePrioInheritBOk=false;
bool_t taskQueuePrioInheritCOk=false;
bool_t taskQueuePrioInheritDOk=false;
Pr_SemaphoreRec * pSemQueuePrioInherit;
uint32_t orderControlInherit = 0;
static Pr_TaskRV_t TASK_A_PRIORITY_INHERIT(Pr_TaskP_t)
{
/*obtain a semaphore*/
pSemQueuePrioInherit->Wait();
if (0 != orderControlInherit)
{
printf("0!=orderControl\n");
return;
}
orderControlInherit++;
pTaskQueuePrioInheritD->SetPriority(EDROOMprioVeryHigh); //2
pTaskQueuePrioInheritC->SetPriority(EDROOMprioNormal); //4
pTaskQueuePrioInheritB->SetPriority(EDROOMprioVeryLow); //6
// printf("contador A antes signal %i\n", pSemQueuePrioInherit->countSem());
pSemQueuePrioInherit->Signal();
// printf("contador A despues signal %i\n", pSemQueuePrioInherit->countSem());
}
static Pr_TaskRV_t TASK_B_PRIORITY_INHERIT(Pr_TaskP_t)
{
/*obtain a semaphore*/
pSemQueuePrioInherit->Wait();
if (3 != orderControlInherit)
{
printf("3!=orderControl %d\n",orderControlInherit );
return;
}
orderControlInherit++;
pSemQueuePrioInherit->Signal();
taskQueuePrioInheritBOk = true;
}
static Pr_TaskRV_t TASK_C_PRIORITY_INHERIT(Pr_TaskP_t)
{
pSemQueuePrioInherit->Wait();
if (2 != orderControlInherit)
{
printf("2!=orderControl\n");
return;
}
orderControlInherit++;
pSemQueuePrioInherit->Signal();
taskQueuePrioInheritCOk = true;
}
static Pr_TaskRV_t TASK_D_PRIORITY_INHERIT(Pr_TaskP_t)
{
pSemQueuePrioInherit->Wait();
if (1 != orderControlInherit)
{
printf("1!=orderControl\n");
return;
}
orderControlInherit++;
pSemQueuePrioInherit->Signal();
taskQueuePrioInheritDOk = true;
}
CUT_EDROOMBP_PR_TASK_CHANGE_TASK_PRIORITY_QUEUED_INHERIT::CUT_EDROOMBP_PR_TASK_CHANGE_TASK_PRIORITY_QUEUED_INHERIT(const char * id) :
CUTBase(id, true, true, 9873829),
kernel(),
taskA(TASK_A_PRIORITY_INHERIT, EDROOMprioURGENT, 2048), //1
taskB(TASK_B_PRIORITY_INHERIT, EDROOMprioHigh, 2048), //3
taskC(TASK_C_PRIORITY_INHERIT, EDROOMprioLow, 2048), //5
taskD(TASK_D_PRIORITY_INHERIT, EDROOMprioIDLE, 2048), //7
pTaskBOk(&taskQueuePrioInheritBOk),
pTaskCOk(&taskQueuePrioInheritCOk),
pTaskDOk(&taskQueuePrioInheritDOk),
semQueuePrio()
{
taskQueuePrioInheritBOk = false;
taskQueuePrioInheritCOk = false;
taskQueuePrioInheritDOk = false;
orderControlInherit = 0;
pSemQueuePrioInherit = &semQueuePrio;
pTaskQueuePrioInheritA = &taskA;
pTaskQueuePrioInheritB = &taskB;
pTaskQueuePrioInheritC = &taskC;
pTaskQueuePrioInheritD = &taskD;
}
bool_t CUT_EDROOMBP_PR_TASK_CHANGE_TASK_PRIORITY_QUEUED_INHERIT::DoTest(void)
{
Pr_DelayIn(Pr_Time(10,0));
return ((*pTaskBOk) && (*pTaskCOk) && (*pTaskDOk));
}
/*----------------------------------------------------------------------------*/
/*------------------------------- val_02_03_103 ------------------------------*/
/*----------------------------------------------------------------------------*/
bool_t testCeilingOk=false;
Pr_Task *pTaskSelf;
static Pr_TaskRV_t TASK_PRIORITY_WAIT_CEILING(Pr_TaskP_t)
{
Pr_SemaphoreRec ceiling(3);
ceiling.Wait();
pTaskSelf->SetPriority(EDROOMprioLow);
if (pTaskSelf->GetTmpTaskPrio()!=EDROOMprioHigh)
{
printf("1 pTaskSelf->GetTaskPrio() %d\n",pTaskSelf->GetTaskPrio());
return;
}
ceiling.Signal();
if (pTaskSelf->GetTmpTaskPrio()!=EDROOMprioLow)
{
printf("2 pTaskSelf->GetTaskPrio() %d\n",pTaskSelf->GetTaskPrio());
return;
}
testCeilingOk=true;
}
CUT_EDROOMBP_PR_TASK_TASK_PRIORITY_WAIT_CEILING::CUT_EDROOMBP_PR_TASK_TASK_PRIORITY_WAIT_CEILING(const char * id) :
CUTBase(id, true, true, 9873829),
kernel(),
task(TASK_PRIORITY_WAIT_CEILING, EDROOMprioHigh, 2048), //1 en realidad es un 3
pTestOk(&testCeilingOk)
{
pTaskSelf=&task;
}
bool_t CUT_EDROOMBP_PR_TASK_TASK_PRIORITY_WAIT_CEILING::DoTest(void)
{
Pr_DelayIn(Pr_Time(10,0));
return ((*pTestOk));
}
//
//
///*
// * TODO: Este test no pasa porque una vez encolado no le afecta el cambio
// * de prioridad y coge el semaforo independientemente de la prioridad actual que
// * tenga en el momento de bloquearlo en lugar de irse a la cola correspondiente:
// * ES DEBIDO A LOS ATRIBUTOS POR DEFECTO DE LA CREACIÓN DEL SEMAFORO. Tal y como
// * está definida la edroombp no sería posible este comportamiento
// */
//
//Pr_SemaphoreBin * pSemRequeue;
//
//uint32_t orderControlRequeue = 0;
//
//bool_t testTaskRequeueOk=true;
//
//static Pr_TaskRV_t TASK_A_REQUEUE(Pr_TaskP_t)
//{
// DEBUG("TASK_A_REQUEUE");
// if (testTaskRequeueOk && 0!=orderControlRequeue)
// {
// DEBUG("FALSE TASK_A_REQUEUE 1");
// testTaskRequeueOk=false;
// return;
// }
// orderControlRequeue++;
//
// if (pSemRequeue->WaitTimed(Pr_Time(5,0)))
// {
// DEBUG("TASK_A_REQUEUE LOCKED SEM LOCK");
// }
// else
// {
// DEBUG("TASK_A_REQUEUE LOCKED SEM NO LOCK");
// }
//
// if (testTaskRequeueOk && 10!=orderControlRequeue)
// {
// DEBUG("FALSE TASK_A_REQUEUE 2");
// testTaskRequeueOk=false;
// return;
// }
//
// orderControlRequeue++;
// DEBUG("END TASK_A_REQUEUE");
//}
//
//static Pr_TaskRV_t TASK_B_REQUEUE(Pr_TaskP_t)
//{