From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH v4 2/2] test: add functional test for uuid
Date: Tue, 9 Apr 2024 10:05:03 -0700 [thread overview]
Message-ID: <20240409170602.541658-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20240409170602.541658-1-stephen@networkplumber.org>
The uuid functions in EAL were not covered by existing functional
tests.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test/meson.build | 1 +
app/test/test_uuid.c | 138 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 139 insertions(+)
create mode 100644 app/test/test_uuid.c
diff --git a/app/test/meson.build b/app/test/meson.build
index 7d909039ae..11fb7dbffa 100644
--- a/app/test/meson.build
+++ b/app/test/meson.build
@@ -198,6 +198,7 @@ source_file_deps = {
'test_trace.c': [],
'test_trace_perf.c': [],
'test_trace_register.c': [],
+ 'test_uuid.c' : [],
'test_vdev.c': ['kvargs', 'bus_vdev'],
'test_version.c': [],
}
diff --git a/app/test/test_uuid.c b/app/test/test_uuid.c
new file mode 100644
index 0000000000..a4b1b34786
--- /dev/null
+++ b/app/test/test_uuid.c
@@ -0,0 +1,138 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2024 Stephen Hemminger
+ */
+
+#include <rte_uuid.h>
+
+#include "test.h"
+
+#define NROUNDS 100
+
+static int
+check_duplicate_uuid(rte_uuid_t uids[])
+{
+ int i, j;
+ char out[256];
+
+ for (i = 0; i < NROUNDS - 1; i++) {
+ for (j = i + 1; j < NROUNDS; j++) {
+ if (rte_uuid_compare(uids[i], uids[j]) == 0) {
+ rte_uuid_unparse(uids[i], out, sizeof(out));
+ printf("Generated duplicate random uuids %d == %d : %s\n",
+ i, j, out);
+ return TEST_FAILED;
+ }
+ }
+ }
+ return TEST_SUCCESS;
+}
+
+
+static const struct uuid_case {
+ const char *in;
+ rte_uuid_t result;
+} good_cases[] = {
+ { "02ce8e94-5b84-47fc-8f86-72633c5b5061",
+ RTE_UUID_INIT(0x02ce8e94, 0x5b84, 0x47fc, 0x8f86, 0x72633c5b5061) },
+ { "2c72af87-d220-4931-98ec-45c8520c94e1",
+ RTE_UUID_INIT(0x2c72af87, 0xd220, 0x4931, 0x98ec, 0x45c8520c94e1) },
+ { "441edca1-0942-4ccd-9b33-233e0454fe5b",
+ RTE_UUID_INIT(0x441edca1, 0x0942, 0x4ccd, 0x9b33, 0x233e0454fe5b) },
+};
+
+static const char * const bad_cases[] = {
+ "", /* empty */
+ "41edca1-0942-4ccd-9b33-233e0454fe5b", /* too short */
+ "d5cecbac-531b-4527-b0629-2bc3011dc9c", /* hyphen in wrong place */
+ "db318745-1347-4f5e-m142-d86dc41172b2", /* bad hex */
+};
+
+static int
+test_uuid(void)
+{
+ rte_uuid_t uids[NROUNDS] = { };
+ rte_uuid_t clone[NROUNDS] = { };
+ unsigned int i;
+ int ret;
+
+ /* Test generate random uuid */
+ for (i = 0; i < NROUNDS; i++) {
+ if (!rte_uuid_is_null(uids[i])) {
+ printf("Zero'd uuid %d is not null\n", i);
+ return TEST_FAILED;
+ }
+
+ rte_uuid_generate_random(uids[i]);
+
+ if (rte_uuid_is_null(uids[i])) {
+ printf("Generated random uuid %d is null\n", i);
+ return TEST_FAILED;
+ }
+ }
+
+ ret = check_duplicate_uuid(uids);
+ if (ret != TEST_SUCCESS)
+ return ret;
+
+ /* Test generate time */
+ for (i = 0; i < NROUNDS; i++) {
+ rte_uuid_generate_time(uids[i]);
+
+ if (rte_uuid_is_null(uids[i])) {
+ printf("Generated random uuid %d is null\n", i);
+ return TEST_FAILED;
+ }
+ }
+
+
+ /* Test that copy works */
+ for (i = 0; i < NROUNDS; i++) {
+ if (!rte_uuid_is_null(clone[i])) {
+ printf("Zero'd clone %d is not null\n", i);
+ return TEST_FAILED;
+ }
+
+ rte_uuid_copy(clone[i], uids[i]);
+
+ if (rte_uuid_compare(uids[i], clone[i]) != 0) {
+ printf("Copied uuid does not match\n");
+ return TEST_FAILED;
+ }
+ }
+
+ for (i = 0; i < RTE_DIM(good_cases); i++) {
+ const struct uuid_case *c = &good_cases[i];
+ char out[37];
+ rte_uuid_t uu;
+
+ if (rte_uuid_parse(c->in, uu) != 0) {
+ printf("Failed to parse '%s'\n", c->in);
+ return TEST_FAILED;
+ }
+ if (rte_uuid_compare(uu, c->result) != 0) {
+ printf("Parse mismatch for '%s'\n", c->in);
+ return TEST_FAILED;
+ }
+
+ rte_uuid_unparse(uu, out, sizeof(out));
+ if (strcmp(out, c->in) != 0) {
+ printf("Parse/unparse mismatch (%s != %s)\n",
+ out, c->in);
+ return TEST_FAILED;
+ }
+ }
+
+ for (i = 0; i < RTE_DIM(bad_cases); i++) {
+ const char *s = bad_cases[i];
+ rte_uuid_t uu;
+
+ if (rte_uuid_parse(s, uu) == 0) {
+ printf("Accepted parse of '%s'\n", s);
+ return TEST_FAILED;
+ }
+ }
+ return TEST_SUCCESS;
+}
+
+
+REGISTER_FAST_TEST(uuid_autotest, true, true, test_uuid);
--
2.43.0
next prev parent reply other threads:[~2024-04-09 17:07 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 16:32 [PATCH 0/2] uuid: enhancements and tests Stephen Hemminger
2024-04-03 16:32 ` [PATCH 1/2] eal: add functions to generate uuid values Stephen Hemminger
2024-04-04 16:11 ` Tyler Retzlaff
2024-04-03 16:32 ` [PATCH 2/2] test: add functional test for uuid Stephen Hemminger
2024-04-03 22:11 ` [PATCH v2 0/2] uuid: add generate functions and tests Stephen Hemminger
2024-04-03 22:11 ` [PATCH v2 1/2] eal: add functions to generate uuid values Stephen Hemminger
2024-04-04 16:16 ` Tyler Retzlaff
2024-04-03 22:11 ` [PATCH v2 2/2] test: add functional test for uuid Stephen Hemminger
2024-04-04 16:18 ` Tyler Retzlaff
2024-04-04 16:22 ` [PATCH v3 0/2] uuid: add generate functions and tests Stephen Hemminger
2024-04-04 16:22 ` [PATCH v3 1/2] eal: add functions to generate uuid values Stephen Hemminger
2024-04-04 16:22 ` [PATCH v3 2/2] test: add functional test for uuid Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 00/30] replace use of rte_memcpy with fixed sizes Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 01/30] cocci/rte_memcpy: add script to eliminate fixed size rte_memcpy Stephen Hemminger
2024-04-06 9:01 ` Morten Brørup
2024-04-05 16:53 ` [PATCH v4 02/30] eal: replace use of " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 03/30] ethdev: replace uses of rte_memcpy Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 04/30] eventdev: replace use of fixed size rte_memcpy Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 05/30] cryptodev: " Stephen Hemminger
2024-04-10 15:40 ` [EXTERNAL] " Akhil Goyal
2024-04-05 16:53 ` [PATCH v4 06/30] ip_frag: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 07/30] net: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 08/30] lpm: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 09/30] node: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 10/30] pdcp: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 11/30] pipeline: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 12/30] rib: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 13/30] security: " Stephen Hemminger
2024-04-10 15:40 ` [EXTERNAL] " Akhil Goyal
2024-04-05 16:53 ` [PATCH v4 14/30] bus: remove unneeded rte_memcpy.h include Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 15/30] net: replace use of fixed size rte_memcpy Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 16/30] raw: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 17/30] baseband: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 18/30] common: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 19/30] crypto: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 20/30] " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 21/30] event: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 22/30] mempool: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 23/30] ml/cnxk: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 24/30] app/test-pmd: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 25/30] app/graph: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 26/30] app/test-eventdev: " Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 27/30] app/test: " Stephen Hemminger
2024-04-10 18:28 ` [EXTERNAL] " Akhil Goyal
2024-04-05 16:53 ` [PATCH v4 28/30] app/test-pipeline: remove unused rte_memcpy.h include Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 29/30] app/test-bbdev: remove unnecessary include of rte_memcpy.h Stephen Hemminger
2024-04-05 16:53 ` [PATCH v4 30/30] examples: replace use of fixed size rte_memcpy Stephen Hemminger
2024-04-09 17:05 ` [PATCH v4 0/2] uuid: generator functions and unit test Stephen Hemminger
2024-04-09 17:05 ` [PATCH v4 1/2] eal: add functions to generate uuid values Stephen Hemminger
2024-04-09 17:05 ` Stephen Hemminger [this message]
2024-05-22 3:27 ` [PATCH v5 00/32] replace use of rte_memcpy() with fixed size Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 01/32] cocci/rte_memcpy: add script to eliminate fixed size rte_memcpy Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 02/32] eal: replace use of " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 03/32] ethdev: replace uses of rte_memcpy Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 04/32] eventdev: replace use of fixed size rte_memcpy Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 05/32] cryptodev: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 06/32] ip_frag: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 07/32] net: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 08/32] lpm: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 09/32] node: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 10/32] pdcp: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 11/32] pipeline: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 12/32] rib: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 13/32] security: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 14/32] bus: remove unneeded rte_memcpy.h include Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 15/32] raw: replace use of fixed size rte_memcpy Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 16/32] baseband: " Stephen Hemminger
2024-05-23 18:28 ` Chautru, Nicolas
2024-05-22 3:27 ` [PATCH v5 17/32] common: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 18/32] crypto: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 19/32] event: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 20/32] mempool: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 21/32] ml/cnxk: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 22/32] app/test-pmd: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 23/32] app/graph: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 24/32] app/test-eventdev: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 25/32] app/test: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 26/32] app/test-pipeline: remove unused rte_memcpy.h include Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 27/32] app/test-bbdev: remove unnecessary include of rte_memcpy.h Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 28/32] examples: replace use of fixed size rte_memcpy Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 29/32] net/null: replace use of fixed size memcpy Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 30/32] net/tap: replace use of fixed size rte_memcpy Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 31/32] net/pcap: " Stephen Hemminger
2024-05-22 3:27 ` [PATCH v5 32/32] net/af_xdp:: " Stephen Hemminger
2024-05-26 14:51 ` [PATCH v5 00/32] replace use of rte_memcpy() with fixed size Mattias Rönnblom
2024-05-26 23:32 ` Stephen Hemminger
2024-05-27 6:06 ` Mattias Rönnblom
2024-05-27 6:38 ` Morten Brørup
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240409170602.541658-3-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).