CORDET Framework - C2 Implementation
CrFwInRepTestCases.c
Go to the documentation of this file.
1 
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include "CrFwInRepTestCases.h"
22 /* Include FW Profile files */
23 #include "FwSmConstants.h"
24 #include "FwSmConfig.h"
25 #include "FwSmCore.h"
26 #include "FwPrConfig.h"
27 #include "FwPrCore.h"
28 #include "FwPrConstants.h"
29 /* Include framework files */
30 #include "CrFwOutRegistryUserPar.h"
32 #include "BaseCmp/CrFwBaseCmp.h"
33 #include "Pckt/CrFwPckt.h"
34 #include "InRep/CrFwInRep.h"
36 #include "CrFwTime.h"
37 #include "CrFwRepErr.h"
39 /* Include configuration files */
40 #include "CrFwRepErrStub.h"
41 #include "CrFwInFactoryUserPar.h"
42 #include "CrFwCmpData.h"
43 
44 /* ---------------------------------------------------------------------------------------------*/
46  FwSmDesc_t InFactory, inRep1, inRep2;
47  CrFwPckt_t pckt1, pckt2;
48  CrFwInRepData_t* inRepSpecificData;
50  CrFwCrc_t crc;
51 
52  /* Instantiate the InFactory */
53  InFactory = CrFwInFactoryMake();
54 
55  /* Initialize and Configure InFactory and check success */
56  CrFwCmpInit(InFactory);
57  CrFwCmpReset(InFactory);
58  if (!CrFwCmpIsInConfigured(InFactory))
59  return 0;
60 
61  /* Allocate two InReports */
62  pckt1 = CrFwPcktMake(100);
63  CrFwPcktSetServType(pckt1,5);
64  CrFwPcktSetServSubType(pckt1,1);
65  CrFwPcktSetDiscriminant(pckt1,1);
66  CrFwPcktSetCmdRepId(pckt1,111);
67  CrFwPcktSetSrc(pckt1,11);
68  CrFwPcktSetGroup(pckt1,88);
69  CrFwPcktSetAckLevel(pckt1,1,0,1,0);
70  CrFwPcktSetSeqCnt(pckt1,1111);
71  crc = CrFwPcktComputeCrc(pckt1);
72  CrFwPcktSetCrc(pckt1, crc);
73  inRep1 = CrFwInFactoryMakeInRep(pckt1);
74 
75  pckt2 = CrFwPcktMake(100);
76  CrFwPcktSetServType(pckt2,5);
77  CrFwPcktSetServSubType(pckt2,1);
78  CrFwPcktSetDiscriminant(pckt2,2);
79  CrFwPcktSetCmdRepId(pckt2,222);
80  CrFwPcktSetSrc(pckt2,22);
81  CrFwPcktSetGroup(pckt2,89);
82  CrFwPcktSetAckLevel(pckt2,0,1,0,1);
83  CrFwPcktSetSeqCnt(pckt2,2222);
84  crc = CrFwPcktComputeCrc(pckt1);
85  CrFwPcktSetCrc(pckt1, crc-1);
86  inRep2 = CrFwInFactoryMakeInRep(pckt2);
87 
88  /* Check the instance identifiers and the type identifier */
89  if (CrFwCmpGetInstanceId(inRep1) != 111)
90  return 0;
91  if (CrFwCmpGetInstanceId(inRep2) != 222)
92  return 0;
94  return 0;
96  return 0;
97 
98  /* Check correct configuration */
99  if (FwSmCheck(inRep1) != 1)
100  return 0;
101  if (FwSmCheck(inRep2) != 1)
102  return 0;
103 
104  /* Check InReport state */
105  if (!CrFwCmpIsInConfigured(inRep1))
106  return 0;
107  if (CrFwCmpIsInConfigured(inRep2))
108  return 0;
109 
110  /* Check the parameter area */
111  inRepData = (CrFwCmpData_t*)FwSmGetData(inRep1);
112  inRepSpecificData = (CrFwInRepData_t*)inRepData->cmpSpecificData;
113  if (CrFwInRepGetParLength(inRep1) != CrFwPcktGetParLength(inRepSpecificData->pckt))
114  return 0;
115  if (CrFwInRepGetParStart(inRep1) != CrFwPcktGetParStart(inRepSpecificData->pckt))
116  return 0;
117 
118  /* Check type, sub-type and discriminant */
119  if (CrFwInRepGetServType(inRep1) != 5)
120  return 0;
121  if (CrFwInRepGetServType(inRep2) != 5)
122  return 0;
123 
124  if (CrFwInRepGetServSubType(inRep1) != 1)
125  return 0;
126  if (CrFwInRepGetServSubType(inRep2) != 1)
127  return 0;
128 
129  if (CrFwInRepGetDiscriminant(inRep1) != 1)
130  return 0;
131  if (CrFwInRepGetDiscriminant(inRep2) != 2)
132  return 0;
133 
134  /* Check source and sequence counter*/
135  if (CrFwInRepGetSrc(inRep1) != 11)
136  return 0;
137  if (CrFwInRepGetSrc(inRep2) != 22)
138  return 0;
139  if (CrFwInRepGetSeqCnt(inRep1) != 1111)
140  return 0;
141  if (CrFwInRepGetSeqCnt(inRep2) != 2222)
142  return 0;
143  if (CrFwInRepGetGroup(inRep1) != 88)
144  return 0;
145  if (CrFwInRepGetGroup(inRep2) != 89)
146  return 0;
147 
148  /* Retrieve and check the packet holding the InReports */
149  if (CrFwInRepGetPckt(inRep1)!=pckt1)
150  return 0;
151  if (CrFwInRepGetPckt(inRep2)!=pckt2)
152  return 0;
153 
154  /* Release the InReports */
157 
158  /* Check that there are no allocated packets */
159  if (CrFwPcktGetNOfAllocated() != 0)
160  return 0;
161 
162  /* Check application errors */
163  if (CrFwGetAppErrCode() != crNoAppErr)
164  return 0;
165 
166  return 1;
167 }
168 
169 /* ---------------------------------------------------------------------------------------------*/
171  FwSmDesc_t InFactory, inRep;
172  CrFwPckt_t pckt;
173 
174  /* Instantiate the InFactory */
175  InFactory = CrFwInFactoryMake();
176 
177  /* Initialize and Configure InFactory and check success */
178  CrFwCmpInit(InFactory);
179  CrFwCmpReset(InFactory);
180  if (!CrFwCmpIsInConfigured(InFactory))
181  return 0;
182 
183  /* Allocate the Sample1 InReport */
184  pckt = CrFwPcktMake(100);
185  CrFwPcktSetServType(pckt,40);
186  CrFwPcktSetServSubType(pckt,1);
187  CrFwPcktSetDiscriminant(pckt,0);
188  CrFwInRepSample1SetValidityFlag(0); /* Validity Check will fail */
190 
191  /* Check InReport state */
193  return 0;
194 
195  /* Check correct type retrieved by Validity Check */
196  if (CrFwInRepSample1GetType() != 40)
197  return 0;
198 
199  /* Release the InReports */
201 
202  /* Check that there are no allocated packets */
203  if (CrFwPcktGetNOfAllocated() != 0)
204  return 0;
205 
206  /* Check application errors */
207  if (CrFwGetAppErrCode() != crNoAppErr)
208  return 0;
209 
210  return 1;
211 }
212 
213 /* ---------------------------------------------------------------------------------------------*/
215  FwSmDesc_t InFactory, inRep;
216  CrFwPckt_t pckt;
217  CrFwCounterU1_t updCnt;
218 
219  /* Instantiate the InFactory */
220  InFactory = CrFwInFactoryMake();
221 
222  /* Initialize and Configure InFactory and check success */
223  CrFwCmpInit(InFactory);
224  CrFwCmpReset(InFactory);
225  if (!CrFwCmpIsInConfigured(InFactory))
226  return 0;
227 
228  /* Allocate the Sample1 InReport */
229  pckt = CrFwPcktMake(100);
230  CrFwPcktSetServType(pckt,40);
231  CrFwPcktSetServSubType(pckt,1);
232  CrFwPcktSetDiscriminant(pckt,0);
233  CrFwInRepSample1SetValidityFlag(1); /* Validity Check will succeed */
236 
237  /* Check InReport state */
239  return 0;
240 
241  /* Execute InReport and check that Update Action is executed */
243  if (CrFwInRepSample1GetUpdateActionCounter() != updCnt+1)
244  return 0;
245 
246  /* Execute InReport again and check that Update Action is not executed */
248  if (CrFwInRepSample1GetUpdateActionCounter() != updCnt+1)
249  return 0;
250 
251  /* Release the InReports */
253 
254  /* Check that there are no allocated packets */
255  if (CrFwPcktGetNOfAllocated() != 0)
256  return 0;
257 
258  /* Check application errors */
259  if (CrFwGetAppErrCode() != crNoAppErr)
260  return 0;
261 
262  return 1;
263 }
264 
CrFwInstanceId_t CrFwCmpGetInstanceId(FwSmDesc_t smDesc)
Return the instance identifier of the argument component.
Definition: CrFwBaseCmp.c:150
void CrFwCmpInit(FwSmDesc_t smDesc)
Initialize a framework component.
Definition: CrFwBaseCmp.c:112
CrFwBool_t CrFwCmpIsInInitialized(FwSmDesc_t smDesc)
Return true if the argument component is in state INITIALIZED.
Definition: CrFwBaseCmp.c:172
CrFwBool_t CrFwCmpIsInConfigured(FwSmDesc_t smDesc)
Return true if the argument component is in state CONFIGURED.
Definition: CrFwBaseCmp.c:177
void CrFwCmpReset(FwSmDesc_t smDesc)
Reset a framework component.
Definition: CrFwBaseCmp.c:117
void CrFwCmpExecute(FwSmDesc_t smDesc)
Execute a framework component.
Definition: CrFwBaseCmp.c:127
CrFwTypeId_t CrFwCmpGetTypeId(FwSmDesc_t smDesc)
Return the type identifier of the argument component.
Definition: CrFwBaseCmp.c:156
Definition of Base Component.
Definition of the Framework Component Data (FCD) Type.
#define CR_FW_INREPORT_TYPE
Type identifier for the InReport component.
unsigned char * CrFwPckt_t
Type for packets (see CrFwPckt.h).
Definition: CrFwConstants.h:38
int CrFwBool_t
Type used for boolean values (1 represent "true" and 0 represents "false").
Definition: CrFwConstants.h:32
static CrFwCmpData_t inRepData[CR_FW_INFACTORY_MAX_NOF_INREP]
The base data for the pre-allocated InReport instances.
Definition: CrFwInFactory.c:70
static FwSmDesc_t inRep[CR_FW_INFACTORY_MAX_NOF_INREP]
The pre-allocated InReport instances.
Definition: CrFwInFactory.c:61
void CrFwInFactoryReleaseInRep(FwSmDesc_t inRepInstance)
Release function for an InReport.
FwSmDesc_t CrFwInFactoryMakeInRep(CrFwPckt_t pckt)
Make function for a component encapsulating an incoming report (InReport).
FwSmDesc_t CrFwInFactoryMake()
Factory function for the singleton instance of the InFactory.
Definition of the InFactory component.
User-modifiable parameters for the InFactory component (see CrFwInFactory.h).
CrFwPckt_t CrFwInRepGetPckt(FwSmDesc_t smDesc)
Return the pointer to the packet which holds the InReport.
Definition: CrFwInRep.c:114
CrFwServType_t CrFwInRepGetServSubType(FwSmDesc_t smDesc)
Return the sub-type of the InReport.
Definition: CrFwInRep.c:65
CrFwSeqCnt_t CrFwInRepGetSeqCnt(FwSmDesc_t smDesc)
Return the sequence counter of the InReport.
Definition: CrFwInRep.c:81
CrFwServType_t CrFwInRepGetServType(FwSmDesc_t smDesc)
Return the type of the InReport.
Definition: CrFwInRep.c:57
CrFwGroup_t CrFwInRepGetGroup(FwSmDesc_t smDesc)
Return the group of the InReport.
Definition: CrFwInRep.c:49
CrFwDestSrc_t CrFwInRepGetSrc(FwSmDesc_t smDesc)
Return the source of the InReport.
Definition: CrFwInRep.c:41
CrFwPcktLength_t CrFwInRepGetParLength(FwSmDesc_t smDesc)
Return the length in bytes of the parameter area of the InReport.
Definition: CrFwInRep.c:96
CrFwDiscriminant_t CrFwInRepGetDiscriminant(FwSmDesc_t smDesc)
Return the discriminant of the InReport.
Definition: CrFwInRep.c:73
CrFwPckt_t CrFwInRepGetParStart(FwSmDesc_t smDesc)
Return the start address of the parameter area of the InReport.
Definition: CrFwInRep.c:89
Definition of the InReport Component of the framework.
void CrFwInRepSample1SetValidityFlag(CrFwBool_t flag)
Set the value of the Validity Flag (see CrFwInRepSample1ValidityCheck).
CrFwCounterU1_t CrFwInRepSample1GetUpdateActionCounter()
Get the value of the Update Action Counter (see CrFwInRepSample1UpdateAction).
CrFwServType_t CrFwInRepSample1GetType()
Get the value of the InReport's type as it is computed by the Validity Check (see CrFwInRepSample1Val...
CrFwBool_t CrFwInRepTestCase3()
Check the update action of an InReport.
CrFwBool_t CrFwInRepTestCase2()
Check the failure of the Validity Check of an InReport.
CrFwBool_t CrFwInRepTestCase1()
Check the configuration of a newly created InReport.
Declaration of the test cases for the InReport Component (see CrFwInRep.h).
Definition of the OutRegistry Component.
User-modifiable parameters for the OutRegistry component (see CrFwOutRegistry.h).
Interface for creating and accessing a report or command packet.
void CrFwPcktSetServSubType(CrFwPckt_t pckt, CrFwServSubType_t servSubType)
Set the service sub-type of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:327
CrFwPckt_t CrFwPcktGetParStart(CrFwPckt_t pckt)
Return the start address of the packet's parameter area.
Definition: CrFwPckt.c:412
void CrFwPcktSetCmdRepId(CrFwPckt_t pckt, CrFwInstanceId_t id)
Set the command or report identifier in the command or report encapsulated in a packet.
Definition: CrFwPckt.c:363
void CrFwPcktSetSeqCnt(CrFwPckt_t pckt, CrFwSeqCnt_t seqCnt)
Set the sequence counter of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:247
CrFwCrc_t CrFwPcktComputeCrc(CrFwPckt_t pckt)
Compute the CRC in the command or report encapsulated in a packet.
Definition: CrFwPckt.c:277
void CrFwPcktSetDiscriminant(CrFwPckt_t pckt, CrFwDiscriminant_t discriminant)
Set the discriminant of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:309
CrFwPcktLength_t CrFwPcktGetParLength(CrFwPckt_t pckt)
Return the length in bytes of the packet's parameter area.
Definition: CrFwPckt.c:417
void CrFwPcktSetServType(CrFwPckt_t pckt, CrFwServType_t servType)
Set the service type of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:315
CrFwCounterU2_t CrFwPcktGetNOfAllocated()
Return the number of packets which are currently allocated.
Definition: CrFwPckt.c:214
void CrFwPcktSetAckLevel(CrFwPckt_t pckt, CrFwBool_t accept, CrFwBool_t start, CrFwBool_t progress, CrFwBool_t term)
Set the acknowledge level for the command encapsulated in a packet.
Definition: CrFwPckt.c:375
void CrFwPcktSetCrc(CrFwPckt_t pckt, CrFwCrc_t crc)
Set the CRC in the command or report encapsulated in a packet.
Definition: CrFwPckt.c:283
void CrFwPcktSetSrc(CrFwPckt_t pckt, CrFwDestSrc_t src)
Set the source of the command or report encapsulated in a packet.
Definition: CrFwPckt.c:351
void CrFwPcktSetGroup(CrFwPckt_t pckt, CrFwGroup_t group)
Set the group of the command/report encapsulated in a packet.
Definition: CrFwPckt.c:422
CrFwPckt_t CrFwPcktMake(CrFwPcktLength_t pcktLength)
Make function for command or report packets.
Definition: CrFwPckt.c:147
Interface for reporting an error detected by a framework component.
The CORDET Framework defines an interface for generating error reports (see CrFwRepErr....
Interface through which framework components access the current time.
unsigned char CrFwCounterU1_t
Type used for unsigned integers with a "short" range.
unsigned short CrFwCrc_t
Type used for the CRC field in a packet.
@ crNoAppErr
No application errors have been detected.
CrFwAppErrCode_t CrFwGetAppErrCode()
Return the value of the application error code.
Definition of the utility functions for the CORDET Framework.
Type for the Framework Component Data (FCD).
Definition: CrFwCmpData.h:79
void * cmpSpecificData
Derived data which are specific to each type of framework component.
Definition: CrFwCmpData.h:101
Type for the data describing an InReport.
CrFwPckt_t pckt
Packet holding the InReport.
P&P Software GmbH, Copyright 2012-2013, All Rights Reserved