summaryrefslogtreecommitdiff
path: root/test/crc.c
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2020-11-09 14:42:53 -0700
committerCommit Bot <commit-bot@chromium.org>2020-11-13 00:27:45 +0000
commitba63fbd08d40421c63e99ff4fbb5a0b78de3b9bd (patch)
tree40ec02b754c3f84fc57dc1433050cf6b5a2fe72c /test/crc.c
parentc382208fe8052890704b83b60219c7d55164127b (diff)
downloadchrome-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 'test/crc.c')
-rw-r--r--test/crc.c14
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();
}