unit: Create ztest unit test for CRC16 functionality
Ensure that the CRC16 functions compute a few test values properly. Change-Id: Ie98049aefac8a330b9b81d3bf333deb09bc35c39 Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
This commit is contained in:
parent
bd75219ba0
commit
3f8f1ed3b0
3 changed files with 33 additions and 0 deletions
3
tests/unit/drivers/crc/Makefile
Normal file
3
tests/unit/drivers/crc/Makefile
Normal file
|
@ -0,0 +1,3 @@
|
|||
INCLUDE += subsys
|
||||
|
||||
include $(ZEPHYR_BASE)/tests/unit/Makefile.unittest
|
26
tests/unit/drivers/crc/main.c
Normal file
26
tests/unit/drivers/crc/main.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <ztest.h>
|
||||
|
||||
#include <drivers/crc/crc16_sw.c>
|
||||
|
||||
void test_crc16(void)
|
||||
{
|
||||
uint8_t test0[] = { };
|
||||
uint8_t test1[] = { 'A' };
|
||||
uint8_t test2[] = { '1', '2', '3', '4', '5', '6', '7', '8', '9' };
|
||||
|
||||
assert(crc16_ccitt(test0, sizeof(test0)) == 0x1d0f, "pass", "fail");
|
||||
assert(crc16_ccitt(test1, sizeof(test1)) == 0x9479, "pass", "fail");
|
||||
assert(crc16_ccitt(test2, sizeof(test2)) == 0xe5cc, "pass", "fail");
|
||||
}
|
||||
|
||||
void test_main(void *p1, void *p2, void *p3)
|
||||
{
|
||||
ztest_test_suite(test_crc16, ztest_unit_test(test_crc16));
|
||||
ztest_run_test_suite(test_crc16);
|
||||
}
|
4
tests/unit/drivers/crc/testcase.ini
Normal file
4
tests/unit/drivers/crc/testcase.ini
Normal file
|
@ -0,0 +1,4 @@
|
|||
[test]
|
||||
type = unit
|
||||
tags = net crc
|
||||
timeout = 5
|
Loading…
Add table
Add a link
Reference in a new issue