Skip to content

Commit bbac6e5

Browse files
jukkarioannisg
authored andcommitted
tests: kernel: Add unit test for sys_get_be64()
Make sure sys_get_be64() works as expected. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 0a6a10d commit bbac6e5

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

tests/kernel/common/src/byteorder.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,26 @@ void test_byteorder_mem_swap(void)
6666
zassert_true((memcmp(buf_orig_2, buf_chk_2, 11) == 0),
6767
"Swapping buffer failed");
6868
}
69+
70+
/**
71+
* @brief Test sys_get_be64() functionality
72+
*
73+
* @details Test if sys_get_be64() correctly handles endianness.
74+
*
75+
* @see sys_get_be64()
76+
*/
77+
void test_sys_get_be64(void)
78+
{
79+
u64_t val = 0xf0e1d2c3b4a59687, tmp;
80+
u8_t buf[] = {
81+
0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87
82+
};
83+
84+
tmp = sys_get_be64(buf);
85+
86+
zassert_equal(tmp, val, "sys_get_be64() failed");
87+
}
88+
6989
/**
7090
* @}
7191
*/

tests/kernel/common/src/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
extern void test_byteorder_memcpy_swap(void);
1414
extern void test_byteorder_mem_swap(void);
15+
extern void test_sys_get_be64(void);
1516
extern void test_atomic(void);
1617
extern void test_intmath(void);
1718
extern void test_printk(void);
@@ -95,6 +96,7 @@ void test_main(void)
9596
ztest_unit_test(test_irq_offload),
9697
ztest_unit_test(test_byteorder_memcpy_swap),
9798
ztest_unit_test(test_byteorder_mem_swap),
99+
ztest_unit_test(test_sys_get_be64),
98100
ztest_user_unit_test(test_atomic),
99101
ztest_unit_test(test_bitfield),
100102
ztest_unit_test(test_printk),

0 commit comments

Comments
 (0)