diff options
author | Jett Rink <jettrink@chromium.org> | 2020-11-09 14:42:53 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-11-11 16:59:49 +0000 |
commit | 22ee9a346718a9a07955fd81b0d03c4dde5b2ec8 (patch) | |
tree | 20c0d9eb589a5b32c15922847861d53847143880 /test/crc.c | |
parent | 5ec269c5a71643c955fe45191ed9f06794c6113a (diff) | |
download | chrome-ec-22ee9a346718a9a07955fd81b0d03c4dde5b2ec8.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.
Change-Id: Ib609f98596c4edc6e6f0d01b6242e62a1f95ad72
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2527811
Reviewed-by: Yuval Peress <peress@chromium.org>
Diffstat (limited to 'test/crc.c')
-rw-r--r-- | test/crc.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/crc.c b/test/crc.c index 3521bce4a9..3f24c1a7e4 100644 --- a/test/crc.c +++ b/test/crc.c @@ -8,6 +8,7 @@ #include "common.h" #include "console.h" #include "crc.h" +#include "crc8.h" #include "test_util.h" #include "util.h" @@ -63,6 +64,18 @@ static int test_kat0(void) return EC_SUCCESS; } +static int test_cros_crc8(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 */ + TEST_EQ(crc, 170, "%d"); + + return EC_SUCCESS; +} + void run_test(int argc, char **argv) { test_reset(); @@ -70,6 +83,7 @@ void run_test(int argc, char **argv) RUN_TEST(test_static_version); RUN_TEST(test_8); RUN_TEST(test_kat0); + RUN_TEST(test_cros_crc8); test_print_result(); } |