tests: kernel: Add unit test for sys_put|get_le64()

Make sure sys_put|get_le64() works as expected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2019-08-27 18:48:24 +03:00 committed by Ioannis Glaropoulos
commit 7c2f063625
2 changed files with 43 additions and 0 deletions

View file

@ -262,6 +262,45 @@ void test_sys_put_le32(void)
zassert_mem_equal(tmp, buf, sizeof(u32_t), "sys_put_le32() failed");
}
/**
* @brief Test sys_get_le64() functionality
*
* @details Test if sys_get_le64() correctly handles endianness.
*
* @see sys_get_le64()
*/
void test_sys_get_le64(void)
{
u64_t val = 0xf0e1d2c3b4a59687, tmp;
u8_t buf[] = {
0x87, 0x96, 0xa5, 0xb4, 0xc3, 0xd2, 0xe1, 0xf0
};
tmp = sys_get_le64(buf);
zassert_equal(tmp, val, "sys_get_le64() failed");
}
/**
* @brief Test sys_put_le64() functionality
*
* @details Test if sys_put_le64() correctly handles endianness.
*
* @see sys_put_le64()
*/
void test_sys_put_le64(void)
{
u64_t val = 0xf0e1d2c3b4a59687;
u8_t buf[] = {
0x87, 0x96, 0xa5, 0xb4, 0xc3, 0xd2, 0xe1, 0xf0
};
u8_t tmp[sizeof(u64_t)];
sys_put_le64(val, tmp);
zassert_mem_equal(tmp, buf, sizeof(u64_t), "sys_put_le64() failed");
}
/**
* @}
*/

View file

@ -22,6 +22,8 @@ extern void test_sys_get_le16(void);
extern void test_sys_put_le16(void);
extern void test_sys_get_le32(void);
extern void test_sys_put_le32(void);
extern void test_sys_get_le64(void);
extern void test_sys_put_le64(void);
extern void test_atomic(void);
extern void test_intmath(void);
extern void test_printk(void);
@ -115,6 +117,8 @@ void test_main(void)
ztest_unit_test(test_sys_put_le16),
ztest_unit_test(test_sys_get_le32),
ztest_unit_test(test_sys_put_le32),
ztest_unit_test(test_sys_get_le64),
ztest_unit_test(test_sys_put_le64),
ztest_user_unit_test(test_atomic),
ztest_unit_test(test_bitfield),
ztest_unit_test(test_printk),