[PATCH v9 03/10] lib: uuid: introduce testcase for uuid_str_to_le_bin

Abdellatif El Khlifi abdellatif.elkhlifi at arm.com
Fri Mar 10 15:10:09 CET 2023


provide a test case

Signed-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi at arm.com>
Cc: Simon Glass <sjg at chromium.org>
---
 MAINTAINERS       |  5 +++++
 test/lib/Makefile |  1 +
 test/lib/uuid.c   | 44 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+)
 create mode 100644 test/lib/uuid.c

diff --git a/MAINTAINERS b/MAINTAINERS
index e29c16cf01..58370c5fbd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1596,3 +1596,8 @@ S:	Maintained
 F:	arch/arm/dts/ls1021a-twr-u-boot.dtsi
 F:	drivers/crypto/fsl/
 F:	include/fsl_sec.h
+
+UUID testing
+M:	Abdellatif El Khlifi <abdellatif.elkhlifi at arm.com>
+S:	Maintained
+F:	test/lib/uuid.c
diff --git a/test/lib/Makefile b/test/lib/Makefile
index 7e7922fe3b..db6d88c065 100644
--- a/test/lib/Makefile
+++ b/test/lib/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_UT_LIB_RSA) += rsa.o
 obj-$(CONFIG_AES) += test_aes.o
 obj-$(CONFIG_GETOPT) += getopt.o
 obj-$(CONFIG_UT_LIB_CRYPT) += test_crypt.o
+obj-$(CONFIG_LIB_UUID) += uuid.o
 else
 obj-$(CONFIG_SANDBOX) += kconfig_spl.o
 endif
diff --git a/test/lib/uuid.c b/test/lib/uuid.c
new file mode 100644
index 0000000000..6f24939de4
--- /dev/null
+++ b/test/lib/uuid.c
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Functional tests for UCLASS_FFA  class
+ *
+ * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office at arm.com>
+ *
+ * Authors:
+ *   Abdellatif El Khlifi <abdellatif.elkhlifi at arm.com>
+ */
+
+#include <common.h>
+#include <uuid.h>
+#include <test/lib.h>
+#include <test/test.h>
+#include <test/ut.h>
+
+/* test UUID */
+#define TEST_SVC_UUID	"ed32d533-4209-99e6-2d72-cdd998a79cc0"
+
+#define UUID_SIZE 16
+
+/* The UUID binary data (little-endian format) */
+static const u8 ref_uuid_bin[UUID_SIZE] = {
+	0x33, 0xd5, 0x32, 0xed,
+	0x09, 0x42, 0xe6, 0x99,
+	0x72, 0x2d, 0xc0, 0x9c,
+	0xa7, 0x98, 0xd9, 0xcd
+};
+
+static int lib_test_uuid_to_le(struct unit_test_state *uts)
+{
+	const char *uuid_str = TEST_SVC_UUID;
+	u8 ret_uuid_bin[UUID_SIZE] = {0};
+	int cnt;
+
+	ut_assertok(uuid_str_to_le_bin(uuid_str, ret_uuid_bin));
+
+	for (cnt = 0; cnt < UUID_SIZE; cnt++)
+		ut_asserteq(ref_uuid_bin[cnt], ret_uuid_bin[cnt]);
+
+	return 0;
+}
+
+LIB_TEST(lib_test_uuid_to_le, 0);
-- 
2.25.1



More information about the U-Boot mailing list