RKH
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 web site: http://sourceforge.net/projects/rkh-reactivesys/
28  * e-mail: francuccilea@gmail.com
29  * ---------------------------------------------------------------------------
30  */
31 
44 /* -------------------------- Development history -------------------------- */
45 /*
46  * 2017.20.04 LeFr v2.4.05 ---
47  */
48 
49 /* -------------------------------- Authors -------------------------------- */
50 /*
51  * LeFr Leandro Francucci francuccilea@gmail.com
52  */
53 
54 /* --------------------------------- Notes --------------------------------- */
55 /* ----------------------------- Include files ----------------------------- */
56 #include "unity_fixture.h"
57 #include "rkhtrc_filter.h"
58 #include "Mock_rkhassert.h"
59 #include "Mock_rkhfwk_bittbl.h"
60 
61 /* ----------------------------- Local macros ------------------------------ */
62 /* ------------------------------- Constants ------------------------------- */
63 #define SIZEOF_BIT_TBL RKH_TRC_MAX_EVENTS_IN_BYTES
64 #define MAX_NUM_BITS (SIZEOF_BIT_TBL * 8)
65 #define FILTER_ON_BYTE 0
66 #define FILTER_OFF_BYTE 0xff
67 
68 /* ---------------------------- Local data types --------------------------- */
69 /* ---------------------------- Global variables --------------------------- */
70 TEST_GROUP(toolForTest);
71 TEST_GROUP(filter);
72 
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 /* ---------------------------- Local functions ---------------------------- */
83 static void
84 MockAssertCallback(const char* const file, int line, int cmock_num_calls)
85 {
86  TEST_PASS();
87 }
88 
89 static void
90 setBitTbl(rui8_t *bt, rui16_t bit, rui8_t value)
91 {
92  rui8_t bitPos;
93  rui16_t ix;
94 
95  TEST_ASSERT_TRUE( (bt != (rui8_t *)0) ||
96  (bit < MAX_NUM_BITS) ||
97  (value <= 1));
98 
99  bitPos = (rui8_t)(bit & 7);
100  ix = (rui16_t)(bit >> 3);
101 
102  if (value == 1)
103  {
104  *(bt + ix) |= maptbl[bitPos];
105  }
106  else
107  {
108  *(bt + ix) &= ~maptbl[bitPos];
109  }
110 }
111 
112 static ruint
113 getBitTbl(rui8_t *bt, rui16_t bit)
114 {
115  rui8_t bitPos;
116  rui16_t ix;
117  rui8_t bitVal;
118 
119  TEST_ASSERT_TRUE( (bt != (rui8_t *)0) ||
120  (bit < MAX_NUM_BITS));
121 
122  bitPos = (rui8_t)(bit & 0x07);
123  ix = (rui16_t)(bit >> 3);
124 
125  bitVal = (*(bt + ix) & maptbl[bitPos]) != 0;
126  return bitVal;
127 }
128 
129 static void
130 setAllBitTbl(rui8_t *bt, ruint value, ruint size)
131 {
132  TEST_ASSERT_TRUE(bt != (rui8_t *)0);
133  memset(bitTbl, value, size);
134 }
135 
136 static rbool_t
137 checkBitTblAreOn(rui8_t *bt, rui16_t size)
138 {
139  rui16_t i;
140  rui8_t *p;
141  rbool_t res;
142 
143  for (i = 0, p = bt, res = RKH_OK; i < size; ++i, ++p)
144  {
145  if (*p != FILTER_ON_BYTE)
146  {
147  res = RKH_FAIL;
148  break;
149  }
150  }
151  return res;
152 }
153 
154 static void
155 setBlockBit(rui8_t *bt, ruint value, ruint to)
156 {
157  ruint bitPos;
158 
159  for (bitPos = 0; bitPos < to; ++bitPos)
160  {
161  setBitTbl(bt, bitPos, value);
162  }
163 }
164 
165 /* It could be added to rkhtrc module */
166 static void
167 rkh_trc_filterAllOn(rui8_t *ft, RKH_TE_ID_T ftSize)
168 {
169  RKH_TE_ID_T cnt;
170  rui8_t *p;
171 
172  for (cnt = 0, p = ft; cnt < ftSize; ++cnt, ++p)
173  {
174  *p = FILTER_ON_BYTE;
175  }
176 }
177 
178 /* It could be added to rkhtrc module */
179 void
180 rkh_trc_filter_init(void)
181 {
182  rkh_trc_filterAllOn(filStatus.signal->tbl,
183  (RKH_TE_ID_T)(filStatus.signal->size));
184  rkh_trc_filterAllOn(filStatus.ao->tbl,
185  (RKH_TE_ID_T)(filStatus.ao->size));
186  rkh_trc_filterAllOn(filStatus.event,
188  rkh_trc_filterAllOn(filStatus.group,
189  (RKH_TE_ID_T)(sizeof(RKH_TG_T)));
190 }
191 
192 /* ---------------------------- Global functions --------------------------- */
193 /* =========================== Filter test group =========================== */
194 TEST_SETUP(toolForTest)
195 {
196 }
197 
198 TEST_TEAR_DOWN(toolForTest)
199 {
200 }
201 
208 TEST(toolForTest, getBitIndex0)
209 {
210  setAllBitTbl(bitTbl, 0, SIZEOF_BIT_TBL);
211  bitTbl[0] = 0x82;
212 
213  TEST_ASSERT_EQUAL(0, getBitTbl(bitTbl, 0));
214  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 1));
215  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 7));
216 }
217 
218 TEST(toolForTest, getBitIndexX)
219 {
220  setAllBitTbl(bitTbl, 0, SIZEOF_BIT_TBL);
221  bitTbl[0] = 0x80;
222  bitTbl[1] = 0x03;
223  bitTbl[2] = 0xc0;
224 
225  TEST_ASSERT_EQUAL(0, getBitTbl(bitTbl, 0));
226  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 7));
227  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 8));
228  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 9));
229  TEST_ASSERT_EQUAL(0, getBitTbl(bitTbl, 10));
230  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 22));
231  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 23));
232 }
233 
234 TEST(toolForTest, setBitIndex0)
235 {
236  setAllBitTbl(bitTbl, 0, SIZEOF_BIT_TBL);
237 
238  setBitTbl(bitTbl, 0, 1);
239  TEST_ASSERT_EQUAL_HEX8(0x01, bitTbl[0]);
240  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 0));
241 
242  setBitTbl(bitTbl, 7, 1);
243  TEST_ASSERT_EQUAL_HEX8(0x81, bitTbl[0]);
244  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 7));
245 
246  TEST_ASSERT_EQUAL_HEX8(0x00, bitTbl[1]);
247  TEST_ASSERT_EQUAL_HEX8(0x00, bitTbl[2]);
248  TEST_ASSERT_EQUAL_HEX8(0x00, bitTbl[3]);
249 }
250 
251 TEST(toolForTest, resetBitIndex0)
252 {
253  setAllBitTbl(bitTbl, 0xff, SIZEOF_BIT_TBL);
254 
255  setBitTbl(bitTbl, 0, 0);
256  TEST_ASSERT_EQUAL_HEX8(0xfe, bitTbl[0]);
257  TEST_ASSERT_EQUAL(0, getBitTbl(bitTbl, 0));
258 
259  setBitTbl(bitTbl, 7, 0);
260  TEST_ASSERT_EQUAL_HEX8(0x7e, bitTbl[0]);
261  TEST_ASSERT_EQUAL(0, getBitTbl(bitTbl, 7));
262 
263  TEST_ASSERT_EQUAL_HEX8(0xff, bitTbl[1]);
264  TEST_ASSERT_EQUAL_HEX8(0xff, bitTbl[2]);
265  TEST_ASSERT_EQUAL_HEX8(0xff, bitTbl[3]);
266 }
267 
268 TEST(toolForTest, setBitIndexX)
269 {
270  setAllBitTbl(bitTbl, 0, SIZEOF_BIT_TBL);
271 
272  setBitTbl(bitTbl, 8, 1);
273  TEST_ASSERT_EQUAL_HEX8(0x01, bitTbl[1]);
274  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 8));
275 
276  setBitTbl(bitTbl, 17, 1);
277  TEST_ASSERT_EQUAL_HEX8(0x02, bitTbl[2]);
278  TEST_ASSERT_EQUAL(1, getBitTbl(bitTbl, 17));
279 
280  TEST_ASSERT_EQUAL_HEX8(0x00, bitTbl[0]);
281  TEST_ASSERT_EQUAL_HEX8(0x00, bitTbl[3]);
282 }
283 
284 TEST(toolForTest, resetBitIndexX)
285 {
286  setAllBitTbl(bitTbl, 0xff, SIZEOF_BIT_TBL);
287 
288  setBitTbl(bitTbl, 8, 0);
289  TEST_ASSERT_EQUAL_HEX8(0xfe, bitTbl[1]);
290  TEST_ASSERT_EQUAL(0, getBitTbl(bitTbl, 8));
291 
292  setBitTbl(bitTbl, 17, 0);
293  TEST_ASSERT_EQUAL_HEX8(0xfd, bitTbl[2]);
294  TEST_ASSERT_EQUAL(0, getBitTbl(bitTbl, 17));
295 
296  TEST_ASSERT_EQUAL_HEX8(0xff, bitTbl[0]);
297  TEST_ASSERT_EQUAL_HEX8(0xff, bitTbl[3]);
298 }
299 
303 /* ============================ Trace test group =========================== */
304 TEST_SETUP(filter)
305 {
306  rkh_trc_filter_get(&filStatus);
307  rkh_trc_filter_init();
308  memset(bitTbl, FILTER_ON_BYTE, RKH_TRC_MAX_EVENTS_IN_BYTES);
309  Mock_rkhfwk_bittbl_Init();
310 }
311 
312 TEST_TEAR_DOWN(filter)
313 {
314  Mock_rkhfwk_bittbl_Verify();
315  Mock_rkhfwk_bittbl_Destroy();
316 }
317 
324 TEST(filter, filEventsAreOnAfterInit)
325 {
326  TEST_ASSERT_TRUE(checkBitTblAreOn(filStatus.signal->tbl,
327  filStatus.signal->size) == RKH_OK);
328 
329  TEST_ASSERT_TRUE(checkBitTblAreOn(filStatus.ao->tbl,
330  filStatus.ao->size) == RKH_OK);
331 
332  TEST_ASSERT_TRUE(checkBitTblAreOn(filStatus.event,
334 
335  TEST_ASSERT_TRUE(checkBitTblAreOn(filStatus.group,
336  sizeof(RKH_TG_T)) == RKH_OK);
337 }
338 
339 TEST(filter, turnOffOneFilEvent)
340 {
341  RKH_GM_OFFSET_T offset;
342 
343  offset = RKH_SM_TTBL_OFFSET;
344  bitTbl[offset] = 0x01;
345  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_SM_INIT) & 7, 1);
346  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_SM_INIT), 8);
347 
349 
350  TEST_ASSERT_EQUAL(1, getBitTbl(&filStatus.event[offset], 0));
351  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.event,
353  TEST_ASSERT_EQUAL_HEX8(0x01,
354  filStatus.event[offset + GETEVT(RKH_TE_SM_INIT)]);
355  TEST_ASSERT_EQUAL_HEX8(0x08, *filStatus.group);
356 }
357 
358 TEST(filter, turnOnOneFilEvent)
359 {
360  bitTbl[RKH_SM_TTBL_OFFSET + 0] = 0x02;
361 
362  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_SM_INIT) & 7, 1);
363  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_SM_INIT), 8);
365 
366  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_SM_CLRH) & 7, 2);
367  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_SM_CLRH), 8);
369 
370  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_SM_INIT) & 7, 1);
372 
373  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.event,
375  TEST_ASSERT_EQUAL_HEX8(0x08, *filStatus.group);
376 }
377 
378 TEST(filter, turnOffMultipleFilEvent)
379 {
380  RKH_GM_OFFSET_T offset;
381 
382  offset = RKH_SM_TTBL_OFFSET;
383  bitTbl[offset] = 0x01;
384  bitTbl[offset + 1] = 0x01;
385 
386  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_SM_INIT) & 7, 1);
387  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_SM_INIT), 8);
389 
390  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_SM_TS_STATE) & 7, 1);
391  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_SM_TS_STATE), 8);
393 
394  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.event,
396 }
397 
398 TEST(filter, allOffFilEvent)
399 {
400  memset(bitTbl, FILTER_OFF_BYTE, RKH_TRC_MAX_EVENTS_IN_BYTES);
401 
403  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.event,
405  TEST_ASSERT_EQUAL_HEX8(0xff, *filStatus.group);
406 }
407 
408 TEST(filter, allOnFilEvent)
409 {
411  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.event,
413  TEST_ASSERT_EQUAL_HEX8(0x00, *filStatus.group);
414 }
415 
416 TEST(filter, isOnOffFilEvent)
417 {
418  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_FWK_OBJ), 0x20);
419  TEST_ASSERT_TRUE(rkh_trc_isoff_(RKH_TE_FWK_OBJ) == RKH_FALSE);
420 
421  setBitTbl(filStatus.event, RKH_TE_MP_INIT, FILTER_OFF);
422  setBitTbl(filStatus.group, RKH_TG_MP, FILTER_OFF);
423  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_MP_INIT), 0x01);
424  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_MP_INIT) & 7, 0x01);
425  TEST_ASSERT_TRUE(rkh_trc_isoff_(RKH_TE_MP_INIT) == RKH_TRUE);
426 
427  setBitTbl(filStatus.event, RKH_TE_MP_INIT, FILTER_ON);
428  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_MP_INIT), 0x01);
429  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_MP_INIT) & 7, 0x01);
430  TEST_ASSERT_TRUE(rkh_trc_isoff_(RKH_TE_MP_INIT) == RKH_FALSE);
431 }
432 
433 TEST(filter, upperAndLowerBoundsFilEvent)
434 {
435  bitTbl[0] = 0x01;
436  bitTbl[RKH_TRC_MAX_EVENTS_IN_BYTES - 2] = 0x80;
437 
438  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_MP_INIT), 0x01);
439  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_MP_INIT) & 7, 0x01);
441 
442  rkh_bittbl_getBitMask_ExpectAndReturn(GETGRP(RKH_TE_UT_IGNORE_ARG), 0x80);
443  rkh_bittbl_getBitMask_ExpectAndReturn(GETEVT(RKH_TE_UT_IGNORE_ARG) & 7,
444  0x80);
445  rkh_trc_filter_event_(FILTER_OFF, RKH_TE_UT_IGNORE_ARG);
446 
447  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.event,
449 }
450 
451 TEST(filter, setAllEventsFromOneGroup)
452 {
453  RKH_TE_ID_T filter, filterFrom, filterTo, offset;
454  rui8_t evt;
455 
456  filterFrom = RKH_SM_START;
457  filterTo = RKH_SM_END;
458  offset = filStatus.grpFilMap[GETGRP(RKH_SM_START)].offset;
459  setBlockBit(&bitTbl[offset], 1, filterTo - filterFrom);
460 
461  for (filter = filterFrom; filter < filterTo; ++filter)
462  {
463  evt = GETEVT(filter) & 7;
464  rkh_bittbl_getBitMask_ExpectAndReturn(evt, maptbl[evt]);
465  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_SM, 8);
466  rkh_trc_filter_event_(FILTER_OFF, filter);
467  }
468 
469  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.event,
471 }
472 
473 TEST(filter, outOfBoundsProducesRuntimeError)
474 {
475  rkh_assert_Expect("rkhtrc_filter", 0);
476  rkh_assert_IgnoreArg_line();
477  rkh_assert_StubWithCallback(MockAssertCallback);
478 
479  rkh_trc_filter_event_(FILTER_OFF, RKH_TRC_ALL_EVENTS + 1);
480 }
481 
482 TEST(filter, turnOffOneGroup)
483 {
484  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_MP, maptbl[RKH_TG_MP]);
485  rkh_trc_filter_group_(FILTER_OFF, RKH_TG_MP, EUNCHANGE);
486  TEST_ASSERT_EQUAL_HEX8(0x01, *filStatus.group);
487 }
488 
489 TEST(filter, turnOnOneGroup)
490 {
491  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_MP, maptbl[RKH_TG_MP]);
492  rkh_trc_filter_group_(FILTER_OFF, RKH_TG_MP, EUNCHANGE);
493 
494  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_MP, maptbl[RKH_TG_MP]);
495  rkh_trc_filter_group_(FILTER_ON, RKH_TG_MP, EUNCHANGE);
496  TEST_ASSERT_EQUAL_HEX8(0x00, *filStatus.group);
497 }
498 
499 TEST(filter, allOnOffGroup)
500 {
501  rkh_trc_filter_group_(FILTER_OFF, RKH_TRC_ALL_GROUPS, EUNCHANGE);
502  TEST_ASSERT_EQUAL_HEX8(0xff, *filStatus.group);
503  rkh_trc_filter_group_(FILTER_ON, RKH_TRC_ALL_GROUPS, EUNCHANGE);
504  TEST_ASSERT_EQUAL_HEX8(0x00, *filStatus.group);
505 }
506 
507 TEST(filter, turnOnOffMultipleGroups)
508 {
509  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_MP, maptbl[RKH_TG_MP]);
510  rkh_trc_filter_group_(FILTER_OFF, RKH_TG_MP, EUNCHANGE);
511 
512  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_SM, maptbl[RKH_TG_SM]);
513  rkh_trc_filter_group_(FILTER_OFF, RKH_TG_SM, EUNCHANGE);
514 
515  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_UT, maptbl[RKH_TG_UT]);
516  rkh_trc_filter_group_(FILTER_OFF, RKH_TG_UT, EUNCHANGE);
517 
518  TEST_ASSERT_EQUAL_HEX8(0x89, *filStatus.group);
519 
520  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_MP, maptbl[RKH_TG_MP]);
521  rkh_trc_filter_group_(FILTER_ON, RKH_TG_MP, EUNCHANGE);
522 
523  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_SM, maptbl[RKH_TG_SM]);
524  rkh_trc_filter_group_(FILTER_ON, RKH_TG_SM, EUNCHANGE);
525 
526  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_UT, maptbl[RKH_TG_UT]);
527  rkh_trc_filter_group_(FILTER_ON, RKH_TG_UT, EUNCHANGE);
528 
529  TEST_ASSERT_EQUAL_HEX8(0x00, *filStatus.group);
530 }
531 
532 TEST(filter, turnOffOneGroupChangedItsEventFilters)
533 {
534  RKHROM RKH_GMTBL_T *pTrcMap;
535 
536  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TG_UT, maptbl[RKH_TG_UT]);
537  rkh_trc_filter_group_(FILTER_OFF, RKH_TG_UT, ECHANGE);
538  TEST_ASSERT_EQUAL_HEX8(0x80, *filStatus.group);
539 
540  pTrcMap = &filStatus.grpFilMap[RKH_TG_UT];
541  memset(&bitTbl[pTrcMap->offset], FILTER_OFF_BYTE, pTrcMap->range);
542 
543  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.event,
545 }
546 
547 TEST(filter, turnOffOneSymFil)
548 {
549  bitTbl[0] = 0x01;
550 
551  rkh_bittbl_getBitMask_ExpectAndReturn(0, maptbl[0]);
552  rkh_trc_symFil(RKHFilterSma, 0, FILTER_OFF);
553 
554  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.ao->tbl, RKH_TRC_MAX_SMA);
555 }
556 
557 TEST(filter, turnOnOneSymFil)
558 {
559  bitTbl[0] = 0x00;
560 
561  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TRC_MAX_SMA - 1,
562  maptbl[RKH_TRC_MAX_SMA - 1]);
563  rkh_trc_symFil(RKHFilterSma, RKH_TRC_MAX_SMA - 1, FILTER_OFF);
564 
565  rkh_bittbl_getBitMask_ExpectAndReturn(RKH_TRC_MAX_SMA - 1,
566  maptbl[RKH_TRC_MAX_SMA - 1]);
567  rkh_trc_symFil(RKHFilterSma, RKH_TRC_MAX_SMA - 1, FILTER_ON);
568 
569  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.ao->tbl, RKH_TRC_MAX_SMA);
570 }
571 
572 TEST(filter, turnOnOffMultipleSymFil)
573 {
574  bitTbl[0] = 0x89;
575 
576  rkh_bittbl_getBitMask_ExpectAndReturn(0, maptbl[0]);
577  rkh_trc_symFil(RKHFilterSma, 0, FILTER_OFF);
578 
579  rkh_bittbl_getBitMask_ExpectAndReturn(3, maptbl[3]);
580  rkh_trc_symFil(RKHFilterSma, 3, FILTER_OFF);
581 
582  rkh_bittbl_getBitMask_ExpectAndReturn(7, maptbl[7]);
583  rkh_trc_symFil(RKHFilterSma, 7, FILTER_OFF);
584 
585  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.ao->tbl, RKH_TRC_MAX_SMA);
586 }
587 
588 TEST(filter, allOffOnSymFil)
589 {
590  setAllBitTbl(bitTbl, FILTER_OFF_BYTE, RKH_TRC_MAX_SMA);
591  rkh_trc_symFil(RKHFilterSma, 0, RKH_TRC_SET_ALL(FILTER_OFF));
592  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.ao->tbl, RKH_TRC_MAX_SMA);
593 
594  setAllBitTbl(bitTbl, FILTER_ON_BYTE, RKH_TRC_MAX_SMA);
595  rkh_trc_symFil(RKHFilterSma, 0, RKH_TRC_SET_ALL(FILTER_ON));
596  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.ao->tbl, RKH_TRC_MAX_SMA);
597 }
598 
599 TEST(filter, isOnOffSymFil)
600 {
601  rkh_bittbl_getBitMask_ExpectAndReturn(0, maptbl[0]);
602  TEST_ASSERT_TRUE(rkh_trc_symFil_isoff(RKHFilterSma, 0) == RKH_FALSE);
603 
604  setBitTbl(filStatus.ao->tbl, 0, FILTER_OFF);
605  setBitTbl(filStatus.ao->tbl, 3, FILTER_OFF);
606  rkh_bittbl_getBitMask_ExpectAndReturn(0, maptbl[0]);
607  TEST_ASSERT_TRUE(rkh_trc_symFil_isoff(RKHFilterSma, 0) == RKH_TRUE);
608  rkh_bittbl_getBitMask_ExpectAndReturn(3, maptbl[3]);
609  TEST_ASSERT_TRUE(rkh_trc_symFil_isoff(RKHFilterSma, 3) == RKH_TRUE);
610 
611  rkh_bittbl_getBitMask_ExpectAndReturn(0, maptbl[0]);
612  setBitTbl(filStatus.ao->tbl, 0, FILTER_ON);
613  TEST_ASSERT_TRUE(rkh_trc_symFil_isoff(RKHFilterSma, 0) == RKH_FALSE);
614 }
615 
616 TEST(filter, upperAndLowerBoundsSymFil)
617 {
618  setBitTbl(bitTbl, 0, FILTER_OFF);
619  setBitTbl(bitTbl, RKH_TRC_MAX_SMA * 8, FILTER_OFF);
620 
621  rkh_bittbl_getBitMask_ExpectAndReturn(0, maptbl[0]);
622  rkh_trc_symFil(RKHFilterSma, 0, FILTER_OFF);
623 
624  rkh_bittbl_getBitMask_ExpectAndReturn(0, maptbl[0]);
625  rkh_trc_symFil(RKHFilterSma, RKH_TRC_MAX_SMA * 8, FILTER_OFF);
626 
627  TEST_ASSERT_EQUAL_MEMORY(bitTbl, filStatus.ao->tbl, RKH_TRC_MAX_SMA);
628 }
629 
630 TEST(filter, outOfBoundsProducesRuntimeErrorSymFil)
631 {
632  rkh_assert_Expect("rkhtrc_filter", 0);
633  rkh_assert_IgnoreArg_line();
634  rkh_assert_StubWithCallback(MockAssertCallback);
635 
636  rkh_trc_symFil(RKHFilterSma, (filStatus.ao->size * 8) + 1, FILTER_OFF);
637 }
638 
644 /* ------------------------------ End of file ------------------------------ */
#define RKH_FAIL
Standard define.
Definition: rkhdef.h:275
#define RKH_TE_MP_INIT
Initializes the previously allocated memory pool data strcuture RKH_MEMPOOL_T.
#define RKH_TRC_ALL_EVENTS
Emit or suppress all trace events.
#define RKH_TE_SM_TS_STATE
Destination state or pseudostate of a transition segment.
#define RKH_TG_MP
Memory Pool group (MP)
void rkh_trc_filter_get(RKH_FilterTbl *outFilterTbl)
Get a memory reference to every trace filter table.
#define RKH_SM_START
Trace event offset.
#define RKH_TG_UT
Unit test harness group (UT)
#define RKH_OK
Standard define.
Definition: rkhdef.h:276
#define RKH_TE_FWK_OBJ
Entry symbol table for memory object.
Specifies the runtime filter operations for the trace facility.
#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.
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.
#define RKH_FALSE
Standard define.
Definition: rkhdef.h:254
#define RKH_TG_SM
State Machine group (SM)
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.
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.
rui8_t RKH_TG_T
Group of events.
#define RKH_TE_SM_CLRH
Erase the history of a state. It can be a shallow or deep history.
void rkh_trc_filter_event_(rui8_t ctrl, RKH_TE_ID_T evt)
Emit or suppress a specific event.
#define RKH_TRUE
Standard define.
Definition: rkhdef.h:255
#define RKH_TE_SM_INIT
Inits a previously created state machine calling its initializing action.
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.
#define RKH_TRC_SET_ALL(mode_)
Emit or supress tracing for all signal/active objects.