Re: [PATCH v2 1/6] tests: remove reliance on buffer behaviour of stderr/stdout streams

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

 



On Tue, Aug 27, 2019 at 01:17:48PM +0200, Karel Zak wrote:
> On Fri, Aug 23, 2019 at 03:32:53PM +0200, Patrick Steinhardt wrote:
> > +	if [ "$TS_ENABLE_ASAN" == "yes" ]; then
> > +		args+=(ASAN_OPTIONS='detect_leaks=1')
> > +	fi
> > +
> >  	#
> > -	# ASAN mode
> > +	# Disable buffering of stdout
> >  	#
> > -	elif [ "$TS_ENABLE_ASAN" == "yes" ]; then
> > -		ASAN_OPTIONS='detect_leaks=1' "$@"
> > +	if [ -n "$UNBUFFERED" ]; then
> > +		if type stdbuf >/dev/null 2>&1; then
> > +			args+=(stdbuf --output=0)
> > +		fi
> > +	fi
> >  
> >  	#
> > -	# Default mode
> > +	# valgrind mode
> >  	#
> > -	else
> > -		"$@"
> > +	if [ -n "$TS_VALGRIND_CMD" ]; then
> > +		args+=(libtool --mode=execute "$TS_VALGRIND_CMD" --tool=memcheck --leak-check=full)
> > +		args+=(--leak-resolution=high --num-callers=20 --log-file="$TS_VGDUMP")
> >  	fi
> > +
> > +	"${args[@]}" "$@"
> >  }
> 
> Unfortunately, it seems "${args[@]}" does not work when environment
> variable used:

Huh. If I remember correctly then I did actually test that this
works, but oh, well...

>   ASAN_OPTIONS=detect_leaks=1 stdbuf --output=0 /home/projects/util-linux/util-linux/mkswap --label 1234567890abcdef --uuid 12345678-abcd-abcd-abcd-1234567890ab /dev/sdc
> 
> ends with
> 
>   ./tests/ts/misc/../../functions.sh: line 465: ASAN_OPTIONS=detect_leaks=1: command not found
> 
> And it's more tricky, it seems ASAN binary cannot be executed by stdbuf
> 
>   # stdbuf --output=0 /home/projects/util-linux/util-linux/mkswap --label 1234567890abcdef --uuid 12345678-abcd-abcd-abcd-1234567890ab /dev/sdc
>   ==28469==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
> 
> it's because stdbuf is hack based on LD_PRELOAD which makes it
> difficult to use with ASAN...
> 
> I have tried to fix it by
> https://github.com/karelzak/util-linux/commit/f612c4c674e8e07fc40644432d8147a05c62058e
> 
> ... but it's really not perfect. I have used "unbuffer" (from expect)
> rather than stdbuf. The question is how usable it will be... (but all
> tests passed).
> 
> Note that you can try to use ASAN by ./configure --enable-asan, the
> script tests/run.sh should be smart enough to detect it and then
> individual tests are executed with --memcheck-asan.

Thanks a lot for fixing this up for ASAN then. I've tried to get
ASAN running on musl libc multiple times, but didn't yet have any
luck in doing so as it will always crash immediately. I'll
probably have to invest some more time here at some point to get
this working.

> So, merged -- please, test it with musl libc. 

In fact there's one more test failure in fdisk/oddinput. Seems
like patch 6/6 (fdisk: avoid hardcoding of errno string,
2019-08-23) wasn't applied yet?

Patrick

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux