RKH
test_rkhtrc_filter.c
Go to the documentation of this file.
1 /*
2  * --------------------------------------------------------------------------
3  *
4  * Framework RKH
5  * -------------
6  *
7  * State-machine framework for reactive embedded systems
8  *
9  * Copyright (C) 2010 Leandro Francucci.
10  * All rights reserved. Protected by international copyright laws.
11  *
12  *
13  * RKH is free software: you can redistribute it and/or modify it under the
14  * terms of the GNU General Public License as published by the Free Software
15  * Foundation, either version 3 of the License, or (at your option) any
16  * later version.
17  *
18  * RKH is distributed in the hope that it will be useful, but WITHOUT ANY
19  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21  * more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with RKH, see copying.txt file.
25  *
26  * Contact information:
27  * RKH site: http://vortexmakes.com/que-es/
28  * RKH GitHub: https://github.com/vortexmakes/RKH
29  * RKH Sourceforge: https://sourceforge.net/projects/rkh-reactivesys/
30  * e-mail: lf@vortexmakes.com
31  * ---------------------------------------------------------------------------
32  */
33 
46 /* -------------------------- Development history -------------------------- */
47 /*
48  * 2017.20.04 LeFr v2.4.05 ---
49  */
50 
51 /* -------------------------------- Authors -------------------------------- */
52 /*
53  * LeFr Leandro Francucci lf@vortexmakes.com
54  */
55 
56 /* --------------------------------- Notes --------------------------------- */
57 /* ----------------------------- Include files ----------------------------- */
58 #include "unity.h"
59 #include "rkhtrc_filter.h"
60 #include "Mock_rkhassert.h"
61 #include "Mock_rkhfwk_bittbl.h"
62 #include <string.h>
63 
64 /* ----------------------------- Local macros ------------------------------ */
65 /* ------------------------------- Constants ------------------------------- */
66 #define SIZEOF_BIT_TBL RKH_TRC_MAX_EVENTS_IN_BYTES
67 #define MAX_NUM_BITS (SIZEOF_BIT_TBL * 8)
68 #define FILTER_ON_BYTE 0
69 #define FILTER_OFF_BYTE 0xff
70 
71 /* ---------------------------- Local data types --------------------------- */
72 /* ---------------------------- Global variables --------------------------- */
73 /* ---------------------------- Local variables ---------------------------- */
74 static RKH_FilterTbl filStatus;
75 static rui8_t bitTbl[SIZEOF_BIT_TBL];
76 static const rui8_t maptbl[] =
77 {
78  0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
79 };
80 
81 /* ----------------------- Local function prototypes ----------------------- */
82 static void setUp_toolForTest(void);
83 static void tearDown_toolForTest(void);
84 static void setUp_filter(void);
85 static void tearDown_filter(void);
86 
87 /* ---------------------------- Local functions ---------------------------- */
88 static void
89 MockAssertCallback(const char* const file, int line, int cmock_num_calls)
90 {
91  TEST_PASS();
92 }
93 
94 static void
95 setBitTbl(rui8_t *bt, rui16_t bit, rui8_t value)
96 {
97  rui8_t bitPos;
98  rui16_t ix;
99 
100  TEST_ASSERT_TRUE( (bt != (rui8_t *)0) ||
101  (bit < MAX_NUM_BITS) ||
102  (value <= 1));
103 
104  bitPos = (rui8_t)(bit & 7);
105  ix = (rui16_t)(bit >> 3);
106 
107  if (value == 1)
108  {
109  *(bt + ix) |= maptbl[bitPos];
110  }
111  else
112  {
113  *(bt + ix) &= ~maptbl[bitPos];
114  }
115 }
116 
117 static ruint
118 getBitTbl(rui8_t *bt, rui16_t bit)
119 {
120  rui8_t bitPos;
121  rui16_t ix;
122  rui8_t bitVal;
123 
124  TEST_ASSERT_TRUE( (bt != (rui8_t *)0) ||
125  (bit < MAX_NUM_BITS));
126 
127  bitPos = (rui8_t)(bit & 0x07);
128  ix = (rui16_t)(bit >> 3);
129 
130  bitVal = (*(bt + ix) & maptbl[bitPos]) != 0;
131  return bitVal;
132 }
133 
134 static void
135 setAllBitTbl(rui8_t *bt, ruint value, ruint size)
136 {
137  TEST_ASSERT_TRUE(bt != (rui8_t *)0);
138  memset(bitTbl, value, size);
139 }
140 
141 static rbool_t
142 checkBitTblAreOn(rui8_t *bt, rui16_t size)
143 {
144  rui16_t i;
145  rui8_t *p;
146  rbool_t res;
147 
148  for (i = 0, p = bt, res = RKH_OK; i < size; ++i, ++p)
149  {
150  if (*p != FILTER_ON_BYTE)
151  {
152  res = RKH_FAIL;
153  break;
154  }
155  }
156  return res;
157 }
158 
159 static void
160 setBlockBit(rui8_t *bt, ruint value, ruint to)
161 {
162  ruint bitPos;
163 
164  for (bitPos = 0; bitPos < to; ++bitPos)
165  {
166  setBitTbl(bt, bitPos, value);
167  }
168 }
169 
170 /* It could be added to rkhtrc module */
171 static void
172 rkh_trc_filterAllOn(rui8_t *ft, RKH_TE_ID_T ftSize)
173 {
174  RKH_TE_ID_T cnt;
175  rui8_t *p;
176 
177  for (cnt = 0, p = ft; cnt < ftSize; ++cnt, ++p)
178  {
179  *p = FILTER_ON_BYTE;
180  }
181 }
182 
183 /* It could be added to rkhtrc module */
184 void
185 rkh_trc_filter_init(void)
186 {
187  rkh_trc_filterAllOn(filStatus.signal->tbl,
188  (RKH_TE_ID_T)(filStatus.signal->size));
189  rkh_trc_filterAllOn(filStatus.ao->tbl,
190  (RKH_TE_ID_T)(filStatus.ao->size));
191  rkh_trc_filterAllOn(filStatus.event,
193  rkh_trc_filterAllOn(filStatus.group,
194  (RKH_TE_ID_T)(sizeof(RKH_TG_T)));
195 }
196 
197 /* ---------------------------- Global functions --------------------------- */
198 void
199 setUp(void)
200 {
201  setUp_toolForTest();
202  setUp_filter();
203 }
204 
205 void
206 tearDown(void)
207 {
208  tearDown_toolForTest();
209  tearDown_filter();
210 }
211 
212 /* =========================== Filter test group =========================== */
213 static void
214 setUp_toolForTest(void)
215 {
216 }
217 
218 static void
219 tearDown_toolForTest(void)
220 {
221 }
222 
229 void
230 test_getBitIndex0(void)
231 {
232  setAllBitTbl(bitTbl, 0, SIZEOF_BIT_TBL);
233  bitTbl[0] = 0x82;
234 
235  TEST_ASSERT_EQUAL(0, getBitTbl(bitTbl, 0));
236  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 1));
237  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 7));
238 }
239 
240 void
241 test_getBitIndexX(void)
242 {
243  setAllBitTbl(bitTbl, 0, SIZEOF_BIT_TBL);
244  bitTbl[0] = 0x80;
245  bitTbl[1] = 0x03;
246  bitTbl[2] = 0xc0;
247 
248  TEST_ASSERT_EQUAL(0, getBitTbl(bitTbl, 0));
249  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 7));
250  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 8));
251  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 9));
252  TEST_ASSERT_EQUAL(0, getBitTbl(bitTbl, 10));
253  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 22));
254  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 23));
255 }
256 
257 void
258 test_setBitIndex0(void)
259 {
260  setAllBitTbl(bitTbl, 0, SIZEOF_BIT_TBL);
261 
262  setBitTbl(bitTbl, 0, 1);
263  TEST_ASSERT_EQUAL_HEX8(0x01, bitTbl[0]);
264  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 0));
265 
266  setBitTbl(bitTbl, 7, 1);
267  TEST_ASSERT_EQUAL_HEX8(0x81, bitTbl[0]);
268  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 7));
269 
270  TEST_ASSERT_EQUAL_HEX8(0x00, bitTbl[1]);
271  TEST_ASSERT_EQUAL_HEX8(0x00, bitTbl[2]);
272  TEST_ASSERT_EQUAL_HEX8(0x00, bitTbl[3]);
273 }
274 
275 void
276 test_resetBitIndex0(void)
277 {
278  setAllBitTbl(bitTbl, 0xff, SIZEOF_BIT_TBL);
279 
280  setBitTbl(bitTbl, 0, 0);
281  TEST_ASSERT_EQUAL_HEX8(0xfe, bitTbl[0]);
282  TEST_ASSERT_EQUAL(0, getBitTbl(bitTbl, 0));
283 
284  setBitTbl(bitTbl, 7, 0);
285  TEST_ASSERT_EQUAL_HEX8(0x7e, bitTbl[0]);
286  TEST_ASSERT_EQUAL(0, getBitTbl(bitTbl, 7));
287 
288  TEST_ASSERT_EQUAL_HEX8(0xff, bitTbl[1]);
289  TEST_ASSERT_EQUAL_HEX8(0xff, bitTbl[2]);
290  TEST_ASSERT_EQUAL_HEX8(0xff, bitTbl[3]);
291 }
292 
293 void
294 test_setBitIndexX(void)
295 {
296  setAllBitTbl(bitTbl, 0, SIZEOF_BIT_TBL);
297 
298  setBitTbl(bitTbl, 8, 1);
299  TEST_ASSERT_EQUAL_HEX8(0x01, bitTbl[1]);
300  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 8));
301 
302  setBitTbl(bitTbl, 17, 1);
303  TEST_ASSERT_EQUAL_HEX8(0x02, bitTbl[2]);
304  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 17));
305 
306  TEST_ASSERT_EQUAL_HEX8(0x00, bitTbl[0]);
307  TEST_ASSERT_EQUAL_HEX8(0x00, bitTbl[3]);
308 }
309 
310 void
311 test_resetBitIndexX(void)
312 {
313  setAllBitTbl(bitTbl, 0xff, SIZEOF_BIT_TBL);
314 
315  setBitTbl(bitTbl, 8, 0);
316  TEST_ASSERT_EQUAL_HEX8(0xfe, bitTbl[1]);
317  TEST_ASSERT_EQUAL(0, getBitTbl(bitTbl, 8));
318 
319  setBitTbl(bitTbl, 17, 0);
320  TEST_ASSERT_EQUAL_HEX8(0xfd, bitTbl[2]);
321  TEST_ASSERT_EQUAL(0, getBitTbl(bitTbl, 17));
322 
323  TEST_ASSERT_EQUAL_HEX8(0xff, bitTbl[0]);
324  TEST_ASSERT_EQUAL_HEX8(0xff, bitTbl[3]);
325 }
326 
330 /* ============================ Trace test group =========================== */
331 static void
332 setUp_filter(void)
333 {
334  rkh_trc_filter_get(&filStatus);
335  rkh_trc_filter_init();
336  memset(bitTbl, FILTER_ON_BYTE, RKH_TRC_MAX_EVENTS_IN_BYTES);
337  Mock_rkhfwk_bittbl_Init();
338 }
339 
340 static void
341 tearDown_filter(void)
342 {
343  Mock_rkhfwk_bittbl_Verify();
344  Mock_rkhfwk_bittbl_Destroy();
345 }
346 
353 void
354 test_filEventsAreOnAfterInit(void)
355 {
356  TEST_ASSERT_TRUE(checkBitTblAreOn(filStatus.signal->tbl,
357  filStatus.signal->size) == RKH_OK);
358 
359  TEST_ASSERT_TRUE(checkBitTblAreOn(filStatus.ao->tbl,
360  filStatus.ao->size) == RKH_OK);
361 
362  TEST_ASSERT_TRUE(checkBitTblAreOn(filStatus.event,
364 
365  TEST_ASSERT_TRUE(checkBitTblAreOn(filStatus.group,
366  sizeof(RKH_TG_T)) == RKH_OK);
367 }
368 
369 void
370 test_turnOffOneFilEvent(void)
371 {
372  RKH_GM_OFFSET_T offset;
373 
374  offset = RKH_SM_TTBL_OFFSET;
375  bitTbl[offset] = 0x01;
376  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_SM_INIT) & 7, 1);
377  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_SM_INIT), 8);
378 
380 
381  TEST_ASSERT_EQUAL(1, getBitTbl(&filStatus.event[offset], 0));
382  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.event,
384  TEST_ASSERT_EQUAL_HEX8(0x01,
385  filStatus.event[offset + GETEVT(RKH_TE_SM_INIT)]);
386  TEST_ASSERT_EQUAL_HEX8(0x08, *filStatus.group);
387 }
388 
389 void
390 test_turnOnOneFilEvent(void)
391 {
392  bitTbl[RKH_SM_TTBL_OFFSET + 0] = 0x02;
393 
394  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_SM_INIT) & 7, 1);
395  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_SM_INIT), 8);
397 
398  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_SM_CLRH) & 7, 2);
399  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_SM_CLRH), 8);
401 
402  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_SM_INIT) & 7, 1);
404 
405  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.event,
407  TEST_ASSERT_EQUAL_HEX8(0x08, *filStatus.group);
408 }
409 
410 void
411 test_turnOffMultipleFilEvent(void)
412 {
413  RKH_GM_OFFSET_T offset;
414 
415  offset = RKH_SM_TTBL_OFFSET;
416  bitTbl[offset] = 0x01;
417  bitTbl[offset + 1] = 0x01;
418 
419  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_SM_INIT) & 7, 1);
420  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_SM_INIT), 8);
422 
423  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_SM_TS_STATE) & 7, 1);
424  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_SM_TS_STATE), 8);
426 
427  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.event,
429 }
430 
431 void
432 test_allOffFilEvent(void)
433 {
434  memset(bitTbl, FILTER_OFF_BYTE, RKH_TRC_MAX_EVENTS_IN_BYTES);
435 
437  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.event,
439  TEST_ASSERT_EQUAL_HEX8(0xff, *filStatus.group);
440 }
441 
442 void
443 test_allOnFilEvent(void)
444 {
446  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.event,
448  TEST_ASSERT_EQUAL_HEX8(0x00, *filStatus.group);
449 }
450 
451 void
452 test_isOnOffFilEvent(void)
453 {
454  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_FWK_OBJ), 0x20);
455  TEST_ASSERT_TRUE(rkh_trc_isoff_(RKH_TE_FWK_OBJ) == RKH_FALSE);
456 
457  setBitTbl(filStatus.event, RKH_TE_MP_INIT, FILTER_OFF);
458  setBitTbl(filStatus.group, RKH_TG_MP, FILTER_OFF);
459  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_MP_INIT), 0x01);
460  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_MP_INIT) & 7, 0x01);
461  TEST_ASSERT_TRUE(rkh_trc_isoff_(RKH_TE_MP_INIT) == RKH_TRUE);
462 
463  setBitTbl(filStatus.event, RKH_TE_MP_INIT, FILTER_ON);
464  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_MP_INIT), 0x01);
465  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_MP_INIT) & 7, 0x01);
466  TEST_ASSERT_TRUE(rkh_trc_isoff_(RKH_TE_MP_INIT) == RKH_FALSE);
467 }
468 
469 void
470 test_upperAndLowerBoundsFilEvent(void)
471 {
472  bitTbl[0] = 0x01;
473  bitTbl[RKH_TRC_MAX_EVENTS_IN_BYTES - 2] = 0x80;
474 
475  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_MP_INIT), 0x01);
476  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_MP_INIT) & 7, 0x01);
478 
479  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_UT_IGNORE_ARG), 0x80);
480  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_UT_IGNORE_ARG) & 7,
481  0x80);
482  rkh_trc_filter_event_(FILTER_OFF, RKH_TE_UT_IGNORE_ARG);
483 
484  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.event,
486 }
487 
488 void
489 test_setAllEventsFromOneGroup(void)
490 {
491  RKH_TE_ID_T filter, filterFrom, filterTo, offset;
492  rui8_t evt;
493 
494  filterFrom = RKH_SM_START;
495  filterTo = RKH_SM_END;
496  offset = filStatus.grpFilMap[GETGRP(RKH_SM_START)].offset;
497  setBlockBit(&bitTbl[offset], 1, filterTo - filterFrom);
498 
499  for (filter = filterFrom; filter < filterTo; ++filter)
500  {
501  evt = GETEVT(filter) & 7;
502  rkh_bittbl_getBitMask_ExpectAndReturn(evt, maptbl[evt]);
503  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_SM, 8);
504  rkh_trc_filter_event_(FILTER_OFF, filter);
505  }
506 
507  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.event,
509 }
510 
511 void
512 test_outOfBoundsProducesRuntimeError(void)
513 {
514  rkh_assert_Expect("rkhtrc_filter", 0);
515  rkh_assert_IgnoreArg_file();
516  rkh_assert_IgnoreArg_line();
517  rkh_assert_StubWithCallback(MockAssertCallback);
518 
519  rkh_trc_filter_event_(FILTER_OFF, RKH_TRC_ALL_EVENTS + 1);
520 }
521 
522 void
523 test_turnOffOneGroup(void)
524 {
525  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_MP, maptbl[RKH_TG_MP]);
526  rkh_trc_filter_group_(FILTER_OFF, RKH_TG_MP, EUNCHANGE);
527  TEST_ASSERT_EQUAL_HEX8(0x01, *filStatus.group);
528 }
529 
530 void
531 test_turnOnOneGroup(void)
532 {
533  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_MP, maptbl[RKH_TG_MP]);
534  rkh_trc_filter_group_(FILTER_OFF, RKH_TG_MP, EUNCHANGE);
535 
536  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_MP, maptbl[RKH_TG_MP]);
537  rkh_trc_filter_group_(FILTER_ON, RKH_TG_MP, EUNCHANGE);
538  TEST_ASSERT_EQUAL_HEX8(0x00, *filStatus.group);
539 }
540 
541 void
542 test_allOnOffGroup(void)
543 {
544  rkh_trc_filter_group_(FILTER_OFF, RKH_TRC_ALL_GROUPS, EUNCHANGE);
545  TEST_ASSERT_EQUAL_HEX8(0xff, *filStatus.group);
546  rkh_trc_filter_group_(FILTER_ON, RKH_TRC_ALL_GROUPS, EUNCHANGE);
547  TEST_ASSERT_EQUAL_HEX8(0x00, *filStatus.group);
548 }
549 
550 void
551 test_turnOnOffMultipleGroups(void)
552 {
553  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_MP, maptbl[RKH_TG_MP]);
554  rkh_trc_filter_group_(FILTER_OFF, RKH_TG_MP, EUNCHANGE);
555 
556  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_SM, maptbl[RKH_TG_SM]);
557  rkh_trc_filter_group_(FILTER_OFF, RKH_TG_SM, EUNCHANGE);
558 
559  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_UT, maptbl[RKH_TG_UT]);
560  rkh_trc_filter_group_(FILTER_OFF, RKH_TG_UT, EUNCHANGE);
561 
562  TEST_ASSERT_EQUAL_HEX8(0x89, *filStatus.group);
563 
564  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_MP, maptbl[RKH_TG_MP]);
565  rkh_trc_filter_group_(FILTER_ON, RKH_TG_MP, EUNCHANGE);
566 
567  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_SM, maptbl[RKH_TG_SM]);
568  rkh_trc_filter_group_(FILTER_ON, RKH_TG_SM, EUNCHANGE);
569 
570  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_UT, maptbl[RKH_TG_UT]);
571  rkh_trc_filter_group_(FILTER_ON, RKH_TG_UT, EUNCHANGE);
572 
573  TEST_ASSERT_EQUAL_HEX8(0x00, *filStatus.group);
574 }
575 
576 void
577 test_turnOffOneGroupChangedItsEventFilters(void)
578 {
579  RKHROM RKH_GMTBL_T *pTrcMap;
580 
581  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_UT, maptbl[RKH_TG_UT]);
582  rkh_trc_filter_group_(FILTER_OFF, RKH_TG_UT, ECHANGE);
583  TEST_ASSERT_EQUAL_HEX8(0x80, *filStatus.group);
584 
585  pTrcMap = &filStatus.grpFilMap[RKH_TG_UT];
586  memset(&bitTbl[pTrcMap->offset], FILTER_OFF_BYTE, pTrcMap->range);
587 
588  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.event,
590 }
591 
592 void
593 test_turnOffOneSymFil(void)
594 {
595  bitTbl[0] = 0x01;
596 
597  rkh_bittbl_getBitMask_ExpectAndReturn(0, maptbl[0]);
598  rkh_trc_symFil(RKHFilterSma, 0, FILTER_OFF);
599 
600  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.ao->tbl, RKH_TRC_MAX_SMA);
601 }
602 
603 void
604 test_turnOnOneSymFil(void)
605 {
606  bitTbl[0] = 0x00;
607 
608  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TRC_MAX_SMA - 1,
609  maptbl[RKH_TRC_MAX_SMA - 1]);
610  rkh_trc_symFil(RKHFilterSma, RKH_TRC_MAX_SMA - 1, FILTER_OFF);
611 
612  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TRC_MAX_SMA - 1,
613  maptbl[RKH_TRC_MAX_SMA - 1]);
614  rkh_trc_symFil(RKHFilterSma, RKH_TRC_MAX_SMA - 1, FILTER_ON);
615 
616  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.ao->tbl, RKH_TRC_MAX_SMA);
617 }
618 
619 void
620 test_turnOnOffMultipleSymFil(void)
621 {
622  bitTbl[0] = 0x89;
623 
624  rkh_bittbl_getBitMask_ExpectAndReturn(0, maptbl[0]);
625  rkh_trc_symFil(RKHFilterSma, 0, FILTER_OFF);
626 
627  rkh_bittbl_getBitMask_ExpectAndReturn(3, maptbl[3]);
628  rkh_trc_symFil(RKHFilterSma, 3, FILTER_OFF);
629 
630  rkh_bittbl_getBitMask_ExpectAndReturn(7, maptbl[7]);
631  rkh_trc_symFil(RKHFilterSma, 7, FILTER_OFF);
632 
633  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.ao->tbl, RKH_TRC_MAX_SMA);
634 }
635 
636 void
637 test_allOffOnSymFil(void)
638 {
639  setAllBitTbl(bitTbl, FILTER_OFF_BYTE, RKH_TRC_MAX_SMA);
640  rkh_trc_symFil(RKHFilterSma, 0, RKH_TRC_SET_ALL(FILTER_OFF));
641  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.ao->tbl, RKH_TRC_MAX_SMA);
642 
643  setAllBitTbl(bitTbl, FILTER_ON_BYTE, RKH_TRC_MAX_SMA);
644  rkh_trc_symFil(RKHFilterSma, 0, RKH_TRC_SET_ALL(FILTER_ON));
645  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.ao->tbl, RKH_TRC_MAX_SMA);
646 }
647 
648 void
649 test_isOnOffSymFil(void)
650 {
651  rkh_bittbl_getBitMask_ExpectAndReturn(0, maptbl[0]);
652  TEST_ASSERT_TRUE(rkh_trc_symFil_isoff(RKHFilterSma, 0) == RKH_FALSE);
653 
654  setBitTbl(filStatus.ao->tbl, 0, FILTER_OFF);
655  setBitTbl(filStatus.ao->tbl, 3, FILTER_OFF);
656  rkh_bittbl_getBitMask_ExpectAndReturn(0, maptbl[0]);
657  TEST_ASSERT_TRUE(rkh_trc_symFil_isoff(RKHFilterSma, 0) == RKH_TRUE);
658  rkh_bittbl_getBitMask_ExpectAndReturn(3, maptbl[3]);
659  TEST_ASSERT_TRUE(rkh_trc_symFil_isoff(RKHFilterSma, 3) == RKH_TRUE);
660 
661  rkh_bittbl_getBitMask_ExpectAndReturn(0, maptbl[0]);
662  setBitTbl(filStatus.ao->tbl, 0, FILTER_ON);
663  TEST_ASSERT_TRUE(rkh_trc_symFil_isoff(RKHFilterSma, 0) == RKH_FALSE);
664 }
665 
666 void
667 test_upperAndLowerBoundsSymFil(void)
668 {
669  setBitTbl(bitTbl, 0, FILTER_OFF);
670  setBitTbl(bitTbl, RKH_TRC_MAX_SMA * 8, FILTER_OFF);
671 
672  rkh_bittbl_getBitMask_ExpectAndReturn(0, maptbl[0]);
673  rkh_trc_symFil(RKHFilterSma, 0, FILTER_OFF);
674 
675  rkh_bittbl_getBitMask_ExpectAndReturn(0, maptbl[0]);
676  rkh_trc_symFil(RKHFilterSma, RKH_TRC_MAX_SMA * 8, FILTER_OFF);
677 
678  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.ao->tbl, RKH_TRC_MAX_SMA);
679 }
680 
681 void
682 test_outOfBoundsProducesRuntimeErrorSymFil(void)
683 {
684  rkh_assert_Expect("rkhtrc_filter", 0);
685  rkh_assert_IgnoreArg_file();
686  rkh_assert_IgnoreArg_line();
687  rkh_assert_StubWithCallback(MockAssertCallback);
688 
689  rkh_trc_symFil(RKHFilterSma, (filStatus.ao->size * 8) + 1, FILTER_OFF);
690 }
691 
697 /* ------------------------------ End of file ------------------------------ */
#define RKH_FAIL
Standard define.
Definition: rkhdef.h:277
#define RKH_OK
Standard define.
Definition: rkhdef.h:278
#define RKH_FALSE
Standard define.
Definition: rkhdef.h:256
#define RKH_TRUE
Standard define.
Definition: rkhdef.h:257
rui8_t RKH_TG_T
Group of events.
#define RKH_TE_FWK_OBJ
Entry symbol table for memory object.
#define RKH_TE_SM_TS_STATE
Destination state or pseudostate of a transition segment.
#define RKH_TG_MP
Memory Pool group (MP)
#define RKH_TRC_SET_ALL(mode_)
Emit or supress tracing for all signal/active objects.
#define RKH_SM_START
Trace event offset.
#define RKH_TE_SM_CLRH
Erase the history of a state. It can be a shallow or deep history.
#define RKH_TRC_ALL_EVENTS
Emit or suppress all trace events.
#define RKH_TG_SM
State Machine group (SM)
#define RKH_TE_SM_INIT
Inits a previously created state machine calling its initializing action.
#define RKH_TRC_MAX_EVENTS_IN_BYTES
Defines the size of trace filter table according to RKH_TOT_NUM_TRC_EVTS and RKH_TRC_MAX_EVENTS.
rui8_t RKH_TE_ID_T
Describes a trace event identification (ID).
#define RKH_TRC_ALL_GROUPS
Emit or suppress tracing for all groups and events.
#define RKH_TG_UT
Unit test harness group (UT)
#define RKH_TE_MP_INIT
Initializes the previously allocated memory pool data strcuture RKH_MEMPOOL_T.
Specifies the runtime filter operations for the trace facility.
void rkh_trc_filter_group_(rui8_t ctrl, RKH_TG_T grp, rui8_t mode)
Emit or suppress all trace events from a specific group.
void rkh_trc_filter_event_(rui8_t ctrl, RKH_TE_ID_T evt)
Emit or suppress a specific event.
rbool_t rkh_trc_symFil_isoff(RKHFilter fd, RKH_TRC_FSLOT slot)
Test the active objecto or signal filter condition.
rbool_t rkh_trc_isoff_(RKH_TE_ID_T e)
Test the group and event filter condition.
void rkh_trc_filter_get(RKH_FilterTbl *outFilterTbl)
Get a memory reference to every trace filter table.
void rkh_trc_symFil(RKHFilter fd, RKH_TRC_FSLOT slot, rui8_t mode)
Emmit or suppresse trace events related to a particular active object or event signal.