summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorcecaric2009-09-29 15:56:04 +0000
committercecaric2009-09-29 15:56:04 +0000
commite2a3efedce6ff752fee21abb67d74a5ba3886a70 (patch)
tree04cc3bfa63d9da941989213d08e5cd64372fb2fc /cesar
parent2aaa272c0388bc0780dd09a6cf978a26e010a145 (diff)
[EOC][STA][ACT] duplicated files removed from utest_eoc
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@5820 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar')
-rw-r--r--cesar/cp/eoc/sta/action/test/utest_eoc/inc/scenario_defs.h122
-rw-r--r--cesar/cp/eoc/sta/action/test/utest_eoc/src/actions.c97
-rw-r--r--cesar/cp/eoc/sta/action/test/utest_eoc/src/fsm_stub.c188
-rw-r--r--cesar/cp/eoc/sta/action/test/utest_eoc/src/test_fsm.c426
4 files changed, 0 insertions, 833 deletions
diff --git a/cesar/cp/eoc/sta/action/test/utest_eoc/inc/scenario_defs.h b/cesar/cp/eoc/sta/action/test/utest_eoc/inc/scenario_defs.h
deleted file mode 100644
index e6691e1972..0000000000
--- a/cesar/cp/eoc/sta/action/test/utest_eoc/inc/scenario_defs.h
+++ /dev/null
@@ -1,122 +0,0 @@
-#ifndef inc_scenario_defs_h
-#define inc_scenario_defs_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file inc/scenario_defs.h
- * \brief Scenario definitions.
- * \ingroup test
- */
-
-#include "cp/types.h"
-#include "cp/mme.h"
-#include "cp/fsm/fsm.h"
-
-/* Scenario globals. */
-#define SCENARIO_DEFS_GLOBALS \
- cp_t *cp;
-
-/* Scenario actions. */
-#define SCENARIO_DEFS_ACTIONS \
- post_and_process, \
- post, \
- trigger, \
- post_urgent, \
- process, \
- process_urgent
-
-typedef struct
-{
- cp_fsm_event_type_t type;
- cp_mme_rx_t *mme;
- cp_beacon_desc_t *beacon;
- cp_net_t *net;
- cp_sta_t *sta;
-} scenario_action_event_param_t;
-
-typedef scenario_action_event_param_t scenario_action_post_and_process_t;
-typedef scenario_action_event_param_t scenario_action_post_t;
-typedef scenario_action_event_param_t scenario_action_trigger_t;
-typedef scenario_action_event_param_t scenario_action_post_urgent_t;
-typedef scenario_empty_t scenario_action_process_t;
-typedef scenario_empty_t scenario_action_process_urgent_t;
-
-void
-scenario_action_post_and_process_cb (scenario_globals_t *globals,
- scenario_params_t *params);
-
-void
-scenario_action_post_cb (scenario_globals_t *globals,
- scenario_params_t *params);
-
-void
-scenario_action_trigger_cb (scenario_globals_t *globals,
- scenario_params_t *params);
-
-void
-scenario_action_post_urgent_cb (scenario_globals_t *globals,
- scenario_params_t *params);
-
-void
-scenario_action_process_cb (scenario_globals_t *globals,
- scenario_params_t *params);
-
-void
-scenario_action_process_urgent_cb (scenario_globals_t *globals,
- scenario_params_t *params);
-
-/* Scenario events. */
-
-#define SCENARIO_DEFS_EVENTS \
- cp_fsm__DETECTING_BEACON__nd_beacon, \
- cp_fsm__DETECTING_BEACON__nd_beacon_timeout, \
- cp_fsm__ASSOCIATING__timeout_associating, \
- cp_fsm__ASSOCIATING__assoc_cnf, \
- cp_fsm__ASSOCIATING__no_beacons, \
- cp_fsm__UNASSOCIATED__enter_sleep_unassociated, \
- cp_fsm__UNASSOCIATED__retry_unassociated, \
- cp_fsm__SLEEP_UNASSOCIATED__exit_sleep_unassociated, \
- cp_fsm__ASSOCIATED__no_beacons, \
- cp_fsm__ASSOCIATED__leave_ind, \
- cp_fsm__ASSOCIATED__timeout_authenticating, \
- cp_fsm__ASSOCIATED__get_key_cnf, \
- cp_fsm__ASSOCIATED__encrypt_payload_rsp, \
- cp_fsm__AUTHENTICATED__no_beacons, \
- cp_fsm__AUTHENTICATED__leave_ind, \
- cp_fsm__AUTHENTICATED__sleep_enter_cnf, \
- cp_fsm__SLEEP_AUTHENTICATED__no_beacons, \
- cp_fsm__SLEEP_AUTHENTICATED__sleep_exit_rsp
-
-typedef struct
-{
- cp_fsm_branch_t branch;
-} scenario_event_transition_with_branch_t;
-
-typedef scenario_empty_t scenario_event_cp_fsm__DETECTING_BEACON__nd_beacon_t;
-typedef scenario_empty_t scenario_event_cp_fsm__DETECTING_BEACON__nd_beacon_timeout_t;
-typedef scenario_event_transition_with_branch_t scenario_event_cp_fsm__ASSOCIATING__timeout_associating_t;
-typedef scenario_event_transition_with_branch_t scenario_event_cp_fsm__ASSOCIATING__assoc_cnf_t;
-typedef scenario_empty_t scenario_event_cp_fsm__ASSOCIATING__no_beacons_t;
-typedef scenario_empty_t scenario_event_cp_fsm__UNASSOCIATED__enter_sleep_unassociated_t;
-typedef scenario_empty_t scenario_event_cp_fsm__UNASSOCIATED__retry_unassociated_t;
-typedef scenario_empty_t scenario_event_cp_fsm__SLEEP_UNASSOCIATED__exit_sleep_unassociated_t;
-typedef scenario_empty_t scenario_event_cp_fsm__ASSOCIATED__no_beacons_t;
-typedef scenario_empty_t scenario_event_cp_fsm__ASSOCIATED__leave_ind_t;
-typedef scenario_empty_t scenario_event_cp_fsm__ASSOCIATED__timeout_authenticating_t;
-typedef scenario_event_transition_with_branch_t scenario_event_cp_fsm__ASSOCIATED__get_key_cnf_t;
-typedef scenario_empty_t scenario_event_cp_fsm__ASSOCIATED__encrypt_payload_rsp_t;
-typedef scenario_empty_t scenario_event_cp_fsm__AUTHENTICATED__no_beacons_t;
-typedef scenario_empty_t scenario_event_cp_fsm__AUTHENTICATED__leave_ind_t;
-typedef scenario_empty_t scenario_event_cp_fsm__AUTHENTICATED__sleep_enter_cnf_t;
-typedef scenario_empty_t scenario_event_cp_fsm__SLEEP_AUTHENTICATED__no_beacons_t;
-typedef scenario_empty_t scenario_event_cp_fsm__SLEEP_AUTHENTICATED__sleep_exit_rsp_t;
-
-
-
-
-#endif /* inc_scenario_defs_h */
diff --git a/cesar/cp/eoc/sta/action/test/utest_eoc/src/actions.c b/cesar/cp/eoc/sta/action/test/utest_eoc/src/actions.c
deleted file mode 100644
index b8d344a32f..0000000000
--- a/cesar/cp/eoc/sta/action/test/utest_eoc/src/actions.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file src/actions.c
- * \brief Scenario actions.
- * \ingroup test
- */
-#include "common/std.h"
-
-#include "lib/scenario/scenario.h"
-
-#include "cp/inc/context.h"
-
-cp_fsm_event_t *
-scenario_action_make_event (cp_t *cp, scenario_action_event_param_t *ep)
-{
- cp_fsm_event_t *event;
- if (ep->mme)
- event = cp_fsm_event_mme_new (cp, ep->type, ep->mme);
- else if (ep->beacon)
- event = cp_fsm_event_beacon_new (cp, ep->type, ep->beacon, ep->net,
- ep->sta);
- else if (ep->sta)
- event = cp_fsm_event_sta_new (cp, ep->type, ep->net, ep->sta);
- else
- event = cp_fsm_event_bare_new (cp, ep->type);
- return event;
-}
-
-void
-scenario_action_post_and_process_cb (scenario_globals_t *globals,
- scenario_params_t *params)
-{
- test_within (scenario.t);
- scenario_action_post_and_process_t *p = &params->action_post_and_process;
- cp_fsm_post (globals->cp, scenario_action_make_event (globals->cp, p));
- test_fail_unless (globals->cp->sta_core_flag);
- globals->cp->sta_core_flag = false;
- cp_fsm_process (globals->cp);
-}
-
-void
-scenario_action_post_cb (scenario_globals_t *globals,
- scenario_params_t *params)
-{
- test_within (scenario.t);
- scenario_action_post_t *p = &params->action_post;
- cp_fsm_post (globals->cp, scenario_action_make_event (globals->cp, p));
- test_fail_unless (globals->cp->sta_core_flag);
-}
-
-void
-scenario_action_trigger_cb (scenario_globals_t *globals,
- scenario_params_t *params)
-{
- test_within (scenario.t);
- scenario_action_trigger_t *p = &params->action_trigger;
- cp_fsm_trigger (globals->cp, scenario_action_make_event (globals->cp, p));
- test_fail_unless (globals->cp->sta_core_flag);
-}
-
-void
-scenario_action_post_urgent_cb (scenario_globals_t *globals,
- scenario_params_t *params)
-{
- test_within (scenario.t);
- scenario_action_post_urgent_t *p = &params->action_post_urgent;
- cp_fsm_post_urgent (globals->cp,
- scenario_action_make_event (globals->cp, p));
- test_fail_unless (globals->cp->sta_core_urgent_flag);
-}
-
-void
-scenario_action_process_cb (scenario_globals_t *globals,
- scenario_params_t *params)
-{
- test_within (scenario.t);
- test_fail_unless (globals->cp->sta_core_flag);
- globals->cp->sta_core_flag = false;
- cp_fsm_process (globals->cp);
-}
-
-void
-scenario_action_process_urgent_cb (scenario_globals_t *globals,
- scenario_params_t *params)
-{
- test_within (scenario.t);
- test_fail_unless (globals->cp->sta_core_urgent_flag);
- globals->cp->sta_core_urgent_flag = false;
- cp_fsm_process_urgent (globals->cp);
-}
-
diff --git a/cesar/cp/eoc/sta/action/test/utest_eoc/src/fsm_stub.c b/cesar/cp/eoc/sta/action/test/utest_eoc/src/fsm_stub.c
deleted file mode 100644
index 09a41e948c..0000000000
--- a/cesar/cp/eoc/sta/action/test/utest_eoc/src/fsm_stub.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file src/fsm_stub.c
- * \brief Override FSM tables.
- * \ingroup test
- */
-#include "common/std.h"
-
-#include "lib/scenario/scenario.h"
-
-#include "cp/fsm/fsm.h"
-#include "cp/fsm/inc/tables.h"
-
-
-void
-cp_eoc_sta_action_assoc__detecting_detected (cp_t *ctx);
-
-void
-cp_eoc_sta_action_assoc__detecting_timeout (cp_t *ctx);
-
-void
-cp_eoc_sta_action_assoc__associating_timeout (cp_t *ctx);
-
-void
-cp_eoc_sta_action_assoc__associating_cnf (cp_t *ctx);
-
-void
-cp_eoc_sta_action_assoc__associating_no_beacons (cp_t *ctx);
-
-void
-cp_eoc_sta_action_sleep__unassociated_enter_sleep (cp_t *ctx);
-
-void
-cp_eoc_sta_action_assoc__unassociated_retry (cp_t *ctx);
-
-void
-cp_eoc_sta_action_sleep__sleep_unassociated_exit_sleep (cp_t *ctx);
-
-void
-cp_eoc_sta_action_assoc__associated_key_cnf (cp_t *ctx);
-
-void
-cp_eoc_sta_action_assoc__associated_encrypt_payload_rsp (cp_t *ctx);
-
-void
-cp_eoc_sta_action_assoc__associated_no_beacons (cp_t *ctx);
-
-void
-cp_eoc_sta_action_assoc__associated_timeout (cp_t *ctx);
-
-void
-cp_eoc_sta_action_assoc__associated_leave (cp_t *ctx);
-
-void
-cp_eoc_sta_action_sleep__authenticated_sleep_enter (cp_t *ctx);
-
-void
-cp_eoc_sta_action_assoc__authenticated_no_beacons (cp_t *ctx);
-
-void
-cp_eoc_sta_action_assoc__authenticated_leave (cp_t *ctx);
-
-void
-cp_eoc_sta_action_sleep__sleep_authenticated_exit (cp_t *ctx);
-
-void
-cp_eoc_sta_action_assoc__sleep_authenticated_no_beacons (cp_t *ctx);
-
-/* Include generated tables. */
-#include "cp_fsm_tables.h"
-
-void
-cp_eoc_sta_action_assoc__detecting_detected (cp_t *ctx)
-{
- scenario_event (cp_fsm__DETECTING_BEACON__nd_beacon);
-}
-
-void
-cp_eoc_sta_action_assoc__detecting_timeout (cp_t *ctx)
-{
- scenario_event (cp_fsm__DETECTING_BEACON__nd_beacon_timeout);
-}
-
-void
-cp_eoc_sta_action_assoc__associating_timeout (cp_t *ctx)
-{
- scenario_event (cp_fsm__ASSOCIATING__timeout_associating, param);
- cp_fsm_branch_ (ctx, param->branch);
-}
-
-void
-cp_eoc_sta_action_assoc__associating_cnf (cp_t *ctx)
-{
- scenario_event (cp_fsm__ASSOCIATING__assoc_cnf, param);
- cp_fsm_branch_ (ctx, param->branch);
-}
-
-void
-cp_eoc_sta_action_assoc__associating_no_beacons (cp_t *ctx)
-{
- scenario_event (cp_fsm__ASSOCIATING__no_beacons);
-}
-
-void
-cp_eoc_sta_action_sleep__unassociated_enter_sleep (cp_t *ctx)
-{
- scenario_event (cp_fsm__UNASSOCIATED__enter_sleep_unassociated);
-}
-
-void
-cp_eoc_sta_action_assoc__unassociated_retry (cp_t *ctx)
-{
- scenario_event (cp_fsm__UNASSOCIATED__retry_unassociated);
-}
-
-void
-cp_eoc_sta_action_sleep__sleep_unassociated_exit_sleep (cp_t *ctx)
-{
- scenario_event (cp_fsm__SLEEP_UNASSOCIATED__exit_sleep_unassociated);
-}
-
-void
-cp_eoc_sta_action_assoc__associated_key_cnf (cp_t *ctx)
-{
- scenario_event (cp_fsm__ASSOCIATED__get_key_cnf, param);
- cp_fsm_branch_ (ctx, param->branch);
-}
-
-void
-cp_eoc_sta_action_assoc__associated_encrypt_payload_rsp (cp_t *ctx)
-{
- scenario_event (cp_fsm__ASSOCIATED__encrypt_payload_rsp);
-}
-
-void
-cp_eoc_sta_action_assoc__associated_no_beacons (cp_t *ctx)
-{
- scenario_event (cp_fsm__ASSOCIATED__no_beacons);
-}
-
-void
-cp_eoc_sta_action_assoc__associated_timeout (cp_t *ctx)
-{
- scenario_event (cp_fsm__ASSOCIATED__timeout_authenticating);
-}
-
-void
-cp_eoc_sta_action_assoc__associated_leave (cp_t *ctx)
-{
- scenario_event (cp_fsm__ASSOCIATED__leave_ind);
-}
-
-void
-cp_eoc_sta_action_sleep__authenticated_sleep_enter (cp_t *ctx)
-{
- scenario_event (cp_fsm__AUTHENTICATED__sleep_enter_cnf);
-}
-
-void
-cp_eoc_sta_action_assoc__authenticated_no_beacons (cp_t *ctx)
-{
- scenario_event (cp_fsm__AUTHENTICATED__no_beacons);
-}
-
-void
-cp_eoc_sta_action_assoc__authenticated_leave (cp_t *ctx)
-{
- scenario_event (cp_fsm__AUTHENTICATED__leave_ind);
-}
-
-void
-cp_eoc_sta_action_sleep__sleep_authenticated_exit (cp_t *ctx)
-{
- scenario_event (cp_fsm__SLEEP_AUTHENTICATED__sleep_exit_rsp);
-}
-
-void
-cp_eoc_sta_action_assoc__sleep_authenticated_no_beacons (cp_t *ctx)
-{
- scenario_event (cp_fsm__SLEEP_AUTHENTICATED__no_beacons);
-}
-
diff --git a/cesar/cp/eoc/sta/action/test/utest_eoc/src/test_fsm.c b/cesar/cp/eoc/sta/action/test/utest_eoc/src/test_fsm.c
deleted file mode 100644
index 63707fbb6a..0000000000
--- a/cesar/cp/eoc/sta/action/test/utest_eoc/src/test_fsm.c
+++ /dev/null
@@ -1,426 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file src/test_fsm.c
- * \brief Test FSM module.
- * \ingroup test
- */
-#include "common/std.h"
-
-#include "lib/blk.h"
-#include "lib/test.h"
-#include "lib/scenario/scenario.h"
-
-#include "cp/fsm/fsm.h"
-
-#include "cp/inc/context.h"
-
-#include "cp/sta/core/core.h"
-
-void
-test_fsm_basic_test_case (test_t t)
-{
- test_case_begin (t, "basic");
- cp_t cp;
- cp.sta_core_urgent_flag = false;
- cp_trace_init (&cp);
- test_begin (t, "successuful authentication")
- {
- cp_fsm_init (&cp);
- cp.sta_core_flag = false;
- scenario_entry_t entries[] = {
- /* DETECTING_BEACON */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_nd_beacon),
- SCENARIO_EVENT (cp_fsm__DETECTING_BEACON__nd_beacon),
- /* ASSOCIATING*/
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_assoc_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATING__assoc_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATING, assoc_cnf, success)),
- /* ASSOCIATED */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_get_key_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATED__get_key_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATED, get_key_cnf, granted_more_to_grant)),
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_get_key_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATED__get_key_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATED, get_key_cnf, granted_more_to_grant)),
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_get_key_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATED__get_key_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATED, get_key_cnf, all_keys_granted)),
- /* AUTHENTICATED */
- SCENARIO_END
- };
- scenario_globals_t globals = {
- .cp = &cp,
- };
- scenario_run (t, entries, &globals);
- test_fail_unless (cp.fsm.active_states[0] == CP_FSM_STATE_AUTHENTICATED);
- cp_fsm_uninit (&cp);
- } test_end;
-
- test_begin (t, "bad association")
- {
- cp_fsm_init (&cp);
- cp.sta_core_flag = false;
- scenario_entry_t entries[] = {
- /* DETECTING_BEACON, beacon detected */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_nd_beacon),
- SCENARIO_EVENT (cp_fsm__DETECTING_BEACON__nd_beacon),
- /* ASSOCIATING, timeout, retry */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_timeout_associating),
- SCENARIO_EVENT (cp_fsm__ASSOCIATING__timeout_associating,
- .branch = CP_FSM_BRANCH (ASSOCIATING, timeout_associating, retry)),
-
- /* DETECTING_BEACON, beacon detected */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_nd_beacon),
- SCENARIO_EVENT (cp_fsm__DETECTING_BEACON__nd_beacon),
- /* ASSOCIATING, timeout, no retries*/
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_timeout_associating),
- SCENARIO_EVENT (cp_fsm__ASSOCIATING__timeout_associating,
- .branch = CP_FSM_BRANCH (ASSOCIATING, timeout_associating, no_retry)),
- /* UNASSOCIATED */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_enter_sleep_unassociated),
- SCENARIO_EVENT (cp_fsm__UNASSOCIATED__enter_sleep_unassociated),
- /* SLEEP_UNASSOCIATED */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_exit_sleep_unassociated),
- SCENARIO_EVENT (cp_fsm__SLEEP_UNASSOCIATED__exit_sleep_unassociated),
- /* UNASSOCIATED */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_retry_unassociated),
- SCENARIO_EVENT (cp_fsm__UNASSOCIATED__retry_unassociated),
-
- /* DETECTING_BEACON, beacon detected */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_nd_beacon),
- SCENARIO_EVENT (cp_fsm__DETECTING_BEACON__nd_beacon),
- /* ASSOCIATING, assoc_cnf, unrelated*/
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_assoc_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATING__assoc_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATING, assoc_cnf, unrelated)),
- /* UNASSOCIATED */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_retry_unassociated),
- SCENARIO_EVENT (cp_fsm__UNASSOCIATED__retry_unassociated),
-
- /* DETECTING_BEACON, beacon detected */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_nd_beacon),
- SCENARIO_EVENT (cp_fsm__DETECTING_BEACON__nd_beacon),
- /* ASSOCIATING, no beacons*/
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_no_beacons),
- SCENARIO_EVENT (cp_fsm__ASSOCIATING__no_beacons),
- /* UNASSOCIATED */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_retry_unassociated),
- SCENARIO_EVENT (cp_fsm__UNASSOCIATED__retry_unassociated),
-
- /* DETECTING_BEACON, beacon detected */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_nd_beacon),
- SCENARIO_EVENT (cp_fsm__DETECTING_BEACON__nd_beacon),
-
- /* ASSOCIATING, assoc_cnf, unsuccess*/
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_assoc_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATING__assoc_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATING, assoc_cnf, unsuccess)),
- /* UNASSOCIATED */
- SCENARIO_END
- };
- scenario_globals_t globals = {
- .cp = &cp,
- };
- scenario_run (t, entries, &globals);
- test_fail_unless (cp.fsm.active_states[0] == CP_FSM_STATE_UNASSOCIATED);
- cp_fsm_uninit (&cp);
- } test_end;
-
- test_begin (t, "associated")
- {
- cp_fsm_init (&cp);
- cp.sta_core_flag = false;
- scenario_entry_t entries[] = {
- /* DETECTING_BEACON */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_nd_beacon),
- SCENARIO_EVENT (cp_fsm__DETECTING_BEACON__nd_beacon),
- /* ASSOCIATING*/
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_assoc_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATING__assoc_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATING, assoc_cnf, success)),
- /* ASSOCIATED, get_key_cnf, unrelated */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_get_key_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATED__get_key_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATED, get_key_cnf, unrelated)),
- /* UNASSOCIATED */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_retry_unassociated),
- SCENARIO_EVENT (cp_fsm__UNASSOCIATED__retry_unassociated),
-
- /* DETECTING_BEACON */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_nd_beacon),
- SCENARIO_EVENT (cp_fsm__DETECTING_BEACON__nd_beacon),
- /* ASSOCIATING*/
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_assoc_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATING__assoc_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATING, assoc_cnf, success)),
- /* ASSOCIATED,get_key_cnf, not granted */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_get_key_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATED__get_key_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATED, get_key_cnf, not_granted)),
- /* UNASSOCIATED */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_retry_unassociated),
- SCENARIO_EVENT (cp_fsm__UNASSOCIATED__retry_unassociated),
-
- /* DETECTING_BEACON */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_nd_beacon),
- SCENARIO_EVENT (cp_fsm__DETECTING_BEACON__nd_beacon),
- /* ASSOCIATING*/
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_assoc_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATING__assoc_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATING, assoc_cnf, success)),
- /* ASSOCIATED, encrypt_payload */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_encrypt_payload_rsp),
- SCENARIO_EVENT (cp_fsm__ASSOCIATED__encrypt_payload_rsp),
- /* UNASSOCIATED */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_retry_unassociated),
- SCENARIO_EVENT (cp_fsm__UNASSOCIATED__retry_unassociated),
-
- /* DETECTING_BEACON */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_nd_beacon),
- SCENARIO_EVENT (cp_fsm__DETECTING_BEACON__nd_beacon),
- /* ASSOCIATING*/
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_assoc_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATING__assoc_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATING, assoc_cnf, success)),
- /* ASSOCIATED, no beacons */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_no_beacons),
- SCENARIO_EVENT (cp_fsm__ASSOCIATED__no_beacons),
- /* UNASSOCIATED */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_retry_unassociated),
- SCENARIO_EVENT (cp_fsm__UNASSOCIATED__retry_unassociated),
-
- /* DETECTING_BEACON */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_nd_beacon),
- SCENARIO_EVENT (cp_fsm__DETECTING_BEACON__nd_beacon),
- /* ASSOCIATING*/
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_assoc_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATING__assoc_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATING, assoc_cnf, success)),
- /* ASSOCIATED, leave */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_leave_ind),
- SCENARIO_EVENT (cp_fsm__ASSOCIATED__leave_ind),
-
- /* DETECTING_BEACON */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_nd_beacon),
- SCENARIO_EVENT (cp_fsm__DETECTING_BEACON__nd_beacon),
- /* ASSOCIATING*/
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_assoc_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATING__assoc_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATING, assoc_cnf, success)),
- /* ASSOCIATED, timeout_authenticating */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_timeout_authenticating),
- SCENARIO_EVENT (cp_fsm__ASSOCIATED__timeout_authenticating),
- /* UNASSOCIATED */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_retry_unassociated),
- SCENARIO_EVENT (cp_fsm__UNASSOCIATED__retry_unassociated),
-
- /* DETECTING_BEACON */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_nd_beacon),
- SCENARIO_EVENT (cp_fsm__DETECTING_BEACON__nd_beacon),
- /* ASSOCIATING*/
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_assoc_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATING__assoc_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATING, assoc_cnf, success)),
- /* ASSOCIATED, get_key */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_get_key_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATED__get_key_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATED, get_key_cnf, granted_more_to_grant)),
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_get_key_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATED__get_key_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATED, get_key_cnf, all_keys_granted)),
- /* AUTHENTICATED */
- SCENARIO_END
- };
- scenario_globals_t globals = {
- .cp = &cp,
- };
- scenario_run (t, entries, &globals);
- test_fail_unless (cp.fsm.active_states[0] == CP_FSM_STATE_AUTHENTICATED);
- cp_fsm_uninit (&cp);
- } test_end;
-
- test_begin (t, "authenticated")
- {
- cp_fsm_init (&cp);
- cp.sta_core_flag = false;
- scenario_entry_t entries[] = {
- /* DETECTING_BEACON */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_nd_beacon),
- SCENARIO_EVENT (cp_fsm__DETECTING_BEACON__nd_beacon),
- /* ASSOCIATING*/
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_assoc_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATING__assoc_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATING, assoc_cnf, success)),
- /* ASSOCIATED */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_get_key_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATED__get_key_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATED, get_key_cnf, all_keys_granted)),
- /* AUTHENTICATED, sleep */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_sleep_enter_cnf),
- SCENARIO_EVENT (cp_fsm__AUTHENTICATED__sleep_enter_cnf),
- /* SLEEP_AUTHENTICATED, exit sleep */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_sleep_exit_rsp),
- SCENARIO_EVENT (cp_fsm__SLEEP_AUTHENTICATED__sleep_exit_rsp),
- /* AUTHENTICATED, sleep */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_sleep_enter_cnf),
- SCENARIO_EVENT (cp_fsm__AUTHENTICATED__sleep_enter_cnf),
- /* SLEEP_AUTHENTICATED, no beacons */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_no_beacons),
- SCENARIO_EVENT (cp_fsm__SLEEP_AUTHENTICATED__no_beacons),
- /* UNASSOCIATED */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_retry_unassociated),
- SCENARIO_EVENT (cp_fsm__UNASSOCIATED__retry_unassociated),
-
- /* DETECTING_BEACON */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_nd_beacon),
- SCENARIO_EVENT (cp_fsm__DETECTING_BEACON__nd_beacon),
- /* ASSOCIATING*/
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_assoc_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATING__assoc_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATING, assoc_cnf, success)),
- /* ASSOCIATED */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_get_key_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATED__get_key_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATED, get_key_cnf, all_keys_granted)),
- /* AUTHENTICATED, no beacons */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_no_beacons),
- SCENARIO_EVENT (cp_fsm__AUTHENTICATED__no_beacons),
- /* UNASSOCIATED */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_retry_unassociated),
- SCENARIO_EVENT (cp_fsm__UNASSOCIATED__retry_unassociated),
-
- /* DETECTING_BEACON */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_nd_beacon),
- SCENARIO_EVENT (cp_fsm__DETECTING_BEACON__nd_beacon),
- /* ASSOCIATING*/
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_assoc_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATING__assoc_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATING, assoc_cnf, success)),
- /* ASSOCIATED */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_get_key_cnf),
- SCENARIO_EVENT (cp_fsm__ASSOCIATED__get_key_cnf,
- .branch = CP_FSM_BRANCH (ASSOCIATED, get_key_cnf, all_keys_granted)),
- /* AUTHENTICATED, leave */
- SCENARIO_ACTION (post_and_process,
- .type = CP_FSM_EVENT_TYPE_leave_ind),
- SCENARIO_EVENT (cp_fsm__AUTHENTICATED__leave_ind),
-
- SCENARIO_END
- };
- scenario_globals_t globals = {
- .cp = &cp,
- };
- scenario_run (t, entries, &globals);
- test_fail_unless (cp.fsm.active_states[0] == CP_FSM_STATE_DETECTING_BEACON);
- cp_fsm_uninit (&cp);
- } test_end;
-
-#if CONFIG_TRACE
- trace_buffer_dbg_dump (&cp.trace);
-#endif /* CONFIG_TRACE */
- cp_trace_uninit (&cp);
-}
-
-
-void
-test_fsm_test_suite (test_t t)
-{
- test_suite_begin (t, "fsm");
- test_fsm_basic_test_case (t);
-}
-
-void
-cp_sta_core_signal_fsm_event (cp_t *ctx)
-{
- dbg_assert (ctx);
- ctx->sta_core_flag = true;
-}
-
-void
-cp_sta_core_signal_fsm_urgent_event (cp_t *ctx)
-{
- dbg_assert (ctx);
- ctx->sta_core_urgent_flag = true;
-}
-
-int
-main (int argc, char **argv)
-{
- test_t t;
- trace_init ();
- test_init (t, argc, argv);
- test_fsm_test_suite (t);
- trace_uninit ();
- test_result (t);
- return test_nb_failed (t) == 0 ? 0 : 1;
-}
-