summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorMilenko Jelisavcic2012-05-15 16:15:25 +0200
committerMilenko Jelisavcic2012-06-04 11:52:22 +0200
commit1ea0d08864c25a3c03ff7f542fbb12e489caf8f4 (patch)
tree6481065fe66cec19d305c9f94f24f7f7dd8f05e2 /cesar
parent4af4add3d97a90f8901c2bf9e760532b22c53aac (diff)
cesar/cp/eoc/sta/action/test/utest[eoc]: fix fsm & action test
Diffstat (limited to 'cesar')
-rw-r--r--cesar/cp/eoc/sta/action/test/utest/Makefile1
-rw-r--r--cesar/cp/eoc/sta/action/test/utest/actions-Config2
-rw-r--r--cesar/cp/eoc/sta/action/test/utest/actions-override/cp/sta/core/core.h2
-rw-r--r--cesar/cp/eoc/sta/action/test/utest/fsm-Makefile2
-rw-r--r--cesar/cp/eoc/sta/action/test/utest/inc/scenario_defs.h3
-rw-r--r--cesar/cp/eoc/sta/action/test/utest/src/cl_interf_stub.c2
-rw-r--r--cesar/cp/eoc/sta/action/test/utest/src/cp_stub.c11
-rw-r--r--cesar/cp/eoc/sta/action/test/utest/src/fsm_stub.c319
-rw-r--r--cesar/cp/eoc/sta/action/test/utest/src/test_actions.c1050
-rw-r--r--cesar/cp/eoc/sta/action/test/utest/src/test_fsm.c14
10 files changed, 546 insertions, 860 deletions
diff --git a/cesar/cp/eoc/sta/action/test/utest/Makefile b/cesar/cp/eoc/sta/action/test/utest/Makefile
index bdfdaf2d37..b238673cdd 100644
--- a/cesar/cp/eoc/sta/action/test/utest/Makefile
+++ b/cesar/cp/eoc/sta/action/test/utest/Makefile
@@ -9,3 +9,4 @@ actions: actions-Makefile
clean: fsm-Makefile actions-Makefile
make -f fsm-Makefile clean
make -f actions-Makefile clean
+ rmdir obj
diff --git a/cesar/cp/eoc/sta/action/test/utest/actions-Config b/cesar/cp/eoc/sta/action/test/utest/actions-Config
index 1b2a998b9b..5c3b6a0b7d 100644
--- a/cesar/cp/eoc/sta/action/test/utest/actions-Config
+++ b/cesar/cp/eoc/sta/action/test/utest/actions-Config
@@ -9,3 +9,5 @@ CONFIG_MAC_COMMON_EOC_TONEMASK = y
CONFIG_CP_EOC_STA_CON_ALLOWED = n
CONFIG_MAC_COMMON_EOC_SCHED = y
CONFIG_MAC_COMMON_EOC_TEI = y
+CONFIG_RESTRACK = y
+CONFIG_MAC_COMMON_EOC_MFS = y
diff --git a/cesar/cp/eoc/sta/action/test/utest/actions-override/cp/sta/core/core.h b/cesar/cp/eoc/sta/action/test/utest/actions-override/cp/sta/core/core.h
index 837703a9b5..a4d6eda352 100644
--- a/cesar/cp/eoc/sta/action/test/utest/actions-override/cp/sta/core/core.h
+++ b/cesar/cp/eoc/sta/action/test/utest/actions-override/cp/sta/core/core.h
@@ -44,6 +44,8 @@ cp_sta_core_stop_timed_or_cyclic_event(
int
cp_sta_core_ms_to_cyg_tick (cp_t *ctx, const uint ms);
+u32
+cp_sta_core_tck_per_rtc (cp_t *ctx);
END_DECLS
#endif /* override_cp_sta_core_core_h */
diff --git a/cesar/cp/eoc/sta/action/test/utest/fsm-Makefile b/cesar/cp/eoc/sta/action/test/utest/fsm-Makefile
index 0ac9bf0f2f..2e5df34c1a 100644
--- a/cesar/cp/eoc/sta/action/test/utest/fsm-Makefile
+++ b/cesar/cp/eoc/sta/action/test/utest/fsm-Makefile
@@ -7,7 +7,7 @@ INCLUDES = cp/eoc/sta/action/test/utest \
HOST_PROGRAMS = test_fsm
-test_fsm_SOURCES = test_fsm.c actions.c
+test_fsm_SOURCES = test_fsm.c actions.c fsm_stub.c
test_fsm_MODULES = lib lib/scenario cp/eoc/fsm mac/sar/stub \
cp/eoc/sta/action/stub cp/eoc/beacon/stub ce/tx/stub
diff --git a/cesar/cp/eoc/sta/action/test/utest/inc/scenario_defs.h b/cesar/cp/eoc/sta/action/test/utest/inc/scenario_defs.h
index 8c3dca7d82..2a0b4c520f 100644
--- a/cesar/cp/eoc/sta/action/test/utest/inc/scenario_defs.h
+++ b/cesar/cp/eoc/sta/action/test/utest/inc/scenario_defs.h
@@ -152,15 +152,12 @@ scenario_action_process_urgent_cb (scenario_globals_t *globals,
cp_fsm__AUTHENTICATED__no_beacons, \
cp_fsm__AUTHENTICATED__BEACON, \
cp_fsm__AUTHENTICATED__CC_LEAVE_IND, \
- cp_fsm__AUTHENTICATED__sleep_enter_cnf, \
cp_fsm__AUTHENTICATED__drv__started__drv_sta_mac_stop_req,\
cp_fsm__AUTHENTICATED__process_cm_brg_info_req,\
cp_fsm__AUTHENTICATED__process_cm_brg_info_cnf,\
cp_fsm__AUTHENTICATED__CM_SET_KEY_REQ,\
cp_fsm__AUTHENTICATED__CM_NW_STATS_REQ,\
cp_fsm__AUTHENTICATED__set_out_lev_ind,\
- cp_fsm__SLEEP_AUTHENTICATED__no_beacons, \
- cp_fsm__SLEEP_AUTHENTICATED__sleep_exit_rsp,\
cp_fsm__CCO__bridge_first_com,\
cp_msg_vs_get_tonemap_req_receive, \
cp_msg_vs_get_tonemap_cnf_send, \
diff --git a/cesar/cp/eoc/sta/action/test/utest/src/cl_interf_stub.c b/cesar/cp/eoc/sta/action/test/utest/src/cl_interf_stub.c
index 48c4240092..910786a8a5 100644
--- a/cesar/cp/eoc/sta/action/test/utest/src/cl_interf_stub.c
+++ b/cesar/cp/eoc/sta/action/test/utest/src/cl_interf_stub.c
@@ -16,7 +16,7 @@
#include "cp/cp.h"
#include "cp/mme.h"
-static u8 buffer[2048] __attribute__((aligned(2048)));
+static u8 buffer[2048];
u8 *
cp_cl_interf_get_buffer_tx (cp_t *ctx)
diff --git a/cesar/cp/eoc/sta/action/test/utest/src/cp_stub.c b/cesar/cp/eoc/sta/action/test/utest/src/cp_stub.c
index 0b82956cb9..00f335e35a 100644
--- a/cesar/cp/eoc/sta/action/test/utest/src/cp_stub.c
+++ b/cesar/cp/eoc/sta/action/test/utest/src/cp_stub.c
@@ -15,6 +15,8 @@
#include "cp/cp.h"
#include "cp/mme.h"
#include "cp/inc/context.h"
+#include "cp/sta/core/core.h"
+#include "cp/sta/core/defs.h"
/**
* Compute the NID and the NMK from the network password.
@@ -45,3 +47,12 @@ cp_compute_nmk_and_nid_from_npw (cp_t *ctx, const char *npw,
cp_sta_own_data_set_nmk (ctx, nmk, 0);
cp_sta_own_data_set_nid (ctx, nid);
}
+
+void
+cp_sta_core_gen_timed_event(cp_t *cp_ctx,
+ cp_sta_core_timed_event_def_t *sta_core_timed_event,
+ cp_fsm_event_t *fsm_event,
+ uint event_delay_ms)
+{
+ slab_release (fsm_event);
+}
diff --git a/cesar/cp/eoc/sta/action/test/utest/src/fsm_stub.c b/cesar/cp/eoc/sta/action/test/utest/src/fsm_stub.c
index f17e27ea0b..1aebf97520 100644
--- a/cesar/cp/eoc/sta/action/test/utest/src/fsm_stub.c
+++ b/cesar/cp/eoc/sta/action/test/utest/src/fsm_stub.c
@@ -13,221 +13,15 @@
#include "common/std.h"
#include "lib/scenario/scenario.h"
+#include "cp/eoc/sta/action/assoc_slave.h"
+#include "cp/eoc/sta/action/drv.h"
+#include "cp/eoc/sta/action/vs.h"
+#include "cp/eoc/sta/action/poweron.h"
#include "cp/fsm/fsm.h"
#include "cp/fsm/inc/tables.h"
void
-cp_eoc_sta_action_auth__authenticated_key_cnf(cp_t *ctx);
-
-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_assoc__unassociated_retry (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_assoc__authenticated_no_beacons (cp_t *ctx);
-
-void
-cp_eoc_sta_action_assoc__authenticated_leave (cp_t *ctx);
-
-void
-cp_eoc_sta_action_assoc__beacon_received (cp_t *ctx);
-
-void
-cp_eoc_sta_action_assoc__beacon_not_received (cp_t *ctx);
-
-void
-cp_sta_action_drv__stopped__drv_sta_set_mac_addr_req (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-void
-cp_sta_action_drv__stopped__drv_sta_set_cco_pref_req (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-void
-cp_sta_action_drv__stopped__drv_sta_set_was_cco_req (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-void
-cp_sta_action_drv__stopped__drv_sta_set_dpw_req (cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-cp_sta_action_drv__stopped__drv_sta_set_nid_req (cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-cp_sta_action_drv__stopped__drv_sta_set_tonemask_req (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-void
-cp_sta_action_drv__stopped__drv_sta_set_key_req (cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-cp_sta_action_drv__stopped__drv_sta_set_dak_req (cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-cp_sta_action_drv__stopped__drv_sta_mac_start_req (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-void
-cp_beacon_beacon_not_received (cp_t *ctx);
-
-void
-ce_tx_process__cm_chan_est_ind (cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-ce_tx_process__cm_update_tm_ind (cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-cp_sta_action_process_cm_brg_info_req (cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-cp_sta_action_process_cm_brg_info_cnf (cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-cp_eoc_sta_action_unassoc__start_retry_timer (cp_t *ctx);
-
-void
-cp_sta_action_assoc__start_retry_timer (cp_t *ctx);
-
-void
-cp_eoc_sta_action_unassoc__stop_retry_timer (cp_t *ctx);
-
-void
-cp_sta_action_assoc__stop_retry_timer (cp_t *ctx);
-
-void
-cp_sta_action_drv__stopped__drv_sta_set_npw_req (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-void
-cp_sta_action_drv__stopped__drv_sta_set_sl_req (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-void
-cp_sta_action_drv__stopped__drv_sta_set_m_sta_hfid_req (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-void
-cp_sta_action_drv__stopped__drv_sta_set_u_sta_hfid_req (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-void
-cp_sta_action_drv__stopped__drv_sta_set_avln_hfid_req (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-void
-cp_sta_action_drv__started__drv_sta_mac_stop_req (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-void
-cp_sta_action_drv__stopping__stopped (cp_t *ctx);
-
-void
-cp_sta_action_bridge_first_com (cp_t *ctx, cp_net_t *net, cp_sta_t *sta);
-
-void
-cp_sta_action_poweron__many__to_idle (cp_t *ctx);
-
-void
-cp_sta_action_vs__started__vs_get_tonemap_req (cp_t *ctx,
- cp_mme_rx_t *mme_rx);
-
-void
-cp_eoc_sta_action_auth__beacon_received (cp_t *ctx, bsu_beacon_t *beacon,
- cp_net_t *net, cp_sta_t *sta);
-
-void
-cp_eoc_sta_action_auth__authenticated_set_key_req (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-void
-cp_sta_action_drv__drv_sta_set_config_req (cp_t *ctx, cp_mme_rx_t *mme_rx);
-
-void
-cp_eoc_sta_action_auth__authenticated_set_out_lev(cp_t *ctx,
- cp_mme_rx_t *mme);
-
-void
-cp_sta_action_process_cm_sta_cap_req (cp_t *ctx, cp_mme_rx_t *rx_mme);
-
-void
-cp_sta_action_vs__started__vs_get_snr_req (cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-cp_sta_action_vs__started__vs_get_stats_req (cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-cp_sta_action_process_cm_nw_info_req (cp_t *ctx, cp_mme_rx_t *rx_mme);
-
-void
-cp_sta_action_process_cm_nw_stats_req (cp_t *ctx, cp_mme_rx_t *rx_mme);
-
-void
-cp_sta_action_process_cm_link_stats_req (cp_t *ctx, cp_mme_rx_t *rx_mme);
-
-void
-cp_eoc_sta_action_drv__drv_sta_set_slave_config_req (cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-cp_eoc_sta_action_drv__drv_sta_set_eoc_config_req (cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-cp_eoc_sta_action_detect__beacon_received (cp_t *ctx, bsu_beacon_t *beacon,
- cp_net_t *net, cp_sta_t *sta);
-
-void
-cp_eoc_sta_action_vs__vs_eoc_get_info_req (cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-cp_eoc_sta_action_vs__vs_eoc_diagnostic_info_req (
- cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-cp_eoc_sta_action_vs__vs_eoc_get_real_time_statistics_req (
- cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-cp_sta_action_vs__started__vs_get_ce_stats_req (cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-cp_sta_action_vs__started__vs_get_pb_stats_req (cp_t *ctx, cp_mme_rx_t *mme);
-
-void
-cp_sta_action_vs__started__vs_get_mactotei_req (cp_t *ctx, cp_mme_rx_t *mme);
-
-/* Include generated tables. */
-#include "cp_fsm_tables.h"
-
-void
cp_sta_action_drv__drv_sta_set_config_req (cp_t *ctx, cp_mme_rx_t *mme_rx)
{
scenario_event (cp_sta_action_drv__drv_sta_set_config_req);
@@ -240,11 +34,6 @@ cp_eoc_sta_action_auth__authenticated_set_out_lev(cp_t *ctx, cp_mme_rx_t *mme)
}
void
-cp_sta_action_process_cm_sta_cap_req (cp_t *ctx, cp_mme_rx_t *rx_mme)
-{
-}
-
-void
cp_sta_action_drv__stopped__drv_sta_set_mac_addr_req (cp_t *ctx,
cp_mme_rx_t *mme)
{
@@ -278,14 +67,14 @@ cp_sta_action_drv__stopped__drv_sta_set_nid_req (cp_t *ctx, cp_mme_rx_t *mme)
}
void
-cp_sta_action_drv__stopped__drv_sta_set_tonemask_req (cp_t *ctx,
+cp_eoc_sta_action_drv__stopped__drv_sta_set_tonemask_req (cp_t *ctx,
cp_mme_rx_t *mme)
{
scenario_event (cp_fsm__STOPPED__drv_sta_set_tonemask_req);
}
void
-cp_sta_action_drv__stopped__drv_sta_set_key_req (cp_t *ctx, cp_mme_rx_t *mme)
+cp_eoc_sta_action_drv__stopped__drv_sta_set_key_req (cp_t *ctx, cp_mme_rx_t *mme)
{
scenario_event (cp_fsm__STOPPED__drv_sta_set_key_req);
}
@@ -329,7 +118,7 @@ cp_eoc_sta_action_assoc__associating_timeout (cp_t *ctx)
}
void
-cp_eoc_sta_action_assoc__associating_cnf (cp_t *ctx)
+cp_eoc_sta_action_assoc__associating_cnf (cp_t *ctx, cp_mme_rx_t *mme)
{
scenario_event (cp_fsm__ASSOCIATING__CC_ASSOC_CNF, param);
cp_fsm_branch_ (ctx, param->branch);
@@ -348,14 +137,15 @@ cp_eoc_sta_action_assoc__unassociated_retry (cp_t *ctx)
}
void
-cp_eoc_sta_action_assoc__associated_key_cnf (cp_t *ctx)
+cp_eoc_sta_action_assoc__associated_key_cnf (cp_t *ctx, cp_mme_rx_t *mme)
{
scenario_event (cp_fsm__ASSOCIATED__CM_GET_KEY_CNF, param);
cp_fsm_branch_ (ctx, param->branch);
}
void
-cp_eoc_sta_action_assoc__associated_encrypt_payload_rsp (cp_t *ctx)
+cp_eoc_sta_action_assoc__associated_encrypt_payload_rsp (cp_t *ctx,
+ cp_mme_rx_t *mme)
{
scenario_event (cp_fsm__ASSOCIATED__encrypt_payload_rsp);
}
@@ -373,7 +163,7 @@ cp_eoc_sta_action_assoc__associated_timeout (cp_t *ctx)
}
void
-cp_eoc_sta_action_assoc__associated_leave (cp_t *ctx)
+cp_eoc_sta_action_assoc__associated_leave (cp_t *ctx, cp_mme_rx_t *mme)
{
scenario_event (cp_fsm__ASSOCIATED__CC_LEAVE_IND, param);
cp_fsm_branch_ (ctx, param->branch);
@@ -386,19 +176,13 @@ cp_eoc_sta_action_assoc__authenticated_no_beacons (cp_t *ctx)
}
void
-cp_eoc_sta_action_assoc__authenticated_leave (cp_t *ctx)
+cp_eoc_sta_action_assoc__authenticated_leave (cp_t *ctx, cp_mme_rx_t *mme)
{
scenario_event (cp_fsm__AUTHENTICATED__CC_LEAVE_IND, param);
cp_fsm_branch_ (ctx, param->branch);
}
void
-cp_eoc_sta_action_assoc__beacon_received (cp_t *ctx)
-{
-
-}
-
-void
cp_eoc_sta_action_assoc__beacon_not_received (cp_t *ctx)
{
scenario_event (cp_fsm__DETECTING_BEACON__BEACON_NOT_RECEIVED);
@@ -423,7 +207,7 @@ cp_eoc_sta_action_unassoc__start_retry_timer (cp_t *ctx)
}
void
-cp_sta_action_assoc__start_retry_timer (cp_t *ctx)
+cp_eoc_sta_action_assoc__start_retry_timer (cp_t *ctx)
{
scenario_event (cp_fsm__ASSOCIATING__start_retry_timer);
}
@@ -480,14 +264,15 @@ cp_sta_action_bridge_first_com (cp_t *ctx, cp_net_t *net, cp_sta_t *sta)
}
void
-cp_eoc_sta_action_auth__authenticated_key_cnf(cp_t *ctx)
+cp_eoc_sta_action_poweron__many__to_idle (cp_t *ctx)
{
+ scenario_event (cp_fsm__STOPPING__poweron__many__to_idle);
}
void
-cp_sta_action_poweron__many__to_idle (cp_t *ctx)
+cp_eoc_sta_action_poweron__idle__to_poweron (cp_t *ctx)
{
- scenario_event (cp_fsm__STOPPING__poweron__many__to_idle);
+ scenario_event (cp_fsm__STARTED__poweron__idle__to_poweron);
}
void
@@ -517,11 +302,6 @@ cp_sta_action_process_cm_brg_info_cnf (cp_t *ctx, cp_mme_rx_t *mme)
}
void
-cp_sta_action_vs__started__vs_get_tonemap_req (cp_t *ctx, cp_mme_rx_t *mme_rx)
-{
-}
-
-void
cp_eoc_sta_action_auth__beacon_received (cp_t *ctx, bsu_beacon_t *beacon,
cp_net_t *net, cp_sta_t *sta)
{
@@ -529,25 +309,23 @@ cp_eoc_sta_action_auth__beacon_received (cp_t *ctx, bsu_beacon_t *beacon,
}
void
-cp_eoc_sta_action_auth__authenticated_set_key_req (cp_t *ctx,
- cp_mme_rx_t *mme)
-{
- scenario_event (cp_fsm__AUTHENTICATED__CM_SET_KEY_REQ);
-}
-
-void
-cp_sta_action_vs__started__vs_get_snr_req (cp_t *ctx, cp_mme_rx_t *mme)
+cp_eoc_sta_action_assoc__unassoc_no_beacons (cp_t *ctx)
{
+ scenario_event (cp_fsm__UNASSOCIATED__no_beacons);
}
void
-cp_sta_action_vs__started__vs_get_stats_req (cp_t *ctx, cp_mme_rx_t *mme)
+cp_eoc_sta_action_unassoc__beacon_received (cp_t *ctx, bsu_beacon_t *beacon,
+ cp_net_t *net, cp_sta_t *sta)
{
+ scenario_event (cp_fsm__UNASSOCIATED__BEACON);
}
void
-cp_sta_action_process_cm_nw_info_req (cp_t *ctx, cp_mme_rx_t *rx_mme)
+cp_eoc_sta_action_auth__authenticated_set_key_req (cp_t *ctx,
+ cp_mme_rx_t *mme)
{
+ scenario_event (cp_fsm__AUTHENTICATED__CM_SET_KEY_REQ);
}
void
@@ -557,53 +335,8 @@ cp_sta_action_process_cm_nw_stats_req (cp_t *ctx, cp_mme_rx_t *rx_mme)
}
void
-cp_sta_action_process_cm_link_stats_req (cp_t *ctx, cp_mme_rx_t *rx_mme)
-{
-}
-
-void
-cp_eoc_sta_action_drv__drv_sta_set_slave_config_req (cp_t *ctx, cp_mme_rx_t *mme)
-{
-}
-
-void
-cp_eoc_sta_action_drv__drv_sta_set_eoc_config_req (cp_t *ctx, cp_mme_rx_t *mme)
-{
-}
-
-void
cp_eoc_sta_action_detect__beacon_received (cp_t *ctx, bsu_beacon_t *beacon,
cp_net_t *net, cp_sta_t *sta)
{
-scenario_event (cp_fsm__DETECTING_BEACON__BEACON);
-}
-
-void
-cp_eoc_sta_action_vs__vs_eoc_get_info_req (cp_t *ctx, cp_mme_rx_t *mme)
-{}
-
-void
-cp_eoc_sta_action_vs__vs_eoc_diagnostic_info_req (
- cp_t *ctx, cp_mme_rx_t *mme)
-{}
-
-void
-cp_eoc_sta_action_vs__vs_eoc_get_real_time_statistics_req (
- cp_t *ctx, cp_mme_rx_t *mme)
-{
-}
-
-void
-cp_sta_action_vs__started__vs_get_ce_stats_req (cp_t *ctx, cp_mme_rx_t *mme)
-{
-}
-
-void
-cp_sta_action_vs__started__vs_get_pb_stats_req (cp_t *ctx, cp_mme_rx_t *mme)
-{
-}
-
-void
-cp_sta_action_vs__started__vs_get_mactotei_req (cp_t *ctx, cp_mme_rx_t *mme)
-{
+ scenario_event (cp_fsm__DETECTING_BEACON__BEACON);
}
diff --git a/cesar/cp/eoc/sta/action/test/utest/src/test_actions.c b/cesar/cp/eoc/sta/action/test/utest/src/test_actions.c
index acc818c504..ac78fbc93f 100644
--- a/cesar/cp/eoc/sta/action/test/utest/src/test_actions.c
+++ b/cesar/cp/eoc/sta/action/test/utest/src/test_actions.c
@@ -31,6 +31,67 @@
#include "cp/eoc/sta/action/action.h"
#include "cp/sta/action/assoc.h"
+void
+cp_test_init (cp_t * ctx)
+{
+ static pbproc_t pbproc;
+ static mac_config_t mac_config;
+ static cl_t cl;
+ static sar_t sar;
+
+ memset (ctx, 0, sizeof (cp_t));
+ memset (&mac_config, 0, sizeof (mac_config_t));
+ memset (&sar, 0, sizeof (sar));
+ memset (&pbproc, 0, sizeof (pbproc));
+
+ ctx->mac_config = &mac_config;
+ ctx->sar = &sar;
+ ctx->cl = &cl;
+ ctx->pbproc = &pbproc;
+
+ ctx->mac_store = mac_store_init ();
+ mac_config_init (ctx->mac_config);
+ lib_stats_init ();
+ cp_msg_init(ctx);
+ cp_cl_interf_init (ctx);
+ lib_rnd_init (&ctx->rnd, 1234);
+ cp_eoc_sta_mgr_init (ctx);
+ cp_fsm_init (ctx);
+}
+
+void
+cp_test_uninit (cp_t * ctx)
+{
+ ctx->fsm.handled_event = NULL;
+ mac_store_uninit (ctx->mac_store);
+ cp_msg_uninit (ctx);
+ cp_fsm_uninit (ctx);
+ lib_stats_uninit ();
+}
+
+void
+cp_eoc_cco_action_test_release_mac_store (cp_t *ctx)
+{
+ uint tei;
+ for (tei = MAC_TEI_STA_MIN_EOC; tei < MAC_TEI_STA_MAX; tei++)
+ {
+ mfs_t *mfs;
+ mfs = mac_store_mfs_get (ctx->mac_store, true, false, false,
+ MAC_LLID_MIN, tei);
+ if (mfs)
+ {
+ mac_store_mfs_remove (ctx->mac_store, mfs);
+ blk_release (mfs);
+ }
+ mfs = mac_store_mfs_get (ctx->mac_store, true, false, true,
+ MAC_LID_NONE, tei);
+ if (mfs)
+ {
+ mac_store_mfs_remove (ctx->mac_store, mfs);
+ blk_release (mfs);
+ }
+ }
+}
void
test_case_association_and_authentication_action (test_t test)
@@ -40,8 +101,6 @@ test_case_association_and_authentication_action (test_t test)
test_begin (test, "Receiving and processing DRV_STA_SET_MAC_ADDR_REQ")
{
cp_t ctx;
- mac_config_t mac_config;
-
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
@@ -49,16 +108,14 @@ test_case_association_and_authentication_action (test_t test)
u64 data;
u8 buffer[1024];
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- cp_cl_interf_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
-
+ cp_test_init (&ctx);
+ memset (mme, 0, sizeof (*mme));
mme->mmtype = DRV_STA_SET_MAC_ADDR_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
//Mac address
data = 0x3;
@@ -75,13 +132,14 @@ test_case_association_and_authentication_action (test_t test)
test_fail_unless (ctx.sta_mgr.sta_own_data.mac_addr == mme->peer.mac);
test_fail_unless (ctx.mac_config->sta_mac_address == mme->peer.mac);
+
+ cp_test_uninit (&ctx);
}
test_end;
test_begin (test, "Receiving and processing DRV_STA_SET_CCO_PREF_REQ")
{
cp_t ctx;
- mac_config_t mac_config;
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
@@ -90,20 +148,18 @@ test_case_association_and_authentication_action (test_t test)
u8 cco_pref;
u8 buffer[1024];
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- cp_cl_interf_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
-
+ cp_test_init (&ctx);
+ memset (mme, 0, sizeof (*mme));
mme->mmtype = DRV_STA_SET_CCO_PREF_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
- // 0x01 means that the staion is prefered as CCO
- // 0x00 means that the station is not prefered as CCO
+ /* 0x01 means that the staion is prefered as CCO
+ * 0x00 means that the station is not prefered as CCO. */
cco_pref = 0x1;
bitstream_access(&bitstream, &cco_pref, 8);
@@ -115,13 +171,13 @@ test_case_association_and_authentication_action (test_t test)
cp_sta_own_data_t *own = cp_sta_mgr_get_sta_own_data (&ctx);
test_fail_unless (own->cco_prefered == cco_pref);
+ cp_test_uninit (&ctx);
}
test_end;
test_begin (test, "Receiving and processing DRV_STA_SET_WAS_CCO_REQ")
{
cp_t ctx;
- mac_config_t mac_config;
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
@@ -130,20 +186,18 @@ test_case_association_and_authentication_action (test_t test)
u8 was_cco;
u8 buffer[1024];
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- cp_cl_interf_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
-
+ cp_test_init (&ctx);
+ memset (mme, 0, sizeof (*mme));
mme->mmtype = DRV_STA_SET_WAS_CCO_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
- // 0x01 means that the staion was a CCO prviously
- // 0x00 means that the station was not a CCO previously
+ /* 0x01 means that the staion was a CCO prviously
+ * 0x00 means that the station was not a CCO previously. */
was_cco = 0x1;
bitstream_access(&bitstream, &was_cco, 8);
@@ -154,13 +208,13 @@ test_case_association_and_authentication_action (test_t test)
cp_sta_action_drv__stopped__drv_sta_set_was_cco_req (&ctx, mme);
test_fail_unless (ctx.sta_mgr.sta_own_data.was_cco == was_cco);
+ cp_test_uninit (&ctx);
}
test_end;
test_begin (test, "Receiving and processing DRV_STA_SET_NPW_REQ")
{
cp_t ctx;
- mac_config_t mac_config;
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
uint i;
@@ -168,47 +222,42 @@ test_case_association_and_authentication_action (test_t test)
u8 buffer[1024];
char npw[CP_NPW_MAX_SIZE + 1];
- //sample network password: SPC-300_EoC_200MBps
+ cp_test_init (&ctx);
+ memset (mme, 0, sizeof (*mme));
+ /* Sample network password: SPC-300_EoC_200MBps. */
+ memset (npw, 0, sizeof (npw));
strcpy(npw, "SPC-300_EoC_200MBps");
- //zero padding
- memset((npw + sizeof("SPC-300_EoC_200MBps")), '\0',
- (sizeof(npw) - sizeof("SPC-300_EoC_200MBps")));
-
- ctx.mac_config = &mac_config;
ctx.sta_mgr.sta_own_data.security_level = CP_SECURITY_LEVEL_SC;
ctx.sta_mgr.sta_own_data.nmk.key[0] = 0;
ctx.sta_mgr.sta_own_data.nmk.key[1] = 0;
ctx.sta_mgr.sta_own_data.nmk.key[2] = 0;
ctx.sta_mgr.sta_own_data.nmk.key[3] = 0;
ctx.sta_mgr.our_avln = NULL;
- cp_msg_init(&ctx);
- cp_cl_interf_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
mme->mmtype = DRV_STA_SET_NPW_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
for(i = 0; i < CP_NPW_MAX_SIZE; i++)
- {
bitstream_access(&bitstream, &npw[i], 8);
- }
+
bitstream_finalise(&bitstream);
cp_sta_action_drv__stopped__drv_sta_set_npw_req (&ctx, mme);
test_fail_unless (!(strcmp(ctx.sta_mgr.sta_own_data.npw, npw)));
+ cp_test_uninit (&ctx);
}
test_end;
test_begin (test, "Receiving and processing DRV_STA_SET_DPW_REQ")
{
cp_t ctx;
- mac_config_t mac_config;
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
uint i;
@@ -216,41 +265,35 @@ test_case_association_and_authentication_action (test_t test)
u8 buffer[1024];
char dpw[CP_NPW_MAX_SIZE + 1];
- //sample device password: Spidcom_Eoc_Modem_user_121
- strcpy(dpw, "Spidcom_Eoc_Modem_user_121");
-
- //zero padding
- memset((dpw + sizeof("Spidcom_Eoc_Modem_user_121")), '\0',
- (sizeof(dpw) - sizeof("Spidcom_Eoc_Modem_user_121")));
-
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- cp_cl_interf_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
-
+ cp_test_init (&ctx);
+ memset (mme, 0, sizeof (*mme));
+ /* Sample device password: Spidcom_Eoc_Modem_user_121. */
+ memset (dpw, 0, sizeof (dpw));
+ strcpy(dpw, "SPC-300_EoC_200MBps");
+
mme->mmtype = DRV_STA_SET_DPW_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
for(i = 0; i < CP_NPW_MAX_SIZE; i++)
- {
bitstream_access(&bitstream, &dpw[i], 8);
- }
+
bitstream_finalise(&bitstream);
cp_sta_action_drv__stopped__drv_sta_set_dpw_req (&ctx, mme);
test_fail_unless (!(strcmp(ctx.sta_mgr.sta_own_data.dpw, dpw)));
+ cp_test_uninit (&ctx);
}
test_end;
test_begin (test, "Receiving and processing DRV_STA_SET_SL_REQ")
{
cp_t ctx;
- mac_config_t mac_config;
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
@@ -258,19 +301,23 @@ test_case_association_and_authentication_action (test_t test)
bitstream_t bitstream;
cp_security_level_t sl;
u8 buffer[1024];
+ char npw[CP_NPW_MAX_SIZE + 1];
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- cp_cl_interf_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
+ cp_test_init (&ctx);
+ memset (mme, 0, sizeof (*mme));
+ memset (npw, 0, sizeof (npw));
+ strcpy(npw, "SPC-300_EoC_200MBps");
+ cp_sta_own_data_set_npw (&ctx, npw);
mme->mmtype = DRV_STA_SET_SL_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
- //Possible security level values: CP_SECURITY_LEVEL_SC, CP_SECURITY_LEVEL_HS
+ /* Possible security level values:
+ * CP_SECURITY_LEVEL_SC, CP_SECURITY_LEVEL_HS */
sl = CP_SECURITY_LEVEL_HS;
bitstream_access(&bitstream, &sl, 8);
@@ -279,46 +326,36 @@ test_case_association_and_authentication_action (test_t test)
cp_sta_action_drv__stopped__drv_sta_set_sl_req (&ctx, mme);
test_fail_unless (ctx.sta_mgr.sta_own_data.security_level == sl);
+ cp_test_uninit (&ctx);
}
test_end;
test_begin (test, "Receiving and processing DRV_STA_SET_NID_REQ")
{
cp_t ctx;
- mac_config_t mac_config;
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
- uint cl;
bitstream_t bitstream;
u8 buffer[1024];
cp_nid_t nid;
cp_net_t *net;
- sar_t sar;
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
- memset (&sar, 0, sizeof (sar_t));
-
- //sample network id: 0x11223344556677
+ cp_test_init (&ctx);
+ memset (mme, 0, sizeof (*mme));
+
+ /* Sample network id: 0x11223344556677. */
nid = 0x11223344556677ull;
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
- cp_eoc_sta_mgr_init (&ctx);
- ctx.sar = &sar;
-
- //set our avln
+ /* Set our avln. */
net = cp_sta_mgr_add_avln (&ctx, 1, 1);
cp_sta_mgr_set_our_avln (&ctx, net);
mme->mmtype = DRV_STA_SET_NID_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
bitstream_access(&bitstream, &nid, 56);
@@ -331,13 +368,13 @@ test_case_association_and_authentication_action (test_t test)
test_fail_unless (ctx.sta_mgr.sta_own_data.nid == nid);
test_fail_unless (ctx.sta_mgr.our_avln->nid == nid);
+ cp_test_uninit (&ctx);
}
test_end;
test_begin (test, "Receiving and processing DRV_STA_SET_M_STA_HFID_REQ")
{
cp_t ctx;
- mac_config_t mac_config;
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
uint i;
@@ -345,32 +382,25 @@ test_case_association_and_authentication_action (test_t test)
u8 buffer[1024];
char m_sta_hfid[CP_HFID_SIZE + 1];
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
-
- //sample manufacturer human friendly identifier: Spidcom_SPC_300_EoC_m_HFID_123;
+ cp_test_init (&ctx);
+ memset (mme, 0, sizeof (*mme));
+
+ /* Sample manufacturer human friendly identifier:
+ * Spidcom_SPC_300_EoC_m_HFID_123. */
+ memset(m_sta_hfid, 0, sizeof (m_sta_hfid));
strcpy(m_sta_hfid, "Spidcom_SPC_300_EoC_m_HFID_123");
- //zero padding
- memset((m_sta_hfid + sizeof("Spidcom_SPC_300_EoC_m_HFID_123")), '\0',
- (sizeof(m_sta_hfid) - sizeof("Spidcom_SPC_300_EoC_m_HFID_123")));
-
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- cp_cl_interf_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
-
mme->mmtype = DRV_STA_SET_M_STA_HFID_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
for(i = 0; i < CP_HFID_SIZE; i++)
- {
bitstream_access(&bitstream, &m_sta_hfid[i], 8);
- }
+
bitstream_finalise(&bitstream);
cp_sta_action_drv__stopped__drv_sta_set_m_sta_hfid_req (&ctx, mme);
@@ -378,13 +408,13 @@ test_case_association_and_authentication_action (test_t test)
cp_sta_own_data_t *own = cp_sta_mgr_get_sta_own_data (&ctx);
test_fail_unless (!(strcmp(own->hfid_manufacturer, m_sta_hfid)));
+ cp_test_uninit (&ctx);
}
test_end;
test_begin (test, "Receiving and processing DRV_STA_SET_U_STA_HFID_REQ")
{
cp_t ctx;
- mac_config_t mac_config;
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
uint i;
@@ -392,32 +422,25 @@ test_case_association_and_authentication_action (test_t test)
u8 buffer[1024];
char u_sta_hfid[CP_HFID_SIZE + 1];
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
-
- //sample user human friendly identifier: Spidcom_SPC_300_EoC_u_HFID_123;
+ cp_test_init (&ctx);
+ memset (mme, 0, sizeof (*mme));
+
+ /* Sample manufacturer human friendly identifier:
+ * Spidcom_SPC_300_EoC_m_HFID_123. */
+ memset(u_sta_hfid, 0, sizeof (u_sta_hfid));
strcpy(u_sta_hfid, "Spidcom_SPC_300_EoC_u_HFID_123");
- //zero padding
- memset((u_sta_hfid + sizeof("Spidcom_SPC_300_EoC_u_HFID_123")), '\0',
- (sizeof(u_sta_hfid) - sizeof("Spidcom_SPC_300_EoC_u_HFID_123")));
-
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- cp_cl_interf_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
-
mme->mmtype = DRV_STA_SET_M_STA_HFID_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
for(i = 0; i < CP_HFID_SIZE; i++)
- {
bitstream_access(&bitstream, &u_sta_hfid[i], 8);
- }
+
bitstream_finalise(&bitstream);
cp_sta_action_drv__stopped__drv_sta_set_u_sta_hfid_req (&ctx, mme);
@@ -425,13 +448,13 @@ test_case_association_and_authentication_action (test_t test)
cp_sta_own_data_t *own = cp_sta_mgr_get_sta_own_data (&ctx);
test_fail_unless (!(strcmp(own->hfid_user, u_sta_hfid)));
+ cp_test_uninit (&ctx);
}
test_end;
test_begin (test, "Receiving and processing DRV_STA_SET_AVLN_HFID_REQ")
{
cp_t ctx;
- mac_config_t mac_config;
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
uint i;
@@ -439,32 +462,25 @@ test_case_association_and_authentication_action (test_t test)
u8 buffer[1024];
char avln_hfid[CP_HFID_SIZE + 1];
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
-
- //sample avln human friendly identifier: Spidcom_SPC_300_EoC_avln_HFID_123;
+ cp_test_init (&ctx);
+ memset (mme, 0, sizeof (*mme));
+
+ /* sample avln human friendly identifier:
+ * Spidcom_SPC_300_EoC_avln_HFID_123. */
+ memset(avln_hfid, 0, sizeof (avln_hfid));
strcpy(avln_hfid, "Spidcom_SPC_300_EoC_avln_HFID_123");
- //zero padding
- memset((avln_hfid + sizeof("Spidcom_SPC_300_EoC_avln_HFID_123")), '\0',
- (sizeof(avln_hfid) - sizeof("Spidcom_SPC_300_EoC_avln_HFID_123")));
-
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- cp_cl_interf_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
-
mme->mmtype = DRV_STA_SET_M_STA_HFID_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
for(i = 0; i < CP_HFID_SIZE; i++)
- {
bitstream_access(&bitstream, &avln_hfid[i], 8);
- }
+
bitstream_finalise(&bitstream);
cp_sta_action_drv__stopped__drv_sta_set_avln_hfid_req (&ctx, mme);
@@ -472,17 +488,16 @@ test_case_association_and_authentication_action (test_t test)
cp_sta_own_data_t *own = cp_sta_mgr_get_sta_own_data (&ctx);
test_fail_unless (!(strcmp(own->hfid_avln, avln_hfid)));
+ cp_test_uninit (&ctx);
}
test_end;
test_begin (test, "Receiving and processing DRV_STA_SET_KEY_REQ change NID")
{
cp_t ctx;
- mac_config_t mac_config;
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
uint i;
- uint cl;
bitstream_t bitstream;
u8 buffer[1024];
cp_nid_t nid;
@@ -491,49 +506,42 @@ test_case_association_and_authentication_action (test_t test)
enum cp_msg_drv_sta_set_key_type_t type;
cp_security_level_t sl;
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
-
- //sample network id: 0x11223344556677
+ cp_test_init (&ctx);
+ memset (mme, 0, sizeof (*mme));
+
+ /* Sample network id: 0x11223344556677. */
nid = 0x11223344556677ull;
- //Possible security level values: CP_SECURITY_LEVEL_SC, CP_SECURITY_LEVEL_HS
+ /* Possible security level values:
+ * CP_SECURITY_LEVEL_SC, CP_SECURITY_LEVEL_HS. */
sl = CP_SECURITY_LEVEL_HS;
- /* Possible type values: CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_NID,
- CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_SECURITY_LEVEL,
- CP_MSG_DRV_STA_SET_KEY_TYPE_NB */
+ /* Possible type values:
+ * CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_NID,
+ * CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_SECURITY_LEVEL,
+ * CP_MSG_DRV_STA_SET_KEY_TYPE_NB */
type = CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_NID;
- //sample network membership key:
+ /* Sample network membership key. */
nmk.key[0] = 0x11111111;
nmk.key[1] = 0x22222222;
nmk.key[2] = 0x33333333;
nmk.key[3] = 0x44444444;
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
- cp_eoc_sta_mgr_init (&ctx);
-
- //set our avln
net = cp_sta_mgr_add_avln (&ctx, 1, 1);
cp_sta_mgr_set_our_avln (&ctx, net);
cp_sta_own_data_set_security_level (&ctx, sl);
mme->mmtype = DRV_STA_SET_KEY_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
for (i = 0; i < COUNT (nmk.key); i++)
- {
bitstream_access(&bitstream, &nmk.key[i], 32);
- }
bitstream_access(&bitstream, &type, 8);
bitstream_access(&bitstream, &nid, 56);
@@ -545,9 +553,7 @@ test_case_association_and_authentication_action (test_t test)
cp_eoc_sta_action_drv__stopped__drv_sta_set_key_req (&ctx, mme);
for (i = 0; i < COUNT (nmk.key); i++)
- {
test_fail_unless (ctx.sta_mgr.sta_own_data.nmk.key[i] == nmk.key[i]);
- }
test_fail_unless (ctx.sta_mgr.sta_own_data.nid == nid);
@@ -555,17 +561,16 @@ test_case_association_and_authentication_action (test_t test)
//When NID is changed, SL should stay the same
test_fail_unless (ctx.sta_mgr.sta_own_data.security_level == sl);
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "Receiving and processing DRV_STA_SET_KEY_REQ change sl")
{
cp_t ctx;
- mac_config_t mac_config;
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
uint i;
- uint cl;
bitstream_t bitstream;
u8 buffer[1024];
cp_nid_t nid;
@@ -574,49 +579,40 @@ test_case_association_and_authentication_action (test_t test)
enum cp_msg_drv_sta_set_key_type_t type;
cp_security_level_t sl;
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
-
- //sample network id: 0x11223344556677
+ cp_test_init (&ctx);
+ memset (mme, 0, sizeof (*mme));
+
nid = 0x11223344556677ull;
- //Possible security level values: CP_SECURITY_LEVEL_SC, CP_SECURITY_LEVEL_HS
+ /* Possible security level values:
+ * CP_SECURITY_LEVEL_SC, CP_SECURITY_LEVEL_HS. */
sl = CP_SECURITY_LEVEL_SC;
- /* Possible type values: CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_NID,
- CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_SECURITY_LEVEL,
- CP_MSG_DRV_STA_SET_KEY_TYPE_NB */
+ /* Possible type values:
+ * CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_NID,
+ * CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_SECURITY_LEVEL,
+ * CP_MSG_DRV_STA_SET_KEY_TYPE_NB */
type = CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_SECURITY_LEVEL;
- //sample network membership key:
nmk.key[0] = 0x11111111;
nmk.key[1] = 0x22222222;
nmk.key[2] = 0x33333333;
nmk.key[3] = 0x44444444;
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
- cp_eoc_sta_mgr_init (&ctx);
-
- //set our avln
net = cp_sta_mgr_add_avln (&ctx, 1, 1);
cp_sta_mgr_set_our_avln (&ctx, net);
cp_sta_own_data_set_security_level (&ctx, sl);
mme->mmtype = DRV_STA_SET_KEY_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
for (i = 0; i < COUNT (nmk.key); i++)
- {
bitstream_access(&bitstream, &nmk.key[i], 32);
- }
bitstream_access(&bitstream, &type, 8);
bitstream_access(&bitstream, &nid, 56);
@@ -630,24 +626,21 @@ test_case_association_and_authentication_action (test_t test)
test_fail_unless (ctx.sta_mgr.sta_own_data.security_level == sl);
for (i = 0; i < COUNT (nmk.key); i++)
- {
test_fail_unless (ctx.sta_mgr.sta_own_data.nmk.key[i] == nmk.key[i]);
- }
- //STA that changes Security Level shall discard the previous NMK.
+ /* STA that changes Security Level shall discard the previous NMK. */
test_fail_unless (ctx.sta_mgr.sta_own_data.nid != nid);
test_fail_unless (ctx.sta_mgr.our_avln->nid != nid);
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "Receiving and processing DRV_STA_SET_DAK_REQ")
{
cp_t ctx;
- mac_config_t mac_config;
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
+ cp_test_init (&ctx);
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
@@ -656,29 +649,24 @@ test_case_association_and_authentication_action (test_t test)
cp_key_t dak;
u8 buffer[1024];
- //sample device access key:
dak.key[0] = 0x11111111;
dak.key[1] = 0x22222222;
dak.key[2] = 0x33333333;
dak.key[3] = 0x44444444;
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- cp_cl_interf_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
-
+ memset (mme, 0, sizeof (*mme));
mme->mmtype = DRV_STA_SET_DAK_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
for (i = 0; i < COUNT (dak.key); i++)
- {
bitstream_access(&bitstream, &dak.key[i], 32);
- }
+
bitstream_finalise (&bitstream);
mme->length = 16;
@@ -686,20 +674,17 @@ test_case_association_and_authentication_action (test_t test)
cp_sta_action_drv__stopped__drv_sta_set_dak_req (&ctx, mme);
for (i = 0; i < COUNT (dak.key); i++)
- {
test_fail_unless (ctx.sta_mgr.sta_own_data.dak.key[i] == dak.key[i]);
- }
+ cp_test_uninit (&ctx);
}
test_end;
test_begin (test, "Receiving and processing DRV_STA_SET_TONEMASK_REQ")
{
cp_t ctx;
- mac_config_t mac_config;
-
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
+ cp_test_init (&ctx);
+
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
uint i;
@@ -708,37 +693,33 @@ test_case_association_and_authentication_action (test_t test)
u8 buffer[2048];
u32 ff32, ff10;
- ctx.mac_config = &mac_config;
- mac_config_init (ctx.mac_config);
- cp_msg_init(&ctx);
- cp_cl_interf_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
-
ff32 = 0xffffffff;
ff10 = 0x3ff;
+ memset (mme, 0, sizeof (*mme));
mme->mmtype = DRV_STA_SET_TONEMASK_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
ti.carrier_nb = tonemask_default (ti.tonemask);
tonemask_update(&ti);
- /* ti.tonemask[2] = 0x3FFFFFFC by default, MSB coresponds to carrier 169 (0-enable,
- 1-disable), by default it is enabled (MSB = 0) */
+ /* ti.tonemask[2] = 0x3FFFFFFC by default,
+ * MSB coresponds to carrier 169 (0-enable,
+ * 1-disable), by default it is enabled (MSB = 0) */
- /* disable carrier number 169 (set MSB to 1, i.e. ti.tonemask[2] = 0xBFFFFFFC */
+ /* disable carrier number 169
+ * (set MSB to 1, i.e. ti.tonemask[2] = 0xBFFFFFFC */
ti.tonemask[2] = 0xBFFFFFFC;
tonemask_update(&ti);
for (i = 0; i < PHY_CARRIER_OFFSET / 32; i++)
- {
bitstream_access(&bitstream, &ff32, 32);
- }
bitstream_access(&bitstream, &ff10, 10);
@@ -747,35 +728,34 @@ test_case_association_and_authentication_action (test_t test)
bitstream_access(&bitstream, &ti.tonemask[i], 32);
}
- for (i = 0; i <= (PHY_ALL_CARRIER_NB - PHY_TONEMASK_WORDS * 32 - PHY_CARRIER_OFFSET) / 32; i++)
- {
+ for (i = 0; i <= (PHY_ALL_CARRIER_NB - PHY_TONEMASK_WORDS * 32 -
+ PHY_CARRIER_OFFSET) / 32; i++)
bitstream_access(&bitstream, &ff32, 32);
- }
bitstream_finalise (&bitstream);
- mme->length = PHY_TONEMASK_WORDS * 32 + PHY_CARRIER_OFFSET + \
- (PHY_ALL_CARRIER_NB - PHY_TONEMASK_WORDS * 32 - PHY_CARRIER_OFFSET) ;
+ mme->length = PHY_TONEMASK_WORDS * 32 + PHY_CARRIER_OFFSET +
+ (PHY_ALL_CARRIER_NB - PHY_TONEMASK_WORDS * 32 -
+ PHY_CARRIER_OFFSET) ;
cp_sta_action_drv__stopped__drv_sta_set_tonemask_req (&ctx, mme);
- test_fail_unless (ctx.mac_config->tonemask_info.carrier_nb == ti.carrier_nb);
+ test_fail_unless (ctx.mac_config->tonemask_info.carrier_nb ==
+ ti.carrier_nb);
for (i = 0; i < PHY_TONEMASK_WORDS; i++)
- {
- test_fail_unless (ctx.mac_config->tonemask_info.tonemask[i] == ti.tonemask[i]);
- }
+ test_fail_unless (ctx.mac_config->tonemask_info.tonemask[i] ==
+ ti.tonemask[i]);
+ cp_test_uninit (&ctx);
}
test_end;
test_begin (test, "Receiving and processing DRV_STA_SET_CONFIG_REQ")
{
cp_t ctx;
- mac_config_t mac_config;
-
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
+ cp_test_init (&ctx);
+
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
uint i;
@@ -784,66 +764,50 @@ test_case_association_and_authentication_action (test_t test)
char test_config[6] = "tei:1";
- ctx.mac_config = &mac_config;
- mac_config_init (ctx.mac_config);
- cp_msg_init(&ctx);
- cp_cl_interf_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
- lib_stats_init ();
-
+ memset (mme, 0, sizeof (*mme));
mme->mmtype = DRV_STA_SET_CONFIG_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
for(i = 0; i < 6; i++)
- {
bitstream_access(&bitstream, &test_config[i], 8);
- }
+
bitstream_finalise (&bitstream);
mme->length = 6;
cp_sta_action_drv__drv_sta_set_config_req (&ctx, mme);
+ cp_test_uninit (&ctx);
}
test_end;
test_begin (test, "Receiving and processing DRV_STA_GET_KEY_REQ")
{
cp_t ctx;
- mac_config_t mac_config;
-
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
+ cp_test_init (&ctx);
+
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
bitstream_t bitstream;
u8 buffer[1024];
cp_nid_t nid;
- uint cl;
cp_net_t *net;
cp_key_t nmk;
cp_security_level_t sl;
u8 i;
- //sample network membership key:
+ memset (mme, 0, sizeof (*mme));
nmk.key[0] = 0x11111111;
nmk.key[1] = 0x22222222;
nmk.key[2] = 0x33333333;
nmk.key[3] = 0x44444444;
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
- cp_eoc_sta_mgr_init (&ctx);
-
- //set our avln
net = cp_sta_mgr_add_avln (&ctx, 1, 1);
cp_sta_mgr_set_our_avln (&ctx, net);
@@ -855,9 +819,10 @@ test_case_association_and_authentication_action (test_t test)
mme->mmtype = DRV_STA_GET_KEY_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
bitstream_finalise (&bitstream);
@@ -867,11 +832,10 @@ test_case_association_and_authentication_action (test_t test)
test_fail_unless (ctx.sta_mgr.sta_own_data.nid == nid);
for (i = 0; i < COUNT (nmk.key); i++)
- {
test_fail_unless (ctx.sta_mgr.sta_own_data.nmk.key[i] == nmk.key[i]);
- }
test_fail_unless (ctx.sta_mgr.sta_own_data.security_level == sl);
+ cp_test_uninit (&ctx);
}
test_end;
@@ -882,21 +846,23 @@ test_case_association_and_authentication_action (test_t test)
cp_mme_rx_t *mme = &my_mme;
bitstream_t bitstream;
u8 buffer[1024];
- //cp_fsm_event_type_t result;
- cp_fsm_init(&ctx);
+ cp_test_init (&ctx);
+ memset (mme, 0, sizeof (*mme));
mme->mmtype = DRV_STA_MAC_START_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
bitstream_finalise (&bitstream);
cp_sta_action_drv__stopped__drv_sta_mac_start_req (&ctx, mme);
+ cp_test_uninit (&ctx);
}
test_end;
@@ -908,8 +874,9 @@ test_case_association_and_authentication_action (test_t test)
bitstream_t bitstream;
u8 buffer[1024];
- cp_fsm_init(&ctx);
+ cp_test_init (&ctx);
+ memset (mme, 0, sizeof (*mme));
mme->peer.mac = 2;
mme->peer.tei = 5;
mme->peer.eth_type = ETH_TYPE_VLAN;
@@ -917,9 +884,10 @@ test_case_association_and_authentication_action (test_t test)
mme->mmtype = DRV_STA_MAC_STOP_REQ;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
bitstream_finalise (&bitstream);
@@ -928,76 +896,75 @@ test_case_association_and_authentication_action (test_t test)
test_fail_unless (ctx.sta_action.drv_peer.tei == mme->peer.tei);
test_fail_unless (ctx.sta_action.drv_peer.mac == mme->peer.mac);
- test_fail_unless (ctx.sta_action.drv_peer.eth_type == mme->peer.eth_type);
- test_fail_unless (ctx.sta_action.drv_peer.vlan_tci == mme->peer.vlan_tci);
+ test_fail_unless (ctx.sta_action.drv_peer.eth_type ==
+ mme->peer.eth_type);
+ test_fail_unless (ctx.sta_action.drv_peer.vlan_tci ==
+ mme->peer.vlan_tci);
+ cp_test_uninit (&ctx);
}
test_end;
test_begin (test, "cp_eoc_sta_action_sta_clear_status")
{
cp_t ctx;
- mac_config_t mac_config;
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
-
- uint cl;
+ cp_test_init (&ctx);
+
cp_net_t *net;
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
- ctx.mac_store = mac_store_init ();
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- cp_eoc_sta_mgr_init (&ctx);
- //set our avln
net = cp_sta_mgr_add_avln (&ctx, 1, 1);
cp_sta_mgr_set_our_avln (&ctx, net);
+ memset (mme, 0, sizeof (*mme));
mme->peer.mac = 2;
mme->peer.tei = 5;
- cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei, mme->peer.mac);
+ cp_sta_t *sta = cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei,
+ mme->peer.mac);
cp_sta_action_assoc_init (&ctx);
cp_eoc_sta_action_sta_clear_status(&ctx);
cp_sta_own_data_t *own_data = cp_sta_mgr_get_sta_own_data (&ctx);
test_fail_unless (own_data->tei_track == MAC_TEI_UNASSOCIATED);
- test_fail_unless (cp_sta_own_data_get_tei (&ctx) == MAC_TEI_UNASSOCIATED);
- test_fail_unless (cp_sta_own_data_get_authenticated_status (&ctx) == false);
+ test_fail_unless (cp_sta_own_data_get_tei (&ctx) ==
+ MAC_TEI_UNASSOCIATED);
+ test_fail_unless (cp_sta_own_data_get_authenticated_status (&ctx) ==
+ false);
test_fail_unless (ctx.sta_action.assoc.retry == 0);
test_fail_unless (ctx.sta_action.assoc.beacon_loss == 0);
+ cp_eoc_sta_mgr_sta_remove (&ctx, sta);
+ slab_release (sta);
+ test_fail_unless (mac_store_sta_remove (ctx.mac_store, mme->peer.tei));
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "Call to cp_eoc_sta_action_assoc__detecting_detected")
{
cp_t ctx;
-
+ cp_test_init (&ctx);
cp_eoc_sta_action_assoc__detecting_detected (&ctx);
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "Call cp_eoc_sta_action_assoc__detecting_timeout")
{
cp_t ctx;
-
+ cp_test_init (&ctx);
cp_eoc_sta_action_assoc__detecting_timeout (&ctx);
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "Call cp_eoc_sta_action_assoc__beacon_received")
{
cp_t ctx;
- mac_config_t mac_config;
-
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
+ cp_test_init (&ctx);
- uint cl;
cp_net_t *net;
cp_sta_t *sta;
bsu_beacon_t beacon;
@@ -1005,17 +972,11 @@ test_case_association_and_authentication_action (test_t test)
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
- ctx.mac_store = mac_store_init ();
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- cp_eoc_sta_mgr_init (&ctx);
- //set our avln
net = cp_sta_mgr_add_avln (&ctx, 1, 1);
cp_sta_mgr_set_our_avln (&ctx, net);
+ memset (mme, 0, sizeof (*mme));
mme->peer.mac = 2;
mme->peer.tei = 5;
sta = cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei, mme->peer.mac);
@@ -1023,19 +984,19 @@ test_case_association_and_authentication_action (test_t test)
cp_eoc_sta_action_assoc__beacon_received (&ctx, pbeacon, net, sta);
test_fail_unless (ctx.sta_action.assoc.beacon_loss == 0);
+ cp_eoc_sta_mgr_sta_remove (&ctx, sta);
+ slab_release (sta);
+ test_fail_unless (mac_store_sta_remove (ctx.mac_store, mme->peer.tei));
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "Call cp_eoc_sta_action_auth__beacon_received")
{
- static pbproc_t ARCH_DLRAM_BSS pbproc_global;
cp_t ctx;
- mac_config_t mac_config;
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
+ cp_test_init (&ctx);
- uint cl;
cp_net_t *net;
cp_sta_t *sta;
bsu_beacon_t beacon;
@@ -1043,19 +1004,11 @@ test_case_association_and_authentication_action (test_t test)
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
- ctx.mac_store = mac_store_init ();
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- cp_eoc_sta_mgr_init (&ctx);
-
- ctx.pbproc = &pbproc_global;
- //set our avln
net = cp_sta_mgr_add_avln (&ctx, 1, 1);
cp_sta_mgr_set_our_avln (&ctx, net);
+ memset (mme, 0, sizeof (*mme));
mme->peer.mac = 2;
mme->peer.tei = 5;
sta = cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei, mme->peer.mac);
@@ -1063,26 +1016,22 @@ test_case_association_and_authentication_action (test_t test)
ctx.pbproc->polled = true;
((cp_sta_private_t *)sta)->is_cco = true;
- cp_fsm_event_t event;
- ctx.fsm.handled_event = &event;
ctx.fsm.active_states[0] = CP_FSM_STATE_AUTHENTICATED;
- ctx.fsm.handled_event->type = CP_FSM_EVENT_TYPE_BEACON;
cp_eoc_sta_action_auth__beacon_received (&ctx, pbeacon, net, sta);
-
test_fail_unless(ctx.fsm.active_states[0] == CP_FSM_STATE_AUTHENTICATED);
+ cp_eoc_sta_mgr_sta_remove (&ctx, sta);
+ slab_release (sta);
+ test_fail_unless (mac_store_sta_remove (ctx.mac_store, mme->peer.tei));
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "Call cp_eoc_sta_action_assoc__associating_cnf")
{
cp_t ctx;
- mac_config_t mac_config;
-
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
-
- uint cl;
+
+ cp_test_init (&ctx);
cp_net_t *net;
bitstream_t bitstream;
u8 result;
@@ -1094,35 +1043,32 @@ test_case_association_and_authentication_action (test_t test)
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
- ctx.mac_store = mac_store_init ();
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- cp_eoc_sta_mgr_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
+
ctx.fsm.handled_active_state = 0;
result = 0;
lease_time = 2;
nid = 0x11223344556677ull;
snid = 5;
+
+ memset (mme, 0, sizeof (*mme));
mme->peer.tei = tei = ctx.sta_mgr.sta_own_data.tei = 5;
mme->peer.mac = ctx.sta_action.assoc.peer.mac = 0x2;
- //set our avln
net = cp_sta_mgr_add_avln (&ctx, snid, nid);
cp_sta_mgr_set_our_avln (&ctx, net);
- cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei, mme->peer.mac);
+ cp_sta_t *sta = cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei,
+ mme->peer.mac);
mme->mmtype = CC_ASSOC_CNF;
cp_secu_protocol_run_new (&mme->prun, 0, &ctx.rnd);
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
- //Mac address
+ /* Mac address. */
bitstream_access (&bitstream, &result, 8);
bitstream_access (&bitstream, &nid, 56);
bitstream_access (&bitstream, &snid, 8);
@@ -1135,58 +1081,61 @@ test_case_association_and_authentication_action (test_t test)
cp_fsm_event_t event;
ctx.fsm.handled_event = &event;
- ctx.fsm.active_states[0] = CP_FSM_STATE_ASSOCIATING;
ctx.fsm.handled_event->type = CP_FSM_EVENT_TYPE_CC_ASSOC_CNF;
+ ctx.fsm.active_states[0] = CP_FSM_STATE_ASSOCIATING;
cp_eoc_sta_action_assoc__associating_cnf (&ctx, mme);
test_fail_unless(ctx.fsm.active_states[0] == CP_FSM_STATE_ASSOCIATED);
+ cp_eoc_sta_mgr_sta_remove (&ctx, sta);
+ slab_release (sta);
+ cp_eoc_cco_action_test_release_mac_store (&ctx);
+ test_fail_unless (mac_store_sta_remove (ctx.mac_store, mme->peer.tei));
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "cp_eoc_sta_action_assoc__associating_no_beacons")
{
cp_t ctx;
- mac_config_t mac_config;
-
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
-
- uint cl;
+
+ cp_test_init (&ctx);
+
cp_net_t *net;
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
- ctx.mac_store = mac_store_init ();
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- cp_eoc_sta_mgr_init (&ctx);
- //set our avln
net = cp_sta_mgr_add_avln (&ctx, 1, 1);
cp_sta_mgr_set_our_avln (&ctx, net);
+ memset (mme, 0, sizeof (*mme));
mme->peer.mac = 2;
mme->peer.tei = 5;
- cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei, mme->peer.mac);
+ cp_sta_t *sta = cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei,
+ mme->peer.mac);
cp_eoc_sta_action_assoc__associating_no_beacons(&ctx);
cp_sta_own_data_t *own_data = cp_sta_mgr_get_sta_own_data (&ctx);
test_fail_unless (own_data->tei_track == MAC_TEI_UNASSOCIATED);
- test_fail_unless (cp_sta_own_data_get_tei (&ctx) == MAC_TEI_UNASSOCIATED);
- test_fail_unless (cp_sta_own_data_get_authenticated_status (&ctx) == false);
+ test_fail_unless (cp_sta_own_data_get_tei (&ctx) ==
+ MAC_TEI_UNASSOCIATED);
+ test_fail_unless (cp_sta_own_data_get_authenticated_status (&ctx) ==
+ false);
test_fail_unless (ctx.sta_action.assoc.retry == 0);
test_fail_unless (ctx.sta_action.assoc.beacon_loss == 0);
+ cp_eoc_sta_mgr_sta_remove (&ctx, sta);
+ slab_release (sta);
+ cp_eoc_cco_action_test_release_mac_store (&ctx);
+ test_fail_unless (mac_store_sta_remove (ctx.mac_store, mme->peer.tei));
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "cp_eoc_sta_action_assoc__unassociated_retry")
{
cp_t ctx;
-
cp_eoc_sta_action_assoc__unassociated_retry(&ctx);
}
test_end
@@ -1194,12 +1143,9 @@ test_case_association_and_authentication_action (test_t test)
test_begin (test, "Call cp_eoc_sta_action_assoc__associated_key_cnf")
{
cp_t ctx;
- mac_config_t mac_config;
-
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
-
- uint cl;
+
+ cp_test_init (&ctx);
+
cp_net_t *net;
bitstream_t bitstream;
u8 result, eks, req_key_type;
@@ -1211,15 +1157,12 @@ test_case_association_and_authentication_action (test_t test)
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
- ctx.mac_store = mac_store_init ();
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- cp_eoc_sta_mgr_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
- mme->prun.my_nonce = ctx.sta_action.assoc.prun.my_nonce = lib_rnd32 (&ctx.rnd);
- mme->prun.your_nonce = ctx.sta_action.assoc.prun.your_nonce = lib_rnd32 (&ctx.rnd);
+
+ memset (mme, 0, sizeof (*mme));
+ mme->prun.my_nonce = ctx.sta_action.assoc.prun.my_nonce =
+ lib_rnd32 (&ctx.rnd);
+ mme->prun.your_nonce = ctx.sta_action.assoc.prun.your_nonce =
+ lib_rnd32 (&ctx.rnd);
result = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED;
req_key_type = CP_MSG_KEY_NEK;
@@ -1231,30 +1174,32 @@ test_case_association_and_authentication_action (test_t test)
mme->prun.pmn = ctx.sta_action.assoc.prun.pmn + 1;
mme->peks = CP_MME_PEKS_DAK;
- //sample network membership key:
nmk.key[0] = 0x11111111;
nmk.key[1] = 0x22222222;
nmk.key[2] = 0x33333333;
nmk.key[3] = 0x44444444;
+
mme->peer.tei = tei = ctx.sta_action.assoc.peer.tei = 5;
mme->peer.mac = ctx.sta_action.assoc.peer.mac = 0x2;
- //set our avln
net = cp_sta_mgr_add_avln (&ctx, snid, nid);
cp_sta_mgr_set_our_avln (&ctx, net);
- cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei, mme->peer.mac);
+ cp_sta_t *sta = cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei,
+ mme->peer.mac);
mme->mmtype = CM_GET_KEY_CNF;
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
bitstream_access (&bitstream, &result, 8);
bitstream_access (&bitstream, &req_key_type, 8);
- bitstream_access (&bitstream, &mme->prun.my_nonce, 32);
+ /* Reverse nonce order (simulate other side). */
bitstream_access (&bitstream, &mme->prun.your_nonce, 32);
+ bitstream_access (&bitstream, &mme->prun.my_nonce, 32);
bitstream_access (&bitstream, &nid, 56);
bitstream_access (&bitstream, &eks, 8);
bitstream_access (&bitstream, &mme->prun.pid, 8);
@@ -1277,18 +1222,22 @@ test_case_association_and_authentication_action (test_t test)
cp_eoc_sta_action_assoc__associated_key_cnf (&ctx, mme);
test_fail_unless(ctx.fsm.active_states[0] == CP_FSM_STATE_AUTHENTICATED);
+ test_fail_unless(ctx.sta_mgr.sta_own_data.state ==
+ CP_EOC_STA_STATE_AUTHENTICATED);
+ cp_eoc_sta_mgr_sta_remove (&ctx, sta);
+ slab_release (sta);
+ cp_eoc_cco_action_test_release_mac_store (&ctx);
+ test_fail_unless (mac_store_sta_remove (ctx.mac_store, mme->peer.tei));
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "Call cp_eoc_sta_action_auth__authenticated_key_cnf")
{
cp_t ctx;
- mac_config_t mac_config;
-
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
-
- uint cl;
+
+ cp_test_init (&ctx);
+
cp_net_t *net;
cp_sta_t *sta;
bitstream_t bitstream;
@@ -1301,15 +1250,12 @@ test_case_association_and_authentication_action (test_t test)
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
- ctx.mac_store = mac_store_init ();
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- cp_eoc_sta_mgr_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
- mme->prun.my_nonce = ctx.sta_action.assoc.prun.my_nonce = lib_rnd32 (&ctx.rnd);
- mme->prun.your_nonce = ctx.sta_action.assoc.prun.your_nonce = lib_rnd32 (&ctx.rnd);
+
+ memset (mme, 0, sizeof (*mme));
+ mme->prun.my_nonce = ctx.sta_action.assoc.prun.my_nonce =
+ lib_rnd32 (&ctx.rnd);
+ mme->prun.your_nonce = ctx.sta_action.assoc.prun.your_nonce =
+ lib_rnd32 (&ctx.rnd);
result = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED;
req_key_type = CP_MSG_KEY_TEK;
@@ -1321,11 +1267,11 @@ test_case_association_and_authentication_action (test_t test)
mme->prun.pmn = 0xFF;
mme->peks = CP_MME_PEKS_DAK;
- //sample network membership key:
nmk.key[0] = 0x11111111;
nmk.key[1] = 0x22222222;
nmk.key[2] = 0x33333333;
nmk.key[3] = 0x44444444;
+
mme->peer.tei = tei = ctx.sta_action.assoc.peer.tei = 5;
mme->peer.mac = ctx.sta_action.assoc.peer.mac = 0x2;
@@ -1336,15 +1282,17 @@ test_case_association_and_authentication_action (test_t test)
sta = cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei, mme->peer.mac);
mme->mmtype = CM_GET_KEY_CNF;
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
bitstream_access (&bitstream, &result, 8);
bitstream_access (&bitstream, &req_key_type, 8);
- bitstream_access (&bitstream, &mme->prun.my_nonce, 32);
+ /* Reverse nonce order (simulate other side). */
bitstream_access (&bitstream, &mme->prun.your_nonce, 32);
+ bitstream_access (&bitstream, &mme->prun.my_nonce, 32);
bitstream_access (&bitstream, &nid, 56);
bitstream_access (&bitstream, &eks, 8);
bitstream_access (&bitstream, &mme->prun.pid, 8);
@@ -1368,18 +1316,20 @@ test_case_association_and_authentication_action (test_t test)
test_fail_unless(ctx.fsm.active_states[0] == CP_FSM_STATE_AUTHENTICATED);
test_fail_unless(cp_sta_get_authenticated (&ctx, sta));
+ cp_eoc_sta_mgr_sta_remove (&ctx, sta);
+ slab_release (sta);
+ cp_eoc_cco_action_test_release_mac_store (&ctx);
+ test_fail_unless (mac_store_sta_remove (ctx.mac_store, mme->peer.tei));
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "Call cp_eoc_sta_action_auth__authenticated_set_key_req")
{
cp_t ctx;
- mac_config_t mac_config;
-
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
-
- uint cl;
+
+ cp_test_init (&ctx);
+
cp_net_t *net;
cp_sta_t *sta;
bitstream_t bitstream;
@@ -1392,15 +1342,12 @@ test_case_association_and_authentication_action (test_t test)
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
- ctx.mac_store = mac_store_init ();
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- cp_eoc_sta_mgr_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
- mme->prun.my_nonce = ctx.sta_action.nek_prun.my_nonce = lib_rnd32 (&ctx.rnd);
- mme->prun.your_nonce = ctx.sta_action.nek_prun.your_nonce = lib_rnd32 (&ctx.rnd);
+
+ memset (mme, 0, sizeof (*mme));
+ mme->prun.my_nonce = ctx.sta_action.nek_prun.my_nonce =
+ lib_rnd32 (&ctx.rnd);
+ mme->prun.your_nonce = ctx.sta_action.nek_prun.your_nonce =
+ lib_rnd32 (&ctx.rnd);
req_key_type = CP_MSG_KEY_NEK;
mme->prun.prn = ctx.sta_action.nek_prun.prn = 1;
@@ -1420,7 +1367,6 @@ test_case_association_and_authentication_action (test_t test)
mme->peer.tei = tei = ctx.sta_action.assoc.peer.tei = 5;
mme->peer.mac = ctx.sta_action.assoc.peer.mac = 0x2;
- //set our avln
net = cp_sta_mgr_add_avln (&ctx, snid, nid);
cp_sta_mgr_set_our_avln (&ctx, net);
@@ -1429,14 +1375,16 @@ test_case_association_and_authentication_action (test_t test)
net->cco = sta;
mme->mmtype = CM_SET_KEY_REQ;
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
bitstream_access (&bitstream, &req_key_type, 8);
- bitstream_access (&bitstream, &mme->prun.my_nonce, 32);
+ /* Reverse nonce order (simulate other side). */
bitstream_access (&bitstream, &mme->prun.your_nonce, 32);
+ bitstream_access (&bitstream, &mme->prun.my_nonce, 32);
bitstream_access (&bitstream, &mme->prun.pid, 8);
bitstream_access (&bitstream, &mme->prun.prn, 16);
bitstream_access (&bitstream, &mme->prun.pmn, 8);
@@ -1459,99 +1407,100 @@ test_case_association_and_authentication_action (test_t test)
cp_eoc_sta_action_auth__authenticated_set_key_req (&ctx, mme);
- test_fail_unless(ctx.fsm.active_states[0] == CP_FSM_STATE_AUTHENTICATED);
+ test_fail_unless (ctx.fsm.active_states[0] ==
+ CP_FSM_STATE_AUTHENTICATED);
+ /* It should be last action. */
+ test_fail_unless (ctx.sta_action.nek_prun.pmn == 0xFF);
+ cp_eoc_sta_mgr_sta_remove (&ctx, sta);
+ slab_release (sta);
+ cp_eoc_cco_action_test_release_mac_store (&ctx);
+ test_fail_unless (mac_store_sta_remove (ctx.mac_store, mme->peer.tei));
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "cp_eoc_sta_action_assoc__associated_no_beacons")
{
cp_t ctx;
- mac_config_t mac_config;
-
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
-
- uint cl;
+
+ cp_test_init (&ctx);
+
cp_net_t *net;
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
- ctx.mac_store = mac_store_init ();
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- cp_eoc_sta_mgr_init (&ctx);
- //set our avln
net = cp_sta_mgr_add_avln (&ctx, 1, 1);
cp_sta_mgr_set_our_avln (&ctx, net);
+ memset (mme, 0, sizeof (*mme));
mme->peer.mac = 2;
mme->peer.tei = 5;
- cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei, mme->peer.mac);
+ cp_sta_t *sta = cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei,
+ mme->peer.mac);
cp_eoc_sta_action_assoc__associated_no_beacons(&ctx);
cp_sta_own_data_t *own_data = cp_sta_mgr_get_sta_own_data (&ctx);
test_fail_unless (own_data->tei_track == MAC_TEI_UNASSOCIATED);
- test_fail_unless (cp_sta_own_data_get_tei (&ctx) == MAC_TEI_UNASSOCIATED);
- test_fail_unless (cp_sta_own_data_get_authenticated_status (&ctx) == false);
+ test_fail_unless (cp_sta_own_data_get_tei (&ctx) ==
+ MAC_TEI_UNASSOCIATED);
+ test_fail_unless (cp_sta_own_data_get_authenticated_status (&ctx) ==
+ false);
test_fail_unless (ctx.sta_action.assoc.retry == 0);
test_fail_unless (ctx.sta_action.assoc.beacon_loss == 0);
+ cp_eoc_sta_mgr_sta_remove (&ctx, sta);
+ slab_release (sta);
+ cp_eoc_cco_action_test_release_mac_store (&ctx);
+ test_fail_unless (mac_store_sta_remove (ctx.mac_store, mme->peer.tei));
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "cp_eoc_sta_action_assoc__associated_timeout")
{
cp_t ctx;
- mac_config_t mac_config;
-
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
-
- uint cl;
+
+ cp_test_init (&ctx);
+
cp_net_t *net;
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
- ctx.mac_store = mac_store_init ();
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- cp_eoc_sta_mgr_init (&ctx);
- //set our avln
net = cp_sta_mgr_add_avln (&ctx, 1, 1);
cp_sta_mgr_set_our_avln (&ctx, net);
+ memset (mme, 0, sizeof (*mme));
mme->peer.mac = 2;
mme->peer.tei = 5;
- cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei, mme->peer.mac);
-
- //cp_sta_own_data_t *own = cp_sta_mgr_get_sta_own_data (&ctx);
+ cp_sta_t *sta = cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei,
+ mme->peer.mac);
cp_eoc_sta_action_assoc__associated_timeout(&ctx);
cp_sta_own_data_t *own_data = cp_sta_mgr_get_sta_own_data (&ctx);
test_fail_unless (own_data->tei_track == MAC_TEI_UNASSOCIATED);
- test_fail_unless (cp_sta_own_data_get_tei (&ctx) == MAC_TEI_UNASSOCIATED);
- test_fail_unless (cp_sta_own_data_get_authenticated_status (&ctx) == false);
+ test_fail_unless (cp_sta_own_data_get_tei (&ctx) ==
+ MAC_TEI_UNASSOCIATED);
+ test_fail_unless (cp_sta_own_data_get_authenticated_status (&ctx) ==
+ false);
test_fail_unless (ctx.sta_action.assoc.retry == 0);
test_fail_unless (ctx.sta_action.assoc.beacon_loss == 0);
+ cp_eoc_sta_mgr_sta_remove (&ctx, sta);
+ slab_release (sta);
+ cp_eoc_cco_action_test_release_mac_store (&ctx);
+ test_fail_unless (mac_store_sta_remove (ctx.mac_store, mme->peer.tei));
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "Call cp_eoc_sta_action_assoc__associated_leave")
{
cp_t ctx;
- mac_config_t mac_config;
-
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
-
- uint cl;
+
+ cp_test_init (&ctx);
+
cp_net_t *net;
bitstream_t bitstream;
u8 reason;
@@ -1561,31 +1510,26 @@ test_case_association_and_authentication_action (test_t test)
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
- ctx.mac_store = mac_store_init ();
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- cp_eoc_sta_mgr_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
reason = 0;
nid = 0x11223344556677ull;
snid = 4;
+ memset (mme, 0, sizeof (*mme));
mme->peer.tei = 5;
mme->peer.mac = 0x2;
- //set our avln
net = cp_sta_mgr_add_avln (&ctx, snid, nid);
cp_sta_mgr_set_our_avln (&ctx, net);
- cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei, mme->peer.mac);
+ cp_sta_t *sta = cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei,
+ mme->peer.mac);
mme->mmtype = CC_LEAVE_IND;
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
bitstream_access (&bitstream, &reason, 8);
@@ -1604,24 +1548,29 @@ test_case_association_and_authentication_action (test_t test)
cp_sta_own_data_t *own_data = cp_sta_mgr_get_sta_own_data (&ctx);
- test_fail_unless(ctx.fsm.active_states[0] == CP_FSM_STATE_DETECTING_BEACON);
+ test_fail_unless(ctx.fsm.active_states[0] ==
+ CP_FSM_STATE_DETECTING_BEACON);
test_fail_unless (own_data->tei_track == MAC_TEI_UNASSOCIATED);
- test_fail_unless (cp_sta_own_data_get_tei (&ctx) == MAC_TEI_UNASSOCIATED);
- test_fail_unless (cp_sta_own_data_get_authenticated_status (&ctx) == false);
+ test_fail_unless (cp_sta_own_data_get_tei (&ctx) ==
+ MAC_TEI_UNASSOCIATED);
+ test_fail_unless (cp_sta_own_data_get_authenticated_status (&ctx) ==
+ false);
test_fail_unless (ctx.sta_action.assoc.retry == 0);
test_fail_unless (ctx.sta_action.assoc.beacon_loss == 0);
+ cp_eoc_sta_mgr_sta_remove (&ctx, sta);
+ slab_release (sta);
+ cp_eoc_cco_action_test_release_mac_store (&ctx);
+ test_fail_unless (mac_store_sta_remove (ctx.mac_store, mme->peer.tei));
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "Call cp_eoc_sta_action_assoc__authenticated_leave")
{
cp_t ctx;
- mac_config_t mac_config;
-
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
-
- uint cl;
+
+ cp_test_init (&ctx);
+
cp_net_t *net;
bitstream_t bitstream;
u8 reason;
@@ -1631,31 +1580,26 @@ test_case_association_and_authentication_action (test_t test)
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
- ctx.mac_store = mac_store_init ();
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- cp_eoc_sta_mgr_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
reason = 0;
nid = 0x11223344556677ull;
snid = 4;
+ memset (mme, 0, sizeof (*mme));
mme->peer.tei = 5;
mme->peer.mac = 0x2;
- //set our avln
net = cp_sta_mgr_add_avln (&ctx, snid, nid);
cp_sta_mgr_set_our_avln (&ctx, net);
- cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei, mme->peer.mac);
+ cp_sta_t *sta = cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei,
+ mme->peer.mac);
mme->mmtype = CC_LEAVE_IND;
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
bitstream_access (&bitstream, &reason, 8);
@@ -1674,75 +1618,81 @@ test_case_association_and_authentication_action (test_t test)
cp_sta_own_data_t *own_data = cp_sta_mgr_get_sta_own_data (&ctx);
- test_fail_unless(ctx.fsm.active_states[0] == CP_FSM_STATE_DETECTING_BEACON);
+ test_fail_unless(ctx.fsm.active_states[0] ==
+ CP_FSM_STATE_DETECTING_BEACON);
test_fail_unless (own_data->tei_track == MAC_TEI_UNASSOCIATED);
- test_fail_unless (cp_sta_own_data_get_tei (&ctx) == MAC_TEI_UNASSOCIATED);
- test_fail_unless (cp_sta_own_data_get_authenticated_status (&ctx) == false);
+ test_fail_unless (cp_sta_own_data_get_tei (&ctx) ==
+ MAC_TEI_UNASSOCIATED);
+ test_fail_unless (cp_sta_own_data_get_authenticated_status (&ctx) ==
+ false);
test_fail_unless (ctx.sta_action.assoc.retry == 0);
test_fail_unless (ctx.sta_action.assoc.beacon_loss == 0);
+ cp_eoc_sta_mgr_sta_remove (&ctx, sta);
+ slab_release (sta);
+ cp_eoc_cco_action_test_release_mac_store (&ctx);
+ test_fail_unless (mac_store_sta_remove (ctx.mac_store, mme->peer.tei));
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "cp_eoc_sta_action_assoc__authenticated_no_beacons")
{
cp_t ctx;
- mac_config_t mac_config;
-
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
-
- uint cl;
+
+ cp_test_init (&ctx);
+
cp_net_t *net;
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
- ctx.mac_store = mac_store_init ();
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- cp_eoc_sta_mgr_init (&ctx);
- //set our avln
net = cp_sta_mgr_add_avln (&ctx, 1, 1);
cp_sta_mgr_set_our_avln (&ctx, net);
+ memset (mme, 0, sizeof (*mme));
mme->peer.mac = 2;
mme->peer.tei = 5;
- cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei, mme->peer.mac);
+ cp_sta_t *sta = cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei,
+ mme->peer.mac);
cp_eoc_sta_action_assoc__authenticated_no_beacons(&ctx);
cp_sta_own_data_t *own_data = cp_sta_mgr_get_sta_own_data (&ctx);
test_fail_unless (own_data->tei_track == MAC_TEI_UNASSOCIATED);
- test_fail_unless (cp_sta_own_data_get_tei (&ctx) == MAC_TEI_UNASSOCIATED);
- test_fail_unless (cp_sta_own_data_get_authenticated_status (&ctx) == false);
+ test_fail_unless (cp_sta_own_data_get_tei (&ctx) ==
+ MAC_TEI_UNASSOCIATED);
+ test_fail_unless (cp_sta_own_data_get_authenticated_status (&ctx) ==
+ false);
test_fail_unless (ctx.sta_action.assoc.retry == 0);
test_fail_unless (ctx.sta_action.assoc.beacon_loss == 0);
+ cp_eoc_sta_mgr_sta_remove (&ctx, sta);
+ slab_release (sta);
+ cp_eoc_cco_action_test_release_mac_store (&ctx);
+ test_fail_unless (mac_store_sta_remove (ctx.mac_store, mme->peer.tei));
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "cp_eoc_sta_action_assoc__beacon_not_received")
{
cp_t ctx;
+ cp_test_init (&ctx);
ctx.sta_action.assoc.beacon_loss = CP_MAX_NO_BEACON + 1;
cp_eoc_sta_action_assoc__beacon_not_received(&ctx);
test_fail_unless (ctx.sta_action.assoc.beacon_loss == 0);
+ cp_test_uninit (&ctx);
}
test_end
test_begin (test, "cp_eoc_sta_action_auth__authenticated_set_out_lev")
{
cp_t ctx;
- mac_config_t mac_config;
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
+ cp_test_init (&ctx);
- uint cl;
cp_net_t *net;
bitstream_t bitstream;
u8 out_level;
@@ -1750,14 +1700,8 @@ test_case_association_and_authentication_action (test_t test)
cp_mme_rx_t my_mme;
cp_mme_rx_t *mme = &my_mme;
- ctx.mac_store = mac_store_init ();
- ctx.mac_config = &mac_config;
- cp_msg_init(&ctx);
- ctx.cl = (cl_t *) &cl;
- cp_cl_interf_init (&ctx);
- cp_eoc_sta_mgr_init (&ctx);
- lib_rnd_init (&ctx.rnd, 1234);
+ memset (mme, 0, sizeof (*mme));
mme->peer.tei = 5;
mme->peer.mac = 0x2;
out_level = 120;
@@ -1766,12 +1710,14 @@ test_case_association_and_authentication_action (test_t test)
net = cp_sta_mgr_add_avln (&ctx, 1, 1);
cp_sta_mgr_set_our_avln (&ctx, net);
- cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei, mme->peer.mac);
+ cp_sta_t *sta = cp_sta_mgr_sta_add (&ctx, net, mme->peer.tei,
+ mme->peer.mac);
mme->mmtype = CC_LEAVE_IND;
- bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer), BITSTREAM_READ);
+ bitstream_init (&my_mme.bitstream, buffer, sizeof(buffer),
+ BITSTREAM_READ);
- // Build the MME.
+ /* Build the MME. */
bitstream_init (&bitstream, buffer, sizeof(buffer), BITSTREAM_WRITE);
bitstream_access (&bitstream, &out_level, 8);
@@ -1781,6 +1727,11 @@ test_case_association_and_authentication_action (test_t test)
mme->length = 1;
cp_eoc_sta_action_auth__authenticated_set_out_lev(&ctx, mme);
+ cp_eoc_sta_mgr_sta_remove (&ctx, sta);
+ slab_release (sta);
+ cp_eoc_cco_action_test_release_mac_store (&ctx);
+ test_fail_unless (mac_store_sta_remove (ctx.mac_store, mme->peer.tei));
+ cp_test_uninit (&ctx);
}
test_end
}
@@ -1791,23 +1742,12 @@ test_case_poweron (test_t test)
{
test_case_begin (test, "Poweron");
- /* TODO : Rewrite this test.
- * because 'cp_eoc_sta_action__power_on_no_beacons' is not a public
- * function.
- */
-#if 0
- test_begin (test, "Receiving and processing cp_eoc_sta_action__power_on_no_beacons")
+ test_begin (test, "Rcv & process cp_eoc_sta_action__power_on_no_beacons")
{
cp_t ctx;
- mac_config_t mac_config;
cp_sta_own_data_t *own;
- cl_t cl;
- sar_t sar;
- ctx.mac_config = &mac_config;
- cp_eoc_sta_mgr_init (&ctx);
- ctx.cl=&cl;
- ctx.sar=&sar;
+ cp_test_init (&ctx);
ctx.sta_mgr.sta_own_data.nid = 1;
ctx.sta_mgr.sta_own_data.snid = 1;
@@ -1817,30 +1757,22 @@ test_case_poweron (test_t test)
own = cp_sta_mgr_get_sta_own_data (&ctx);
test_fail_unless(cp_sta_own_data_get_tei(&ctx) == MAC_TEI_UNASSOCIATED);
- test_fail_unless(cp_sta_own_data_get_authenticated_status(&ctx) == false);
+ test_fail_unless(cp_sta_own_data_get_authenticated_status(&ctx) ==
+ false);
test_fail_unless(cp_sta_mgr_get_our_avln(&ctx) != NULL);
test_fail_unless(own->nid_track == cp_sta_own_data_get_nid (&ctx));
test_fail_unless(cp_sta_own_data_get_cco_status(&ctx) == false);
test_fail_unless(own->tei_track == MAC_TEI_UNASSOCIATED);
test_fail_unless(ctx.sta_action.assoc.retry == 0);
test_fail_unless(ctx.sta_action.assoc.beacon_loss == 0);
+ cp_test_uninit (&ctx);
}
test_end
-#endif
- test_begin (test, "Receiving and processing cp_sta_action_poweron__idle__to_poweron")
+ test_begin (test, "Rcv & process cp_sta_action_poweron__idle__to_poweron")
{
cp_t ctx;
- mac_config_t mac_config;
- sar_t sar;
-
- memset (&ctx, 0, sizeof (cp_t));
- memset (&mac_config, 0, sizeof (mac_config_t));
- memset (&sar, 0, sizeof (sar_t));
-
- ctx.mac_config = &mac_config;
- cp_eoc_sta_mgr_init (&ctx);
- ctx.sar=&sar;
+ cp_test_init (&ctx);
ctx.sta_mgr.sta_own_data.nid = 1;
ctx.sta_mgr.sta_own_data.snid = 1;
@@ -1849,12 +1781,13 @@ test_case_poweron (test_t test)
test_fail_unless(ctx.sta_action.assoc.peer.mac == \
CP_MME_PEER (MAC_BROADCAST, MAC_TEI_UNASSOCIATED).mac);
- test_fail_unless(ctx.sta_action.assoc.peer.eth_type == \
- CP_MME_PEER (MAC_BROADCAST, MAC_TEI_UNASSOCIATED).eth_type);
- test_fail_unless(ctx.sta_action.assoc.peer.vlan_tci == \
- CP_MME_PEER (MAC_BROADCAST, MAC_TEI_UNASSOCIATED).vlan_tci);
- test_fail_unless(ctx.sta_action.assoc.peer.tei == \
- CP_MME_PEER (MAC_BROADCAST, MAC_TEI_UNASSOCIATED).tei);
+ test_fail_unless(ctx.sta_action.assoc.peer.eth_type ==
+ CP_MME_PEER (MAC_BROADCAST, MAC_TEI_UNASSOCIATED).eth_type);
+ test_fail_unless(ctx.sta_action.assoc.peer.vlan_tci ==
+ CP_MME_PEER (MAC_BROADCAST, MAC_TEI_UNASSOCIATED).vlan_tci);
+ test_fail_unless(ctx.sta_action.assoc.peer.tei ==
+ CP_MME_PEER (MAC_BROADCAST, MAC_TEI_UNASSOCIATED).tei);
+ cp_test_uninit (&ctx);
}
test_end
}
@@ -1873,11 +1806,18 @@ int
main (int argc, char **argv)
{
test_t t;
- lib_stats_init();
trace_init ();
test_init (t, argc, argv);
test_action_test_suite (t);
trace_uninit ();
+
+ test_case_begin (t, "Memory allocation");
+ test_begin (t, "memory leaks")
+ {
+ test_fail_if (blk_check_memory () != true, "Memory leaks");
+ }
+ test_end;
+
test_result (t);
return test_nb_failed (t) == 0 ? 0 : 1;
}
diff --git a/cesar/cp/eoc/sta/action/test/utest/src/test_fsm.c b/cesar/cp/eoc/sta/action/test/utest/src/test_fsm.c
index 8bd0d26798..e0114257eb 100644
--- a/cesar/cp/eoc/sta/action/test/utest/src/test_fsm.c
+++ b/cesar/cp/eoc/sta/action/test/utest/src/test_fsm.c
@@ -262,7 +262,6 @@ test_fsm_basic_test_case (test_t t)
SCENARIO_EVENT (cp_fsm__UNASSOCIATED__start_retry_timer),
SCENARIO_ACTION (post_and_process,
.type = CP_FSM_EVENT_TYPE_enter_sleep_unassociated),
- SCENARIO_EVENT (cp_fsm__UNASSOCIATED__enter_sleep_unassociated),
SCENARIO_EVENT (cp_fsm__UNASSOCIATED__stop_retry_timer),
/* SLEEP_UNASSOCIATED */
SCENARIO_END
@@ -316,12 +315,10 @@ test_fsm_basic_test_case (test_t t)
SCENARIO_EVENT (cp_fsm__UNASSOCIATED__start_retry_timer),
SCENARIO_ACTION (post_and_process,
.type = CP_FSM_EVENT_TYPE_enter_sleep_unassociated),
- SCENARIO_EVENT (cp_fsm__UNASSOCIATED__enter_sleep_unassociated),
SCENARIO_EVENT (cp_fsm__UNASSOCIATED__stop_retry_timer),
/* 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_EVENT (cp_fsm__UNASSOCIATED__start_retry_timer),
SCENARIO_ACTION (post_and_process,
@@ -593,19 +590,15 @@ test_fsm_basic_test_case (test_t t)
/* 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_EVENT (cp_fsm__UNASSOCIATED__start_retry_timer),
SCENARIO_ACTION (post_and_process,
@@ -776,6 +769,13 @@ main (int argc, char **argv)
test_init (t, argc, argv);
test_fsm_test_suite (t);
trace_uninit ();
+
+ test_case_begin (t, "Memory allocation");
+ test_begin (t, "memory leaks")
+ {
+ test_fail_if (blk_check_memory () != true, "Memory leaks");
+ }
+ test_end;
test_result (t);
return test_nb_failed (t) == 0 ? 0 : 1;
}