From 103739729c99abd548424e4ceed7d3fd8609ab0f Mon Sep 17 00:00:00 2001 From: NĂ©lio Laranjeiro Date: Wed, 11 Jul 2012 10:24:13 +0200 Subject: cesar: make test code compile with CONFIG_STATS = n, closes #3234 * VS_GET_STAT_REQ returns an MME with the result, failure or empty. * host unit tests of the SAR uses the override CE context to compute stats. --- cesar/cp/av/msg/test/utest/src/msg_vs.c | 25 ++++++++++++++++++------- cesar/cp/av/sta/action/test/utest/src/drv.c | 16 +++++++++++++--- 2 files changed, 31 insertions(+), 10 deletions(-) (limited to 'cesar/cp') diff --git a/cesar/cp/av/msg/test/utest/src/msg_vs.c b/cesar/cp/av/msg/test/utest/src/msg_vs.c index df42ede2a3..5df9713101 100644 --- a/cesar/cp/av/msg/test/utest/src/msg_vs.c +++ b/cesar/cp/av/msg/test/utest/src/msg_vs.c @@ -1549,8 +1549,11 @@ test_case_msg_vs_get_stats (test_t test) bitstream_access (&stream, &nb_pages, 8); test_fail_if (oui != SPC_OUI); - test_fail_if (result != 1); - test_fail_if (nb_pages != 1); + test_fail_unless (result == 1); + if (CONFIG_STATS) + test_fail_unless (nb_pages == 1); + else + test_fail_unless (nb_pages == 0); bitstream_finalise (&stream); } test_end; @@ -1597,7 +1600,7 @@ test_case_msg_vs_get_stats (test_t test) cp_msg_vs_get_stats_cnf_send_end (&cp, mme); /* verify. */ - char buf_str[1024]; + char buf_str[1024] = "\0"; bitstream_read_init (&stream, first_mme + HPAV_MME_HEADER, 1024); bitstream_access (&stream, &oui, 24); bitstream_access (&stream, &result, 8); @@ -1605,10 +1608,18 @@ test_case_msg_vs_get_stats (test_t test) bitstream_access_str (&stream, buf_str, 1000); test_fail_if (oui != SPC_OUI); - test_fail_if (nb_pages != 1); - test_fail_if (strcmp(buf_str, - "value_u8:12 value_u16:3456 value_u32:7890ABCD " - "value_u64:1234567890ABCDEF")); + if (CONFIG_STATS) + { + test_fail_unless (nb_pages == 1); + test_fail_unless (!strcmp( + buf_str, "value_u8:12 value_u16:3456 value_u32:7890ABCD " + "value_u64:1234567890ABCDEF")); + } + else + { + test_fail_unless (nb_pages == 0); + test_fail_unless (!strcmp (buf_str, "\0")); + } bitstream_finalise (&stream); } diff --git a/cesar/cp/av/sta/action/test/utest/src/drv.c b/cesar/cp/av/sta/action/test/utest/src/drv.c index 2fc811ccc1..9da1bb0fde 100644 --- a/cesar/cp/av/sta/action/test/utest/src/drv.c +++ b/cesar/cp/av/sta/action/test/utest/src/drv.c @@ -242,7 +242,9 @@ drv_basic_test_case (test_t t) SCENARIO_EVENT (cp_msg_drv_any_cnf_send, .peer = peer, .mmtype = DRV_STA_SET_CONFIG_CNF, - .result = CP_MSG_DRV_RESULT_SUCCESS), + .result = CONFIG_STATS ? + CP_MSG_DRV_RESULT_SUCCESS: + CP_MSG_DRV_RESULT_FAILURE), SCENARIO_END }; scenario_globals_t globals = { @@ -264,8 +266,16 @@ drv_basic_test_case (test_t t) cp_sta_own_data_set_nid (&ctx.cp, old_nid); cp_sta_own_data_set_security_level (&ctx.cp, 0x0); lib_stats_uninit (); - test_fail_if (my_param_u8 != 42); - test_fail_if (my_param_u64 != 0x4242424242ull); + if (CONFIG_STATS) + { + test_fail_unless (my_param_u8 == 42); + test_fail_unless (my_param_u64 == 0x4242424242ull); + } + else + { + test_fail_unless (my_param_u8 == 0); + test_fail_unless (my_param_u64 == 0); + } /* Check poweron init set neet_set to false. */ cp_av_sta_action_poweron_init (&ctx.cp); -- cgit v1.2.3