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

Martin Wilck mwilck at suse.com
Tue Nov 3 08:32:11 UTC 2020


On Mon, 2020-11-02 at 13:58 -0600, Benjamin Marzinski wrote:
> On Tue, Oct 27, 2020 at 11:45:35PM +0100, mwilck at suse.com wrote:
> > 
> >  	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));
> 
> This looks fine. I'm just wondering the purpose. Is it just to deal
> with
> bad,non-null terminated strings? 

No. In the case at hand, the error strings returned by the C library,
which are at the tail of the log message in this case, were different.
We're looking at an errno==0 case, where glibc returns "Success",
whereas musl returned something else (like "undefined error" or so, I
forgot the exact wording).

The downside of this patch is that if a mismatch occurs,
assert_string_equal() prints the two different strings, whereas
assert_memory_equal() prints differing offsets and values in hex, which
makes it more difficult to assess the cause of the mismatch.

Regards,
Martin





More information about the dm-devel mailing list