]> Git Repo - u-boot.git/blob - test/lib/test_crc8.c
Merge patch series "Fix J7200 kernel boot when using upstream u-boot"
[u-boot.git] / test / lib / test_crc8.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright 2023, Heinrich Schuchardt <[email protected]>
4  *
5  * Unit test for crc8
6  */
7
8 #include <test/lib.h>
9 #include <test/ut.h>
10 #include <u-boot/crc.h>
11
12 static int lib_crc8(struct unit_test_state *uts) {
13         const char str[] = {0x20, 0xf4, 0xd8, 0x24, 0x6f, 0x41, 0x91, 0xae,
14                             0x46, 0x61, 0xf6, 0x55, 0xeb, 0x38, 0x47, 0x0f,
15                             0xec, 0xd8};
16         int actual1, actual2, actual3;
17         int expected1 = 0x47, expected2 = 0xea, expected3 = expected1;
18
19         actual1 = crc8(0, str, sizeof(str));
20         ut_asserteq(expected1, actual1);
21         actual2 = crc8(0, str, 7);
22         ut_asserteq(expected2, actual2);
23         actual3 = crc8(actual2, str + 7, sizeof(str) - 7);
24         ut_asserteq(expected3, actual3);
25
26         return 0;
27 }
28
29 LIB_TEST(lib_crc8, 0);
This page took 0.028005 seconds and 4 git commands to generate.