[PATCH 12/72] multipath tests: alias: add format/scan test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Martin Wilck <mwilck@xxxxxxxx>

Test scan_devname(format_devname(id)) == id.

Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
---
 tests/alias.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/tests/alias.c b/tests/alias.c
index 170ebbeb..30414db0 100644
--- a/tests/alias.c
+++ b/tests/alias.c
@@ -297,6 +297,34 @@ static void sd_max_p1(void **state)
 }
 #endif
 
+static void sd_fd_many(void **state)
+{
+	char buf[32];
+	int rc, i;
+
+	for (i = 1; i < 5000; i++) {
+		rc = format_devname(buf, i, sizeof(buf), "MPATH");
+		assert_in_range(rc, 6, 8);
+		rc = scan_devname(buf, "MPATH");
+		assert_int_equal(rc, i);
+	}
+}
+
+static void sd_fd_random(void **state)
+{
+	char buf[32];
+	int rc, i, n;
+
+	srandom(1);
+	for (i = 1; i < 1000; i++) {
+		n = random() & 0xffff;
+		rc = format_devname(buf, n, sizeof(buf), "MPATH");
+		assert_in_range(rc, 6, 9);
+		rc = scan_devname(buf, "MPATH");
+		assert_int_equal(rc, n);
+	}
+}
+
 static int test_scan_devname(void)
 {
 	const struct CMUnitTest tests[] = {
@@ -314,6 +342,8 @@ static int test_scan_devname(void)
 		cmocka_unit_test(sd_max),
 		cmocka_unit_test(sd_max_p1),
 #endif
+		cmocka_unit_test(sd_fd_many),
+		cmocka_unit_test(sd_fd_random),
 	};
 
 	return cmocka_run_group_tests(tests, NULL, NULL);
-- 
2.23.0


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel



[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux