Skip to content

Commit

Permalink
Sent memory pool symbols as traces
Browse files Browse the repository at this point in the history
  • Loading branch information
leanfrancucci committed Aug 15, 2020
1 parent 29fe7ac commit 57ff8a8
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
8 changes: 8 additions & 0 deletions source/fwk/inc/rkhitl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,14 @@ extern "C" {
#define R_TRC_AO_NAME_EN RKH_DISABLED
#endif

#if (RKH_CFG_TRC_EN == RKH_ENABLED && \
(RKH_CFG_TRC_ALL_EN == RKH_ENABLED || \
RKH_CFG_TRC_MP_EN == RKH_ENABLED))
#define RKH_MEMPOOL_EN RKH_ENABLED
#else
#define RKH_MEMPOOL_EN RKH_DISABLED
#endif

#define MKTRN(evt_, guard_, effect_, target_) \
{ \
evt_, (RKH_GUARD_T)guard_, \
Expand Down
8 changes: 8 additions & 0 deletions source/fwk/src/rkhfwk_evtpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "rkhassert.h"
#include "rkhfwk_dynevt.h"
#include "rkhmempool.h"
#include "rkhtrc_record.h"

RKH_MODULE_NAME(rkhfwk_evtpool)

Expand Down Expand Up @@ -92,11 +93,18 @@ rkh_evtPool_getPool(void *stoStart, rui16_t stoSize, RKH_ES_T evtSize)
{
rInt i;
RKHEvtPool *ep;
#if RKH_MEMPOOL_EN == RKH_ENABLED
char name[] = "memPool?";
#endif

for (i = 0, ep = evtPools; i < RKH_CFG_FWK_MAX_EVT_POOL; ++i, ++ep)
{
if (((RKH_MEMPOOL_T *)ep)->nblocks == 0)
{
#if RKH_MEMPOOL_EN == RKH_ENABLED
name[7] = (i + '0');
RKH_TR_FWK_OBJ_NAME(ep, name);
#endif
rkh_memPool_init((RKH_MEMPOOL_T *)ep, stoStart, stoSize,
(RKH_MPBS_T)evtSize);
return ep;
Expand Down
41 changes: 41 additions & 0 deletions source/fwk/test/test_rkhfwk_evtpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

/* --------------------------------- Notes --------------------------------- */
/* ----------------------------- Include files ----------------------------- */
#include <string.h>
#include "unity.h"
#include "rkhfwk_evtpool.h"
#include "Mock_rkhtrc_record.h"
Expand Down Expand Up @@ -122,9 +123,13 @@ test_AfterInitAllEvtPoolAvailable(void)
{
RKHEvtPool *ep;
int i;
char name[10];

for (i = 0; i < RKH_CFG_FWK_MAX_EVT_POOL; ++i)
{
sprintf(name, "memPool%1d", i);
rkh_trc_obj_Expect(RKH_TE_FWK_OBJ, 0, name);
rkh_trc_obj_IgnoreArg_obj();
rkh_memPool_init_Expect(0, stoStart, stoSize, (RKH_MPBS_T)evtSize);
rkh_memPool_init_IgnoreArg_mp();

Expand All @@ -138,7 +143,11 @@ void
test_GetOneEvtPool(void)
{
RKHEvtPool *ep;
char name[10];

strcpy(name, "memPool0");
rkh_trc_obj_Expect(RKH_TE_FWK_OBJ, 0, name);
rkh_trc_obj_IgnoreArg_obj();
rkh_memPool_init_Expect(0, stoStart, stoSize, (RKH_MPBS_T)evtSize);
rkh_memPool_init_IgnoreArg_mp();

Expand All @@ -151,9 +160,13 @@ test_GetMultipleEvtPool(void)
{
rInt i;
RKHEvtPool *ep[RKH_CFG_FWK_MAX_EVT_POOL];
char name[10];

for (i = 0; i < RKH_CFG_FWK_MAX_EVT_POOL; ++i)
{
sprintf(name, "memPool%1d", i);
rkh_trc_obj_Expect(RKH_TE_FWK_OBJ, 0, name);
rkh_trc_obj_IgnoreArg_obj();
rkh_memPool_init_Expect(0, stoStart + (stoSize * i),
stoSize, (RKH_MPBS_T)evtSize * (2 * (i + 1)));
rkh_memPool_init_IgnoreArg_mp();
Expand All @@ -171,9 +184,13 @@ test_Fails_ExceedsMaxAvailableEvtPool(void)
{
rInt i;
RKHEvtPool *ep;
char name[10];

for (i = 0; i < RKH_CFG_FWK_MAX_EVT_POOL; ++i)
{
sprintf(name, "memPool%1d", i);
rkh_trc_obj_Expect(RKH_TE_FWK_OBJ, 0, name);
rkh_trc_obj_IgnoreArg_obj();
rkh_memPool_init_Expect(0, stoStart, stoSize, (RKH_MPBS_T)evtSize);
rkh_memPool_init_IgnoreArg_mp();
ep = rkh_evtPool_getPool(stoStart, stoSize, evtSize);
Expand All @@ -187,7 +204,11 @@ void
test_GetBlockSize(void)
{
RKHEvtPool *ep;
char name[10];

strcpy(name, "memPool0");
rkh_trc_obj_Expect(RKH_TE_FWK_OBJ, 0, name);
rkh_trc_obj_IgnoreArg_obj();
rkh_memPool_init_Expect(0, stoStart, stoSize, (RKH_MPBS_T)evtSize);
rkh_memPool_init_IgnoreArg_mp();

Expand All @@ -210,7 +231,11 @@ test_GetBlock(void)
{
RKHEvtPool *ep;
RKH_EVT_T *evt;
char name[10];

strcpy(name, "memPool0");
rkh_trc_obj_Expect(RKH_TE_FWK_OBJ, 0, name);
rkh_trc_obj_IgnoreArg_obj();
rkh_memPool_init_Expect(0, stoStart, stoSize, (RKH_MPBS_T)evtSize);
rkh_memPool_init_IgnoreArg_mp();
rkh_memPool_get_ExpectAndReturn(0, (void *)0xdead);
Expand All @@ -237,7 +262,11 @@ test_PutBlock(void)
{
RKHEvtPool *ep;
RKH_EVT_T *evt = (RKH_EVT_T *)0xdead;
char name[10];

strcpy(name, "memPool0");
rkh_trc_obj_Expect(RKH_TE_FWK_OBJ, 0, name);
rkh_trc_obj_IgnoreArg_obj();
rkh_memPool_init_Expect(0, stoStart, stoSize, (RKH_MPBS_T)evtSize);
rkh_memPool_init_IgnoreArg_mp();
rkh_memPool_put_Expect(0, evt);
Expand All @@ -263,7 +292,11 @@ void
test_GetNumUsed(void)
{
RKHEvtPool *ep;
char name[10];

strcpy(name, "memPool0");
rkh_trc_obj_Expect(RKH_TE_FWK_OBJ, 0, name);
rkh_trc_obj_IgnoreArg_obj();
rkh_memPool_init_Expect(0, stoStart, stoSize, (RKH_MPBS_T)evtSize);
rkh_memPool_init_IgnoreArg_mp();

Expand All @@ -285,7 +318,11 @@ void
test_GetNumMin(void)
{
RKHEvtPool *ep;
char name[10];

strcpy(name, "memPool0");
rkh_trc_obj_Expect(RKH_TE_FWK_OBJ, 0, name);
rkh_trc_obj_IgnoreArg_obj();
rkh_memPool_init_Expect(0, stoStart, stoSize, (RKH_MPBS_T)evtSize);
rkh_memPool_init_IgnoreArg_mp();

Expand All @@ -307,7 +344,11 @@ void
test_GetNumBlock(void)
{
RKHEvtPool *ep;
char name[10];

strcpy(name, "memPool0");
rkh_trc_obj_Expect(RKH_TE_FWK_OBJ, 0, name);
rkh_trc_obj_IgnoreArg_obj();
rkh_memPool_init_Expect(0, stoStart, stoSize, (RKH_MPBS_T)evtSize);
rkh_memPool_init_IgnoreArg_mp();

Expand Down

0 comments on commit 57ff8a8

Please sign in to comment.