diff options
Diffstat (limited to 'test/lib')
-rw-r--r-- | test/lib/Makefile | 1 | ||||
-rw-r--r-- | test/lib/kconfig.c | 10 | ||||
-rw-r--r-- | test/lib/kconfig_spl.c | 6 | ||||
-rw-r--r-- | test/lib/test_crc8.c | 29 |
4 files changed, 38 insertions, 8 deletions
diff --git a/test/lib/Makefile b/test/lib/Makefile index 7e7922fe3b..e0bd9e04e8 100644 --- a/test/lib/Makefile +++ b/test/lib/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_UT_LIB_ASN1) += asn1.o obj-$(CONFIG_UT_LIB_RSA) += rsa.o obj-$(CONFIG_AES) += test_aes.o obj-$(CONFIG_GETOPT) += getopt.o +obj-$(CONFIG_CRC8) += test_crc8.o obj-$(CONFIG_UT_LIB_CRYPT) += test_crypt.o else obj-$(CONFIG_SANDBOX) += kconfig_spl.o diff --git a/test/lib/kconfig.c b/test/lib/kconfig.c index 472d2c5728..76225ba8ff 100644 --- a/test/lib/kconfig.c +++ b/test/lib/kconfig.c @@ -15,12 +15,12 @@ static int lib_test_is_enabled(struct unit_test_state *uts) { ulong val; - ut_asserteq(1, IS_ENABLED(CONFIG_CMDLINE)) - ut_asserteq(0, IS_ENABLED(CONFIG__UNDEFINED)) + ut_asserteq(1, IS_ENABLED(CONFIG_CMDLINE)); + ut_asserteq(0, IS_ENABLED(CONFIG__UNDEFINED)); - ut_asserteq(1, CONFIG_IS_ENABLED(CMDLINE)) - ut_asserteq(0, CONFIG_IS_ENABLED(OF_PLATDATA)) - ut_asserteq(0, CONFIG_IS_ENABLED(_UNDEFINED)) + ut_asserteq(1, CONFIG_IS_ENABLED(CMDLINE)); + ut_asserteq(0, CONFIG_IS_ENABLED(OF_PLATDATA)); + ut_asserteq(0, CONFIG_IS_ENABLED(_UNDEFINED)); ut_asserteq(0xc000, IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED, CONFIG_BLOBLIST_ADDR)); diff --git a/test/lib/kconfig_spl.c b/test/lib/kconfig_spl.c index c89ceaec66..8f8a3411b1 100644 --- a/test/lib/kconfig_spl.c +++ b/test/lib/kconfig_spl.c @@ -15,9 +15,9 @@ static int lib_test_spl_is_enabled(struct unit_test_state *uts) { ulong val; - ut_asserteq(0, CONFIG_IS_ENABLED(CMDLINE)) - ut_asserteq(1, CONFIG_IS_ENABLED(OF_PLATDATA)) - ut_asserteq(0, CONFIG_IS_ENABLED(_UNDEFINED)) + ut_asserteq(0, CONFIG_IS_ENABLED(CMDLINE)); + ut_asserteq(1, CONFIG_IS_ENABLED(OF_PLATDATA)); + ut_asserteq(0, CONFIG_IS_ENABLED(_UNDEFINED)); /* * This fails if CONFIG_TEST_KCONFIG_ENABLE is not enabled, since the diff --git a/test/lib/test_crc8.c b/test/lib/test_crc8.c new file mode 100644 index 0000000000..0dac97bc5b --- /dev/null +++ b/test/lib/test_crc8.c @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2023, Heinrich Schuchardt <heinrich.schuchardt@canonical.com> + * + * Unit test for crc8 + */ + +#include <test/lib.h> +#include <test/ut.h> +#include <u-boot/crc.h> + +static int lib_crc8(struct unit_test_state *uts) { + const char str[] = {0x20, 0xf4, 0xd8, 0x24, 0x6f, 0x41, 0x91, 0xae, + 0x46, 0x61, 0xf6, 0x55, 0xeb, 0x38, 0x47, 0x0f, + 0xec, 0xd8}; + int actual1, actual2, actual3; + int expected1 = 0x47, expected2 = 0xea, expected3 = expected1; + + actual1 = crc8(0, str, sizeof(str)); + ut_asserteq(expected1, actual1); + actual2 = crc8(0, str, 7); + ut_asserteq(expected2, actual2); + actual3 = crc8(actual2, str + 7, sizeof(str) - 7); + ut_asserteq(expected3, actual3); + + return 0; +} + +LIB_TEST(lib_crc8, 0); |