1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests: adapt unittests for removal of user-controlled PAN_COMP

This commit is contained in:
Martine Lenders 2016-09-30 13:07:24 +02:00
parent a0454b3787
commit 3b35dae6cd

View File

@ -173,85 +173,22 @@ static void test_ieee802154_set_frame_hdr_bcast_src8(void)
IEEE802154_FCF_SRC_ADDR_LONG,
TEST_UINT8,
dst_pan.u8[0], dst_pan.u8[1],
0xff, 0xff,
ieee802154_addr_bcast[0], ieee802154_addr_bcast[1],
src_pan.u8[0], src_pan.u8[1],
src.u8[7], src.u8[6], src.u8[5], src.u8[4],
src.u8[3], src.u8[2], src.u8[1], src.u8[0] };
uint8_t res[sizeof(exp)];
const uint8_t flags = IEEE802154_BCAST;
const uint8_t flags = 0;
TEST_ASSERT_EQUAL_INT(sizeof(exp),
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
NULL, 0,
ieee802154_addr_bcast,
IEEE802154_ADDR_BCAST_LEN,
src_pan, dst_pan,
flags, TEST_UINT8));
TEST_ASSERT_EQUAL_INT(0, memcmp(exp, res, sizeof(exp)));
}
static void test_ieee802154_set_frame_hdr_dst0_src2(void)
{
const network_uint16_t src = byteorder_htons(TEST_UINT16);
const le_uint16_t src_pan = byteorder_htols(TEST_UINT16 + 1);
const le_uint16_t dst_pan = byteorder_htols(0);
/* IEEE 802.15.4 is little endian! */
const uint8_t exp[] = { IEEE802154_FCF_ACK_REQ,
IEEE802154_FCF_VERS_V1 |
IEEE802154_FCF_DST_ADDR_VOID |
IEEE802154_FCF_SRC_ADDR_SHORT,
TEST_UINT8,
src_pan.u8[0], src_pan.u8[1],
src.u8[1], src.u8[0] };
uint8_t res[sizeof(exp)];
const uint8_t flags = IEEE802154_FCF_ACK_REQ;
TEST_ASSERT_EQUAL_INT(sizeof(exp),
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
NULL, 0,
src_pan, dst_pan,
flags, TEST_UINT8));
TEST_ASSERT_EQUAL_INT(0, memcmp(exp, res, sizeof(exp)));
}
static void test_ieee802154_set_frame_hdr_dst0_src8(void)
{
const network_uint64_t src = byteorder_htonll(TEST_UINT64);
const le_uint16_t src_pan = byteorder_htols(TEST_UINT16);
const le_uint16_t dst_pan = byteorder_htols(0);
/* IEEE 802.15.4 is little endian! */
const uint8_t exp[] = { IEEE802154_FCF_FRAME_PEND,
IEEE802154_FCF_VERS_V1 |
IEEE802154_FCF_DST_ADDR_VOID |
IEEE802154_FCF_SRC_ADDR_LONG,
TEST_UINT8,
src_pan.u8[0], src_pan.u8[1],
src.u8[7], src.u8[6], src.u8[5], src.u8[4],
src.u8[3], src.u8[2], src.u8[1], src.u8[0] };
uint8_t res[sizeof(exp)];
const uint8_t flags = IEEE802154_FCF_FRAME_PEND;
TEST_ASSERT_EQUAL_INT(sizeof(exp),
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
NULL, 0,
src_pan, dst_pan,
flags, TEST_UINT8));
TEST_ASSERT_EQUAL_INT(0, memcmp(exp, res, sizeof(exp)));
}
static void test_ieee802154_set_frame_hdr_dst0_src8_pancomp(void)
{
const network_uint64_t src = byteorder_htonll(TEST_UINT64);
const le_uint16_t src_pan = byteorder_htols(TEST_UINT16);
const le_uint16_t dst_pan = byteorder_htols(0);
uint8_t res;
const uint8_t flags = IEEE802154_FCF_PAN_COMP;
TEST_ASSERT_EQUAL_INT(0,
ieee802154_set_frame_hdr(&res, src.u8, sizeof(src),
NULL, 0,
src_pan, dst_pan,
flags, TEST_UINT8));
}
static void test_ieee802154_set_frame_hdr_dst2_src0(void)
{
const network_uint16_t dst = byteorder_htons(TEST_UINT16);
@ -276,21 +213,6 @@ static void test_ieee802154_set_frame_hdr_dst2_src0(void)
TEST_ASSERT_EQUAL_INT(0, memcmp(exp, res, sizeof(exp)));
}
static void test_ieee802154_set_frame_hdr_dst2_src0_pancomp(void)
{
const network_uint16_t dst = byteorder_htons(TEST_UINT16);
const le_uint16_t src_pan = byteorder_htols(0);
const le_uint16_t dst_pan = byteorder_htols(TEST_UINT16 + 1);
uint8_t res;
const uint8_t flags = IEEE802154_FCF_PAN_COMP;
TEST_ASSERT_EQUAL_INT(0,
ieee802154_set_frame_hdr(&res, NULL, 0,
dst.u8, sizeof(dst),
src_pan, dst_pan,
flags, TEST_UINT8));
}
static void test_ieee802154_set_frame_hdr_dst2_src2(void)
{
const network_uint16_t src = byteorder_htons(TEST_UINT16);
@ -323,7 +245,7 @@ static void test_ieee802154_set_frame_hdr_dst2_src2_pancomp(void)
const network_uint16_t src = byteorder_htons(TEST_UINT16);
const le_uint16_t src_pan = byteorder_htols(TEST_UINT16 + 1);
const network_uint16_t dst = byteorder_htons(TEST_UINT16 + 2);
const le_uint16_t dst_pan = byteorder_htols(TEST_UINT16 + 3);
const le_uint16_t dst_pan = src_pan;
/* IEEE 802.15.4 is little endian! */
const uint8_t exp[] = { IEEE802154_FCF_TYPE_DATA | IEEE802154_FCF_PAN_COMP,
IEEE802154_FCF_VERS_V1 |
@ -335,7 +257,7 @@ static void test_ieee802154_set_frame_hdr_dst2_src2_pancomp(void)
/* src_pan compressed (and assumed equal to dst_pan) */
src.u8[1], src.u8[0] };
uint8_t res[sizeof(exp)];
const uint8_t flags = IEEE802154_FCF_TYPE_DATA | IEEE802154_FCF_PAN_COMP;
const uint8_t flags = IEEE802154_FCF_TYPE_DATA;
TEST_ASSERT_EQUAL_INT(sizeof(exp),
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
@ -378,7 +300,7 @@ static void test_ieee802154_set_frame_hdr_dst2_src8_pancomp(void)
const network_uint64_t src = byteorder_htonll(TEST_UINT64);
const le_uint16_t src_pan = byteorder_htols(TEST_UINT16);
const network_uint16_t dst = byteorder_htons(TEST_UINT16 + 1);
const le_uint16_t dst_pan = byteorder_htols(TEST_UINT16 + 2);
const le_uint16_t dst_pan = src_pan;
/* IEEE 802.15.4 is little endian! */
const uint8_t exp[] = { IEEE802154_FCF_TYPE_DATA | IEEE802154_FCF_PAN_COMP,
IEEE802154_FCF_VERS_V1 |
@ -391,7 +313,7 @@ static void test_ieee802154_set_frame_hdr_dst2_src8_pancomp(void)
src.u8[7], src.u8[6], src.u8[5], src.u8[4],
src.u8[3], src.u8[2], src.u8[1], src.u8[0] };
uint8_t res[sizeof(exp)];
const uint8_t flags = IEEE802154_FCF_TYPE_DATA | IEEE802154_FCF_PAN_COMP;
const uint8_t flags = IEEE802154_FCF_TYPE_DATA;
TEST_ASSERT_EQUAL_INT(sizeof(exp),
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
@ -426,21 +348,6 @@ static void test_ieee802154_set_frame_hdr_dst8_src0(void)
TEST_ASSERT_EQUAL_INT(0, memcmp(exp, res, sizeof(exp)));
}
static void test_ieee802154_set_frame_hdr_dst8_src0_pancomp(void)
{
const network_uint64_t dst = byteorder_htonll(TEST_UINT64);
const le_uint16_t src_pan = byteorder_htols(0);
const le_uint16_t dst_pan = byteorder_htols(TEST_UINT16);
uint8_t res;
const uint8_t flags = IEEE802154_FCF_PAN_COMP;
TEST_ASSERT_EQUAL_INT(0,
ieee802154_set_frame_hdr(&res, NULL, 0,
dst.u8, sizeof(dst),
src_pan, dst_pan,
flags, TEST_UINT8));
}
static void test_ieee802154_set_frame_hdr_dst8_src2(void)
{
const network_uint16_t src = byteorder_htons(TEST_UINT16);
@ -474,7 +381,7 @@ static void test_ieee802154_set_frame_hdr_dst8_src2_pancomp(void)
const network_uint16_t src = byteorder_htons(TEST_UINT16);
const le_uint16_t src_pan = byteorder_htols(TEST_UINT16 + 1);
const network_uint64_t dst = byteorder_htonll(TEST_UINT64);
const le_uint16_t dst_pan = byteorder_htols(TEST_UINT16 + 2);
const le_uint16_t dst_pan = src_pan;
/* IEEE 802.15.4 is little endian! */
const uint8_t exp[] = { IEEE802154_FCF_TYPE_BEACON | IEEE802154_FCF_PAN_COMP,
IEEE802154_FCF_VERS_V1 |
@ -487,7 +394,7 @@ static void test_ieee802154_set_frame_hdr_dst8_src2_pancomp(void)
/* src_pan compressed (and assumed equal to dst_pan) */
src.u8[1], src.u8[0] };
uint8_t res[sizeof(exp)];
const uint8_t flags = IEEE802154_FCF_TYPE_BEACON | IEEE802154_FCF_PAN_COMP;
const uint8_t flags = IEEE802154_FCF_TYPE_BEACON;
TEST_ASSERT_EQUAL_INT(sizeof(exp),
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
@ -531,7 +438,7 @@ static void test_ieee802154_set_frame_hdr_dst8_src8_pancomp(void)
const network_uint64_t src = byteorder_htonll(TEST_UINT64);
const le_uint16_t src_pan = byteorder_htols(TEST_UINT16);
const network_uint64_t dst = byteorder_htonll(TEST_UINT64);
const le_uint16_t dst_pan = byteorder_htols(TEST_UINT16 + 1);
const le_uint16_t dst_pan = src_pan;
/* IEEE 802.15.4 is little endian! */
const uint8_t exp[] = { IEEE802154_FCF_TYPE_BEACON | IEEE802154_FCF_PAN_COMP,
IEEE802154_FCF_VERS_V1 |
@ -545,7 +452,7 @@ static void test_ieee802154_set_frame_hdr_dst8_src8_pancomp(void)
src.u8[7], src.u8[6], src.u8[5], src.u8[4],
src.u8[3], src.u8[2], src.u8[1], src.u8[0] };
uint8_t res[sizeof(exp)];
const uint8_t flags = IEEE802154_FCF_TYPE_BEACON | IEEE802154_FCF_PAN_COMP;
const uint8_t flags = IEEE802154_FCF_TYPE_BEACON;
TEST_ASSERT_EQUAL_INT(sizeof(exp),
ieee802154_set_frame_hdr(res, src.u8, sizeof(src),
@ -1167,17 +1074,12 @@ Test *tests_ieee802154_tests(void)
new_TestFixture(test_ieee802154_set_frame_hdr_bcast_dst2_src2),
new_TestFixture(test_ieee802154_set_frame_hdr_bcast_dst8_src2),
new_TestFixture(test_ieee802154_set_frame_hdr_bcast_src8),
new_TestFixture(test_ieee802154_set_frame_hdr_dst0_src2),
new_TestFixture(test_ieee802154_set_frame_hdr_dst0_src8),
new_TestFixture(test_ieee802154_set_frame_hdr_dst0_src8_pancomp),
new_TestFixture(test_ieee802154_set_frame_hdr_dst2_src0),
new_TestFixture(test_ieee802154_set_frame_hdr_dst2_src0_pancomp),
new_TestFixture(test_ieee802154_set_frame_hdr_dst2_src2),
new_TestFixture(test_ieee802154_set_frame_hdr_dst2_src2_pancomp),
new_TestFixture(test_ieee802154_set_frame_hdr_dst2_src8),
new_TestFixture(test_ieee802154_set_frame_hdr_dst2_src8_pancomp),
new_TestFixture(test_ieee802154_set_frame_hdr_dst8_src0),
new_TestFixture(test_ieee802154_set_frame_hdr_dst8_src0_pancomp),
new_TestFixture(test_ieee802154_set_frame_hdr_dst8_src2),
new_TestFixture(test_ieee802154_set_frame_hdr_dst8_src2_pancomp),
new_TestFixture(test_ieee802154_set_frame_hdr_dst8_src8),