tests: kernel: Add unit test for sys_put_be64()

Make sure sys_put_be64() works as expected.

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

View file

@ -86,6 +86,26 @@ void test_sys_get_be64(void)
zassert_equal(tmp, val, "sys_get_be64() failed");
}
/**
* @brief Test sys_put_be64() functionality
*
* @details Test if sys_put_be64() correctly handles endianness.
*
* @see sys_put_be64()
*/
void test_sys_put_be64(void)
{
u64_t val = 0xf0e1d2c3b4a59687;
u8_t buf[] = {
0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87
};
u8_t tmp[sizeof(u64_t)];
sys_put_be64(val, tmp);
zassert_mem_equal(tmp, buf, sizeof(u64_t), "sys_put_be64() failed");
}
/**
* @}
*/

View file

@ -13,6 +13,7 @@
extern void test_byteorder_memcpy_swap(void);
extern void test_byteorder_mem_swap(void);
extern void test_sys_get_be64(void);
extern void test_sys_put_be64(void);
extern void test_atomic(void);
extern void test_intmath(void);
extern void test_printk(void);
@ -97,6 +98,7 @@ void test_main(void)
ztest_unit_test(test_byteorder_memcpy_swap),
ztest_unit_test(test_byteorder_mem_swap),
ztest_unit_test(test_sys_get_be64),
ztest_unit_test(test_sys_put_be64),
ztest_user_unit_test(test_atomic),
ztest_unit_test(test_bitfield),
ztest_unit_test(test_printk),