diff options
author | Jett Rink <jettrink@chromium.org> | 2020-11-09 14:42:53 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-11-13 00:27:45 +0000 |
commit | ba63fbd08d40421c63e99ff4fbb5a0b78de3b9bd (patch) | |
tree | 40ec02b754c3f84fc57dc1433050cf6b5a2fe72c /zephyr/test | |
parent | c382208fe8052890704b83b60219c7d55164127b (diff) | |
download | chrome-ec-ba63fbd08d40421c63e99ff4fbb5a0b78de3b9bd.tar.gz |
zephyr: forward cros_crc8 to zephyrs crc8 impl
Shim in support for crc8 used in CBI, I2C, and other
applications within platform/ec
BRANCH=none
BUG=b:168032589
TEST=add unit test for platform/ec and zephyr based
CRC8 approaches and verify they both pass.
Signed-off-by: Jett Rink <jettrink@chromium.org>
Change-Id: I9b6112cb83dab81a44a1ac020d4efb1b7bb1df5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2532692
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'zephyr/test')
-rw-r--r-- | zephyr/test/crc/CMakeLists.txt | 17 | ||||
-rw-r--r-- | zephyr/test/crc/main.c | 27 | ||||
-rw-r--r-- | zephyr/test/crc/prj.conf | 5 |
3 files changed, 49 insertions, 0 deletions
diff --git a/zephyr/test/crc/CMakeLists.txt b/zephyr/test/crc/CMakeLists.txt new file mode 100644 index 0000000000..d8b4d9fadc --- /dev/null +++ b/zephyr/test/crc/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright 2020 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.13.1) +set(BOARD native_posix) +project(tasks) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) + +# We need to include the EC include directory and this local test directory +# for the task defines +zephyr_include_directories("${PLATFORM_EC}/include") + +# Include the test source and the file under test +target_sources(app PRIVATE main.c) +target_sources(app PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../shim/src/crc.c") diff --git a/zephyr/test/crc/main.c b/zephyr/test/crc/main.c new file mode 100644 index 0000000000..34fec7199a --- /dev/null +++ b/zephyr/test/crc/main.c @@ -0,0 +1,27 @@ +/* Copyright 2020 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include <kernel.h> +#include <ztest.h> + +#include "crc8.h" + +/* Note this test makes the pure platform/ec test that uses the same value */ +static void test_crc8_known_data(void) +{ + uint8_t buffer[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 8 }; + + int crc = cros_crc8(buffer, 10); + + /* Verifies polynomial values of 0x07 representing x^8 + x^2 + x + 1 */ + zassert_equal(crc, 170, "CRC8 hash did not match"); +} + +void test_main(void) +{ + ztest_test_suite(test_task_shim, + ztest_unit_test(test_crc8_known_data)); + ztest_run_test_suite(test_task_shim); +} diff --git a/zephyr/test/crc/prj.conf b/zephyr/test/crc/prj.conf new file mode 100644 index 0000000000..3940ec99eb --- /dev/null +++ b/zephyr/test/crc/prj.conf @@ -0,0 +1,5 @@ +# Copyright 2020 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_ZTEST=y |