summaryrefslogtreecommitdiff
path: root/cesar/cp2/fsm
diff options
context:
space:
mode:
authorschodet2008-06-13 12:56:58 +0000
committerschodet2008-06-13 12:56:58 +0000
commitb9eb3c949e0b95a8cf6d135e2189a7c05b55825f (patch)
tree0e1ca7d2540e9f0c7fe2b871ee396e3a99507346 /cesar/cp2/fsm
parent2319ff53c4b2c6ba0435b623048f64c7718e775d (diff)
* cp2/fsm/test/utest:
- fixed bad event and leaked memory. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2321 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp2/fsm')
-rw-r--r--cesar/cp2/fsm/test/utest/src/test_fsm.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/cesar/cp2/fsm/test/utest/src/test_fsm.c b/cesar/cp2/fsm/test/utest/src/test_fsm.c
index 8fbdcc0053..5e737c01fc 100644
--- a/cesar/cp2/fsm/test/utest/src/test_fsm.c
+++ b/cesar/cp2/fsm/test/utest/src/test_fsm.c
@@ -25,9 +25,9 @@ test_fsm_basic_test_case (test_t t)
{
test_case_begin (t, "basic");
cp_t cp;
- cp_fsm_init (&cp);
test_begin (t, "bare")
{
+ cp_fsm_init (&cp);
scenario_entry_t entries[] = {
/* STATE1 */
SCENARIO_ACTION (post_and_process,
@@ -45,7 +45,7 @@ test_fsm_basic_test_case (test_t t)
/* STATE3 */
SCENARIO_ACTION (post_and_process,
.type = CP_FSM_EVENT_TYPE_event1, .mme = NULL),
- SCENARIO_EVENT (cp_fsm__STATE2__event3,
+ SCENARIO_EVENT (cp_fsm__STATE3__event1,
.branch = CP_FSM_BRANCH (STATE3, event1, branch2)),
/* STATE3 */
SCENARIO_ACTION (post_and_process,
@@ -59,12 +59,12 @@ test_fsm_basic_test_case (test_t t)
/* STATE4 */
SCENARIO_ACTION (post_and_process,
.type = CP_FSM_EVENT_TYPE_event1, .mme = NULL),
- SCENARIO_EVENT (cp_fsm__STATE2__event3,
+ SCENARIO_EVENT (cp_fsm__STATE4__event1,
.branch = CP_FSM_BRANCH (STATE4, event1, branch2)),
/* STATE4 */
SCENARIO_ACTION (post_and_process,
.type = CP_FSM_EVENT_TYPE_event1, .mme = NULL),
- SCENARIO_EVENT (cp_fsm__STATE2__event3,
+ SCENARIO_EVENT (cp_fsm__STATE4__event1,
.branch = CP_FSM_BRANCH (STATE4, event1, branch1)),
/* STATE1 */
SCENARIO_END
@@ -74,9 +74,11 @@ test_fsm_basic_test_case (test_t t)
};
scenario_run (t, entries, &globals);
test_fail_unless (cp.fsm.state == CP_FSM_STATE_STATE1);
+ cp_fsm_uninit (&cp);
} test_end;
test_begin (t, "mme")
{
+ cp_fsm_init (&cp);
cp_mme_rx_t *mme = (void *) 0x12345678;
scenario_entry_t entries[] = {
SCENARIO_ACTION (post_and_process,
@@ -89,9 +91,11 @@ test_fsm_basic_test_case (test_t t)
};
scenario_run (t, entries, &globals);
test_fail_unless (cp.fsm.state == CP_FSM_STATE_STATE1);
+ cp_fsm_uninit (&cp);
} test_end;
test_begin (t, "beacon")
{
+ cp_fsm_init (&cp);
cp_beacon_desc_t *beacon = (void *) 0x9abcdef0;
scenario_entry_t entries[] = {
SCENARIO_ACTION (post_and_process,
@@ -106,8 +110,8 @@ test_fsm_basic_test_case (test_t t)
};
scenario_run (t, entries, &globals);
test_fail_unless (cp.fsm.state == CP_FSM_STATE_STATE1);
+ cp_fsm_uninit (&cp);
} test_end;
- cp_fsm_uninit (&cp);
}
void
@@ -118,8 +122,9 @@ test_fsm_error_test_case (test_t t)
test_begin (t, "no branch")
{
cp_fsm_init (&cp);
- cp_fsm_post (&cp, cp_fsm_event_bare_new (
- &cp, CP_FSM_EVENT_TYPE_error_event_no_branch));
+ cp_fsm_event_t *event = cp_fsm_event_bare_new (
+ &cp, CP_FSM_EVENT_TYPE_error_event_no_branch);
+ cp_fsm_post (&cp, event);
const char *asserted = NULL;
dbg_fatal_try_begin
{
@@ -127,6 +132,7 @@ test_fsm_error_test_case (test_t t)
}
dbg_fatal_try_catch (const char *msg)
{
+ slab_release (event); /* Was not release due to assert. */
asserted = msg;
}
dbg_fatal_try_end;
@@ -135,8 +141,9 @@ test_fsm_error_test_case (test_t t)
test_begin (t, "bad branch")
{
cp_fsm_init (&cp);
- cp_fsm_post (&cp, cp_fsm_event_bare_new (
- &cp, CP_FSM_EVENT_TYPE_error_event_bad_branch));
+ cp_fsm_event_t *event = cp_fsm_event_bare_new (
+ &cp, CP_FSM_EVENT_TYPE_error_event_bad_branch);
+ cp_fsm_post (&cp, event);
const char *asserted = NULL;
dbg_fatal_try_begin
{
@@ -144,6 +151,7 @@ test_fsm_error_test_case (test_t t)
}
dbg_fatal_try_catch (const char *msg)
{
+ slab_release (event); /* Was not release due to assert. */
asserted = msg;
}
dbg_fatal_try_end;
@@ -152,8 +160,9 @@ test_fsm_error_test_case (test_t t)
test_begin (t, "dup branch")
{
cp_fsm_init (&cp);
- cp_fsm_post (&cp, cp_fsm_event_bare_new (
- &cp, CP_FSM_EVENT_TYPE_error_event_dup_branch));
+ cp_fsm_event_t *event = cp_fsm_event_bare_new (
+ &cp, CP_FSM_EVENT_TYPE_error_event_dup_branch);
+ cp_fsm_post (&cp, event);
const char *asserted = NULL;
dbg_fatal_try_begin
{
@@ -161,6 +170,7 @@ test_fsm_error_test_case (test_t t)
}
dbg_fatal_try_catch (const char *msg)
{
+ slab_release (event); /* Was not release due to assert. */
asserted = msg;
}
dbg_fatal_try_end;