[PATCH 4/5] libmultipath tests: fix strerror() difference between musl and glibc

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

 



From: Martin Wilck <mwilck@xxxxxxxx>

If an error occurs with errno=0, strerror() on musl returns a different
string than "Success". Make sure the test doesn't fail for that reason.

Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
---
 tests/alias.c    | 2 +-
 tests/test-log.c | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/alias.c b/tests/alias.c
index 5624138..7fda679 100644
--- a/tests/alias.c
+++ b/tests/alias.c
@@ -712,7 +712,7 @@ static void al_write_err(void **state)
 	will_return(__wrap_write, strlen(ln) - 1);
 	expect_value(__wrap_ftruncate, length, offset);
 	will_return(__wrap_ftruncate, 0);
-	expect_condlog(0, "Cannot write binding to bindings file : Success\n");
+	expect_condlog(0, "Cannot write binding to bindings file :");
 
 	alias = allocate_binding(0, "WWIDa", 1, "MPATH");
 	assert_ptr_equal(alias, NULL);
diff --git a/tests/test-log.c b/tests/test-log.c
index 051491e..1c901cb 100644
--- a/tests/test-log.c
+++ b/tests/test-log.c
@@ -2,6 +2,7 @@
 #include <stddef.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <string.h>
 #include <cmocka.h>
 #include "log.h"
 #include "test-log.h"
@@ -11,12 +12,14 @@ void __wrap_dlog (int sink, int prio, const char * fmt, ...)
 {
 	char buff[MAX_MSG_SIZE];
 	va_list ap;
+	char *expected;
 
 	check_expected(prio);
 	va_start(ap, fmt);
 	vsnprintf(buff, MAX_MSG_SIZE, fmt, ap);
 	va_end(ap);
-	assert_string_equal(buff, mock_ptr_type(char *));
+	expected = mock_ptr_type(char *);
+	assert_memory_equal(buff, expected, strlen(expected));
 }
 
 void expect_condlog(int prio, char *string)
-- 
2.29.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