diff mbox series

[06/21] multipath-tools test: simplify debugging for condlog mismatch

Message ID 20230901180235.23980-7-mwilck@suse.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series multipath-tools: user-friendly names rework | expand

Commit Message

Martin Wilck Sept. 1, 2023, 6:02 p.m. UTC
From: Martin Wilck <mwilck@suse.com>

If there's a mismatch between expected and actual log message,
print both messages.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 tests/test-log.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Benjamin Marzinski Sept. 6, 2023, 10:43 p.m. UTC | #1
On Fri, Sep 01, 2023 at 08:02:19PM +0200, mwilck@suse.com wrote:
> From: Martin Wilck <mwilck@suse.com>
> 
> If there's a mismatch between expected and actual log message,
> print both messages.
> 
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
>  tests/test-log.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/test-log.c b/tests/test-log.c
> index c174587..6351699 100644
> --- a/tests/test-log.c
> +++ b/tests/test-log.c
> @@ -16,12 +16,14 @@ void __wrap_dlog (int prio, const char * fmt, ...)
>  	va_list ap;
>  	char *expected;
>  
> -	check_expected(prio);
>  	va_start(ap, fmt);
>  	vsnprintf(buff, MAX_MSG_SIZE, fmt, ap);
>  	va_end(ap);
>  	fprintf(stderr, "%s(%d): %s", __func__, prio, buff);
>  	expected = mock_ptr_type(char *);
> +	if (memcmp(expected, buff, strlen(expected)))
> +		fprintf(stderr, "%s(expected): %s", __func__, expected);
> +	check_expected(prio);
>  	assert_memory_equal(buff, expected, strlen(expected));
>  }
>  
> -- 
> 2.41.0
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
diff mbox series

Patch

diff --git a/tests/test-log.c b/tests/test-log.c
index c174587..6351699 100644
--- a/tests/test-log.c
+++ b/tests/test-log.c
@@ -16,12 +16,14 @@  void __wrap_dlog (int prio, const char * fmt, ...)
 	va_list ap;
 	char *expected;
 
-	check_expected(prio);
 	va_start(ap, fmt);
 	vsnprintf(buff, MAX_MSG_SIZE, fmt, ap);
 	va_end(ap);
 	fprintf(stderr, "%s(%d): %s", __func__, prio, buff);
 	expected = mock_ptr_type(char *);
+	if (memcmp(expected, buff, strlen(expected)))
+		fprintf(stderr, "%s(expected): %s", __func__, expected);
+	check_expected(prio);
 	assert_memory_equal(buff, expected, strlen(expected));
 }