From 9589fd4a52c398cdb396dbe5672ffc4185da78bf Mon Sep 17 00:00:00 2001 From: laranjeiro Date: Thu, 3 Apr 2008 12:52:17 +0000 Subject: Fixed a bug in the SAR, the MFL must contain the length of the ATS or confounder if the MF contains it. Done in tx and rx. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1747 017c9cb6-072f-447c-8318-d5b54f68fe89 --- mac/sar/bridgedma/src/bridge.c | 3 +- mac/sar/inc/sar_mf.h | 13 -- mac/sar/src/sar.c | 7 +- mac/sar/src/sar_mf.c | 20 ++- mac/sar/test/inc/reassembly_unit_test_functions.h | 2 +- mac/sar/test/src/reassembly_unit_test_functions.c | 165 +++++++++++++++------ mac/sar/test/unit_test/ecos/Makefile | 6 +- .../test/unit_test/ecos/src/lib_sar_expiration.c | 5 +- mac/sar/test/unit_test/ecos/src/lib_sar_mfs.c | 9 +- .../test/unit_test/ecos/src/reassembly_complete.c | 3 +- .../test/unit_test/ecos/src/sar_mf_function_test.c | 41 +++-- mac/sar/test/unit_test/host/src/lib_sar_mf.c | 8 +- 12 files changed, 170 insertions(+), 112 deletions(-) diff --git a/mac/sar/bridgedma/src/bridge.c b/mac/sar/bridgedma/src/bridge.c index 1b05c77622..8b602aad76 100644 --- a/mac/sar/bridgedma/src/bridge.c +++ b/mac/sar/bridgedma/src/bridge.c @@ -1,5 +1,6 @@ #include "common/std.h" #include "mac/sar/bridgedma/inc/bridge.h" +#include "lib/read_word.h" phy_bridgedma_t *phy_bridgedma_init (void *user_data, phy_bridgedma_cb_t bridgedma_cb, phy_deferred_cb_t deferred_cb) @@ -92,7 +93,7 @@ void bridge_run (void) addr = first->data + offset; buffer = malloc (2048 * sizeof(u8)); - header_len = ((sar_mf_mfh_t *) addr)->type; + header_len = read_u16_from_word (addr) & 0x3; memcpy (buffer, (first->data + offset), BLK_SIZE- offset); data_len -= BLK_SIZE - offset; diff --git a/mac/sar/inc/sar_mf.h b/mac/sar/inc/sar_mf.h index 0d83426e02..4101f15150 100644 --- a/mac/sar/inc/sar_mf.h +++ b/mac/sar/inc/sar_mf.h @@ -25,21 +25,8 @@ #define SAR_MF_MAX_SIZE (SAR_MF_MFH_SIZE + SAR_MF_ATS_SIZE + ETH_PACKET_MAX_SIZE + SAR_MF_ICV_SIZE) #define SAR_MF_MIN_SIZE (SAR_MF_MFH_SIZE + SAR_MF_ATS_SIZE + ETH_PACKET_MIN_SIZE + SAR_MF_ICV_SIZE) -//#define SAR_MAX_MF_POSITION_MANAGE_EXPIRATION (BLK_SIZE - 6) - #define SAR_DIV_BY_BLK_SIZE 9 -struct sar_mf_mfh_t -{ - BITFIELDS_WORD - ( - u32 type:2;, - u32 length:14;, - u32 ats:16; - ) -}; -typedef struct sar_mf_mfh_t sar_mf_mfh_t; - /** * Get the type of the MF from the PB at the data adress plus the offset * diff --git a/mac/sar/src/sar.c b/mac/sar/src/sar.c index 560e20e047..6379897321 100644 --- a/mac/sar/src/sar.c +++ b/mac/sar/src/sar.c @@ -522,7 +522,7 @@ bridge_dma_free_head (sar_t *ctx) // RX transmission else { - /* If the CRC error is not reaised i.e. THE checksum is correct. */ + /* If the CRC error is not raised i.e. THE checksum is correct. */ if (!job->job.crc_error) { if (((mfs_rx_t *) job->mfs)->common.mme) @@ -966,7 +966,7 @@ void rx_job_desc_create (phy_bridgedma_job_t *job, mfs_rx_t *mfs, + sizeof(u32)); } - offset += job->data_len; + offset += job->data_len + job->header_len + SAR_MF_ICV_SIZE; if (offset < BLK_SIZE) { first_pb->header.mfbo = offset; @@ -1397,10 +1397,11 @@ pb_t * tx_job_desc_create (sar_msdu_t *md_data, mfs_tx_t * mfs, /* * Prescence of an MSDU payload with a Confounder * Mac Frame Header length = 6 Bytes + * MFL = length - 1 + the ATS or confounder size. */ job->header_len = 0x06; // 6 Bytes - job->mf_header1 = type | ((md_data->length - 1) << 2) + job->mf_header1 = type | ((md_data->length - 1 + SAR_MF_ATS_SIZE) << 2) | (md_data->ats_confounder << 16); job->mf_header2 = md_data->ats_confounder >> 16; // 11, the 10 bytes for the header ats and icv + 1 for the human count diff --git a/mac/sar/src/sar_mf.c b/mac/sar/src/sar_mf.c index 36b0ebd2f5..6d1047ecb2 100644 --- a/mac/sar/src/sar_mf.c +++ b/mac/sar/src/sar_mf.c @@ -41,7 +41,7 @@ uint mf_get_type (pb_t * pb, uint offset) * \param offset the offset to start reading * \param payload_only request to return only the payload length if true. * - * \return length of the paylod with the header and icv + * \return length of the payload with the header and icv */ uint mf_get_length (pb_t *pb, uint offset, bool payload_only) { @@ -69,16 +69,20 @@ uint mf_get_length (pb_t *pb, uint offset, bool payload_only) } if (length < ETH_PACKET_MIN_SIZE || length - > ETH_PACKET_MAX_SIZE) + > ETH_PACKET_MAX_SIZE + SAR_MF_ICV_SIZE) return 0; + + if (payload_only && (type > 1)) + { + return length + 1 - SAR_MF_ATS_SIZE; + } else if (payload_only) + { return length + 1; - - switch (type) { - case 0x1: - return length + 7; - default: - return length + 11; + } + else + { + return length + 1 + SAR_MF_ICV_SIZE + SAR_MF_MFH_SIZE; } } diff --git a/mac/sar/test/inc/reassembly_unit_test_functions.h b/mac/sar/test/inc/reassembly_unit_test_functions.h index 77382aeb64..314fea9ecd 100644 --- a/mac/sar/test/inc/reassembly_unit_test_functions.h +++ b/mac/sar/test/inc/reassembly_unit_test_functions.h @@ -18,7 +18,7 @@ #include "lib/blk.h" #include "mac/sar/test/inc/reassembly_unit_test_functions.h" -uint list[12] = { 283, 241, 1231, 169, 227, 393, 82, 1499, 240, 1186, 185}; +uint list[12] = {273, 231, 1221, 159, 217, 383, 72, 1489, 230, 1176, 175}; void test_sar_rx_noise_cb (void *user, const pbproc_rx_params_t *rx_params, phy_chandata_t *first); diff --git a/mac/sar/test/src/reassembly_unit_test_functions.c b/mac/sar/test/src/reassembly_unit_test_functions.c index 3e13c48374..7447338f04 100644 --- a/mac/sar/test/src/reassembly_unit_test_functions.c +++ b/mac/sar/test/src/reassembly_unit_test_functions.c @@ -14,6 +14,8 @@ #include #include "common/std.h" +#include "lib/bitstream.h" +#include "lib/read_word.h" #include "mac/sar/inc/sar_mf.h" #include "mac/pbproc/pbproc.h" @@ -24,6 +26,34 @@ void test_sar_rx_noise_cb (void *user, const pbproc_rx_params_t *rx_params, } +static void +write_mfh (u8 *addr, uint length, uint type, uint ats) +{ + bitstream_t bitstream; + + dbg_assert (addr); + + if (type > 1) + { + length += SAR_MF_ATS_SIZE - 1; + + bitstream_init (&bitstream, addr, 6, BITSTREAM_WRITE); + bitstream_access (&bitstream, &type, 2); + bitstream_access (&bitstream, &length, 14); + bitstream_access (&bitstream, &ats, 32); + } + else + { + length -= 1; + + bitstream_init (&bitstream, addr, 2, BITSTREAM_WRITE); + bitstream_access (&bitstream, &type, 2); + bitstream_access (&bitstream, &length, 14); + } + + bitstream_finalise (&bitstream); +} + /** * Initialize the Reassembly test generating a list of PBs. */ @@ -32,6 +62,10 @@ void sar_unit_test_generate_pb_list (pb_t **first, pb_t **last) pb_t *pb_list[14]; pb_t *pb; + uint length; + uint ats; + uint type; + uint i; *first = (pb_t *) blk_alloc_desc_range (14, (blk_t **) last); @@ -69,45 +103,60 @@ void sar_unit_test_generate_pb_list (pb_t **first, pb_t **last) pb_list[10]->header.mfbf = true; pb_list[10]->header.mfbo = 431; - // MF of 283 bytes => 0x0442 (with type = 2) - *(u32 *) pb_list[0]->data = 0x12340442; + // MF of 283 bytes => 0x0452 (with type = 2 and ats in length) + length = 273; + type = 2; + write_mfh (pb_list[0]->data, length, type, 0); - // MF of 241 bytes => 0x398 + 2 = 0x39A - *(u32*) (pb_list[0]->data + 280) = 0x9A000000; - *(u32*) (pb_list[0]->data + 284) = 0x00123403; + // MF of 241 bytes => 0x398 + 2 = 0x3AA + length = 231; + ats = 0x1234; + write_mfh (pb_list[0]->data + 283, length, type, ats); // MF of 1231 bytes => 0x1310 + type = 0x1312 - *(u32*) (pb_list[1]->data + 12) = 0x12341312; + length = 1221; + ats = 0x1234; + write_mfh (pb_list[1]->data + 12, length, type, ats); // MF of 169 bytes => 0x278 + type = 0x27A - *(u32*) (pb_list[3]->data + 216) = 0x7A000000; - *(u32*) (pb_list[3]->data + 220) = 0x00123402; + length = 159; + ats = 0x1234; + write_mfh (pb_list[3]->data + 219, length, type, ats); // MF of 227 bytes => 0x360 + type = 0x362 - *(u32*) (pb_list[3]->data + 388) = 0x12340362; + length = 217; + ats = 0x1234; + write_mfh (pb_list[3]->data + 388, length, type, ats); // MF of 393 bytes => 0x5f8 + type = 0x5FA - *(u32 *) (pb_list[4]->data + 100) = 0xFA000000; - *(u32 *) (pb_list[4]->data + 104) = 0x00123405; + length = 383; + ats = 0x1234; + write_mfh (pb_list[4]->data + 103, length, type, ats); // MF of 82 bytes => 0x11C + type = 0x11E - *(u32*) (pb_list[4]->data + 496) = 0x1234011E; + length = 72; + ats = 0x1234; + write_mfh (pb_list[4]->data + 496, length, type, ats); // MF of 1499 bytes => 0x1740 + type = 0x1742 - *(u32 *) (pb_list[5]->data + 64) = 0x17420000; - *(u32 *) (pb_list[5]->data + 68) = 0x1234; + length = 1489; + ats = 0x1234; + write_mfh (pb_list[5]->data + 66, length, type, ats); // MF of 240 bytes => 0x394 + type = 0x396 - *(u32*) (pb_list[8]->data + 28) = 0x34039600; - *(u32*) (pb_list[8]->data + 32) = 0x12; + length = 230; + ats = 0x1234; + write_mfh (pb_list[8]->data + 29, length, type, ats); // MF of 1186 bytes => 0x125C + type = 0x125E - *(u32*) (pb_list[8]->data + 268) = 0x34125E00; - *(u32*) (pb_list[8]->data + 272) = 0x12; + length = 1176; + ats = 0x1234; + write_mfh (pb_list[8]->data + 269, length, type, ats); // MF of 185 bytes => 0x2B8 + type = 0x2BA - *(u32*) (pb_list[10]->data + 428) = 0xBA000000; - *(u32*) (pb_list[10]->data + 432) = 0x123402; + length = 175; + ats = 0x1234; + write_mfh (pb_list[10]->data + 431, length, type, ats); // Repeat the PB with the ssn = 1. memcpy (&pb_list[12]->header, &pb_list[1]->header, 4); @@ -142,6 +191,9 @@ void sar_unit_test_generate_mme_pb_list (pb_t **first, pb_t **last) pb_t *pb_list[12]; pb_t *pb; + uint length; + uint ats; + uint type; uint i; *first = (pb_t *) blk_alloc_desc_range (12, (blk_t **) last); @@ -179,45 +231,60 @@ void sar_unit_test_generate_mme_pb_list (pb_t **first, pb_t **last) pb_list[10]->header.mfbf = true; pb_list[10]->header.mfbo = 431; - // MF of 283 bytes => 0x0443 (with type = 3) - *(u32 *) pb_list[0]->data = 0x12340443; + // MF of 283 bytes => 0x0452 (with type = 2 and ats in length) + length = 273; + type = 3; + write_mfh (pb_list[0]->data, length, type, 0); - // MF of 241 bytes => 0x398 + 3 = 0x39B - *(u32*) (pb_list[0]->data + 280) = 0x9B000000; - *(u32*) (pb_list[0]->data + 284) = 0x00123403; + // MF of 241 bytes => 0x398 + 2 = 0x3AA + length = 231; + ats = 0x1234; + write_mfh (pb_list[0]->data + 283, length, type, ats); - // MF of 1231 bytes => 0x1310 + type = 0x1313 - *(u32*) (pb_list[1]->data + 12) = 0x12341313; + // MF of 1231 bytes => 0x1310 + type = 0x1312 + length = 1221; + ats = 0x1234; + write_mfh (pb_list[1]->data + 12, length, type, ats); - // MF of 169 bytes => 0x278 + type = 0x27B - *(u32*) (pb_list[3]->data + 216) = 0x7B000000; - *(u32*) (pb_list[3]->data + 220) = 0x00123402; + // MF of 169 bytes => 0x278 + type = 0x27A + length = 159; + ats = 0x1234; + write_mfh (pb_list[3]->data + 219, length, type, ats); - // MF of 227 bytes => 0x360 + type = 0x363 - *(u32*) (pb_list[3]->data + 388) = 0x12340363; + // MF of 227 bytes => 0x360 + type = 0x362 + length = 217; + ats = 0x1234; + write_mfh (pb_list[3]->data + 388, length, type, ats); - // MF of 393 bytes => 0x5f8 + type = 0x5FB - *(u32 *) (pb_list[4]->data + 100) = 0xFB000000; - *(u32 *) (pb_list[4]->data + 104) = 0x00123405; + // MF of 393 bytes => 0x5f8 + type = 0x5FA + length = 383; + ats = 0x1234; + write_mfh (pb_list[4]->data + 103, length, type, ats); - // MF of 82 bytes => 0x11C + type = 0x11F - *(u32*) (pb_list[4]->data + 496) = 0x1234011F; + // MF of 82 bytes => 0x11C + type = 0x11E + length = 72; + ats = 0x1234; + write_mfh (pb_list[4]->data + 496, length, type, ats); - // MF of 1499 bytes => 0x1740 + type = 0x1743 - *(u32 *) (pb_list[5]->data + 64) = 0x17430000; - *(u32 *) (pb_list[5]->data + 68) = 0x1234; + // MF of 1499 bytes => 0x1740 + type = 0x1742 + length = 1489; + ats = 0x1234; + write_mfh (pb_list[5]->data + 66, length, type, ats); - // MF of 240 bytes => 0x394 + type = 0x397 - *(u32*) (pb_list[8]->data + 28) = 0x34039700; - *(u32*) (pb_list[8]->data + 32) = 0x12; + // MF of 240 bytes => 0x394 + type = 0x396 + length = 230; + ats = 0x1234; + write_mfh (pb_list[8]->data + 29, length, type, ats); - // MF of 1186 bytes => 0x125C + type = 0x125f - *(u32*) (pb_list[8]->data + 268) = 0x34125f00; - *(u32*) (pb_list[8]->data + 272) = 0x12; + // MF of 1186 bytes => 0x125C + type = 0x125E + length = 1176; + ats = 0x1234; + write_mfh (pb_list[8]->data + 269, length, type, ats); - // MF of 185 bytes => 0x2B8 + type = 0x2BB - *(u32*) (pb_list[10]->data + 428) = 0xBB000000; - *(u32*) (pb_list[10]->data + 432) = 0x123402; + // MF of 185 bytes => 0x2B8 + type = 0x2BA + length = 175; + ats = 0x1234; + write_mfh (pb_list[10]->data + 431, length, type, ats); *first = pb_list[0]; pb_list[0]->next= pb_list[6]; diff --git a/mac/sar/test/unit_test/ecos/Makefile b/mac/sar/test/unit_test/ecos/Makefile index c6de8cafc3..6f30a011ef 100644 --- a/mac/sar/test/unit_test/ecos/Makefile +++ b/mac/sar/test/unit_test/ecos/Makefile @@ -7,7 +7,7 @@ DEFS = -DSAR_UNIT_TEST=1 TARGET_PROGRAMS = reassembly_complete rea_cov_test \ reassembly_create_mfs lib_sar_mfs reassembly_measurement \ reassembly_mfs_update_expiration_date sar_call_back_ul \ - lib_sar_expiration sar_mf_function_test \ + lib_sar_expiration \ sar_mfs_resising segmentation_complete test_store_memory test_crc_error \ msdu-timeout beacon_path test-seg-provide-pb @@ -50,10 +50,6 @@ lib_sar_expiration_SOURCES = lib_sar_expiration.c lib_sar_expiration_MODULES = lib mac/sar mac/common mac/pbproc \ mac/sar/bridgedma mac/sar/test -sar_mf_function_test_SOURCES = sar_mf_function_test.c -sar_mf_function_test_MODULES = lib mac/sar mac/common mac/sar/bridgedma \ - mac/pbproc mac/sar/test - sar_mfs_resising_SOURCES = sar_mfs_resising.c sar_mfs_resising_MODULES = lib mac/sar mac/common mac/sar/bridgedma \ mac/sar/test mac/pbproc diff --git a/mac/sar/test/unit_test/ecos/src/lib_sar_expiration.c b/mac/sar/test/unit_test/ecos/src/lib_sar_expiration.c index 7c060d1488..1ddfc01f74 100644 --- a/mac/sar/test/unit_test/ecos/src/lib_sar_expiration.c +++ b/mac/sar/test/unit_test/ecos/src/lib_sar_expiration.c @@ -33,7 +33,8 @@ bool ce_tested; bool ce_measurement (void *user, pbproc_rx_params_t *rx_params, uint pb_nb, blk_t **first, - blk_t **last, pb_t *chan_data_first, uint nb_chandata) + blk_t **last, pb_t *chan_data_first, uint nb_chandata, uint + *blk_offset) { ce_tested = true; return false; @@ -629,7 +630,7 @@ this_test_mpdu_expired (sar_t *sar) test_begin (test, "Chandata provided") { - test_fail_if (ce_tested == false, "Chandata not providede to the CE"); + test_fail_if (ce_tested == false, "Chandata not provided to the CE"); } test_end; diff --git a/mac/sar/test/unit_test/ecos/src/lib_sar_mfs.c b/mac/sar/test/unit_test/ecos/src/lib_sar_mfs.c index bdd484544e..59edf82aa7 100644 --- a/mac/sar/test/unit_test/ecos/src/lib_sar_mfs.c +++ b/mac/sar/test/unit_test/ecos/src/lib_sar_mfs.c @@ -19,7 +19,8 @@ #include "lib/test.h" #include "mac/sar/inc/sar_mfs.h" -int main (void) +int +cyg_user_start (void) { test_t test; pb_t *pb_head; @@ -47,7 +48,7 @@ int main (void) /* Verify the contiguousity of the MFS */ rx_mfs_update_last_contiguous_and_tail (mfs, mfs->head); - test_begin (test, "Test the contigousity of the MFS") + test_begin (test, "Test the contiguously of the MFS") { test_fail_if (mfs->head != NULL, "The first pb is wrong"); test_fail_if (mfs->tail != NULL, "The tail pb is wrong"); @@ -59,10 +60,10 @@ int main (void) mfs->tail = pb_tail; mfs->last_contiguous = NULL; - /* Test the contigousity of the chain */ + /* Test the contiguously of the chain */ rx_mfs_update_last_contiguous_and_tail (mfs, mfs->head); - test_begin (test, "Test the contigousity of the chain") + test_begin (test, "Test the contiguously of the chain") { test_fail_if (mfs->head->header.ssn != 0, "The first pb is wrong"); test_fail_if (mfs->tail->header.ssn != 3, "The tail pb is wrong"); diff --git a/mac/sar/test/unit_test/ecos/src/reassembly_complete.c b/mac/sar/test/unit_test/ecos/src/reassembly_complete.c index da57e3c84b..f3a3bc6bb2 100644 --- a/mac/sar/test/unit_test/ecos/src/reassembly_complete.c +++ b/mac/sar/test/unit_test/ecos/src/reassembly_complete.c @@ -22,6 +22,7 @@ #include "lib/test.h" #include "lib/trace.h" +#include "lib/read_word.h" #include "mac/sar/sar.h" #include "mac/common/store.h" @@ -54,7 +55,7 @@ void rea_comp_sar_rea_done_with_one_pb (void *user, u8* buffer, uint length, void rea_comp_sar_rea_done (void *user, u8* buffer, uint length, mfs_rx_t *mfs, bool encrypted) { - if (length != list[cpt] - 10) + if (length != list[cpt]) bool_test = true; cpt ++; } diff --git a/mac/sar/test/unit_test/ecos/src/sar_mf_function_test.c b/mac/sar/test/unit_test/ecos/src/sar_mf_function_test.c index fcd0121275..d386674be8 100644 --- a/mac/sar/test/unit_test/ecos/src/sar_mf_function_test.c +++ b/mac/sar/test/unit_test/ecos/src/sar_mf_function_test.c @@ -27,15 +27,14 @@ int main (void) bool debug = false; pb_t *pb1; pb_t *pb2; - sar_mf_mfh_t *mfh; - u16 length; - u8 type; - u16 type_length; - u16 ats; + uint length; + uint type; + uint type_length; + uint ats; type = 2; - length = 106; + length = 106 + SAR_MF_ATS_SIZE; ats = 0x1234; type_length = type | (length << 2); @@ -49,12 +48,7 @@ int main (void) pb1->header.ssn = 0; pb2->header.ssn = 1; - mfh = (sar_mf_mfh_t *) pb1->data; - mfh->type = type; - mfh->length = length - 1; - mfh->ats = ats; - - *(u32*)pb2->data = type | ((length -1) << 2)| (ats << 16); + *(u32*)pb2->data = type | ((length -1 + SAR_MF_ATS_SIZE) << 2)| (ats << 16); if (debug) { @@ -76,10 +70,10 @@ int main (void) test_init (test, 0, NULL); test_begin(test, "test MF 1, offset = 0") { - test_fail_if (mf_get_type(pb1, 0) != (uint) mfh->type, "Type in MF 1 does not correspond"); - test_fail_if (mf_get_length(pb1, 0, true) != (uint) (mfh->length + 1), "Pyaload Length in MF 1 does not correspond"); - test_fail_if (mf_get_length(pb1, 0, false) != (uint) (mfh->length + 11), "Complete Length in MF 1 does not correspond"); - test_fail_if (mf_get_ats(pb1, 0) != (uint) mfh->ats, "Ats does not correspond"); + test_fail_if (mf_get_type(pb1, 0) != type, "Type in MF 1 does not correspond"); + test_fail_if (mf_get_length(pb1, 0, true) != length - SAR_MF_ATS_SIZE, "Payload Length in MF 1 does not correspond"); + test_fail_if (mf_get_length(pb1, 0, false) != length + SAR_MF_MFH_SIZE + SAR_MF_ICV_SIZE, "Complete Length in MF 1 does not correspond"); + test_fail_if (mf_get_ats(pb1, 0) != ats, "Ats does not correspond"); } test_end; @@ -105,11 +99,16 @@ int main (void) test_end; // ANOTHER test. + length = 272 + SAR_MF_ATS_SIZE; + ats = 0x5678; + type = 2; + // MF of 283 bytes - *((u32*)(pb1->data)) = 2 | (272 << 2)| (0x5678 << 16); + *((u32*)(pb1->data)) = type | (length << 2)| (ats << 16); // MF of 241 bytes - *((u32*)(pb1->data + 283)) = 2 | (230 << 2)| (0x5678 << 16); + length = 230 + SAR_MF_ATS_SIZE; + *((u32*)(pb1->data + 283)) = type | (length << 2)| (ats << 16); if (debug) { @@ -124,9 +123,9 @@ int main (void) test_begin(test, "two MF followed") { - test_fail_if (mf_get_type(pb1, 0) != (uint)((sar_mf_mfh_t *)(pb1->data))->type, "Type Should correspond"); - test_fail_if (mf_get_length(pb1, 0, true) != (uint) (((sar_mf_mfh_t *)(pb1->data))->length + 1), "Length Should correspond"); - test_fail_if (mf_get_ats(pb1, 0) != (uint) ((sar_mf_mfh_t *)(pb1->data))->ats, "Ats should correspond"); + test_fail_if (mf_get_type(pb1, 0) != type, "Type Should correspond"); + test_fail_if (mf_get_length(pb1, 0, true) != length - 3, "Length Should correspond"); + test_fail_if (mf_get_ats(pb1, 0) != ats, "Ats should correspond"); test_fail_if (mf_get_type(pb1, 283) != (uint) ((sar_mf_mfh_t *)(pb1->data + 283))->type, "Type Should correspond"); test_fail_if (mf_get_length(pb1, 283, true) != (uint) (((sar_mf_mfh_t *)(pb1->data + 283))->length + 1), "Length Should correspond"); diff --git a/mac/sar/test/unit_test/host/src/lib_sar_mf.c b/mac/sar/test/unit_test/host/src/lib_sar_mf.c index ed405377e9..ca2190e87a 100644 --- a/mac/sar/test/unit_test/host/src/lib_sar_mf.c +++ b/mac/sar/test/unit_test/host/src/lib_sar_mf.c @@ -41,7 +41,7 @@ int main (void) /* fill the pb */ mft = 2; - length = 105; + length = 105 + SAR_MF_ATS_SIZE; ats = 0x0; bitstream_init (&bitstream, pb->data + 0x10, 6, BITSTREAM_WRITE); @@ -107,7 +107,7 @@ int main (void) pb->next = (pb_t *) blk_alloc_desc(); pb->next->next = NULL; - *(uint*) (pb->data + 508) = 0xBA000000; + *(uint*) (pb->data + 508) = 0xCA000000; *(uint*) (pb->next->data) = 0x34567801; *(uint*) (pb->next->data + 4) = 0x12; @@ -119,7 +119,7 @@ int main (void) } test_end; - *(uint*) (pb->data + 500) = 0xBA000000; + *(uint*) (pb->data + 500) = 0xCA000000; *(uint*) (pb->data + 504) = 0x34567801; *(uint*) (pb->data + 508) = 0x12; @@ -130,7 +130,7 @@ int main (void) } test_end; - *(uint*) (pb->data + 508) = 0x7801BA00; + *(uint*) (pb->data + 508) = 0x7801CA00; *(uint*) (pb->next->data) = 0x123456; -- cgit v1.2.3