Subject: bug#29887: tests/misc/stdbuf is unstable

From: Thomas Deutschmann <[email-masked]>
Date: Fri, 29 Dec 2017 03:45:30 +0100

Hi,

tests/misc/stdbuf seems to be unstable. Sometimes we see failures like

> FAIL: tests/misc/stdbuf
> =======================
> 
> ++ initial_cwd_=/var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28
> +++ testdir_prefix_
> +++ printf gt
> ++ pfx_=gt
> +++ mktempd_ /var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28 gt-stdbuf.sh.XXXX
> +++ case $# in
> +++ destdir_=/var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28
> +++ template_=gt-stdbuf.sh.XXXX
> +++ MAX_TRIES_=4
> +++ case $destdir_ in
> +++ destdir_slash_=/var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28/
> +++ case $template_ in
> ++++ unset TMPDIR
> +++ d=/var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28/gt-stdbuf.sh.g3HO
> +++ case $d in
> +++ :
> +++ test -d /var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28/gt-stdbuf.sh.g3HO
> ++++ ls -dgo /var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28/gt-stdbuf.sh.g3HO
> +++ perms='drwx------ 2 4096 Nov 23 17:08 /var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28/gt-stdbuf.sh.g3HO'
> +++ case $perms in
> +++ :
> +++ echo /var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28/gt-stdbuf.sh.g3HO
> +++ return
> ++ test_dir_=/var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28/gt-stdbuf.sh.g3HO
> ++ cd /var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28/gt-stdbuf.sh.g3HO
> ++ gl_init_sh_nl_='
> '
> ++ IFS=' 	
> '
> ++ for sig_ in 1 2 3 13 15
> +++ expr 1 + 128
> ++ eval 'trap '\''Exit 129'\'' 1'
> +++ trap 'Exit 129' 1
> ++ for sig_ in 1 2 3 13 15
> +++ expr 2 + 128
> ++ eval 'trap '\''Exit 130'\'' 2'
> +++ trap 'Exit 130' 2
> ++ for sig_ in 1 2 3 13 15
> +++ expr 3 + 128
> ++ eval 'trap '\''Exit 131'\'' 3'
> +++ trap 'Exit 131' 3
> ++ for sig_ in 1 2 3 13 15
> +++ expr 13 + 128
> ++ eval 'trap '\''Exit 141'\'' 13'
> +++ trap 'Exit 141' 13
> ++ for sig_ in 1 2 3 13 15
> +++ expr 15 + 128
> ++ eval 'trap '\''Exit 143'\'' 15'
> +++ trap 'Exit 143' 15
> ++ trap remove_tmp_ 0
> + path_prepend_ ./src
> + test 1 '!=' 0
> + path_dir_=./src
> + case $path_dir_ in
> + abs_path_dir_=/var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28/./src
> + case $abs_path_dir_ in
> + PATH=/var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28/./src:/var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28/src:/var/tmp/portage/sys-apps/coreutils-8.28-r1/temp/mount-wrappers:/var/tmp/portage/sys-apps/coreutils-8.28-r1/temp/python2.7/bin:/usr/lib/portage/python2.7/ebuild-helpers/xattr:/usr/lib/portage/python2.7/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/sparc-unknown-linux-gnu/gcc-bin/5.4.0
> + create_exe_shims_ /var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28/./src
> + case $EXEEXT in
> + return 0
> + shift
> + test 0 '!=' 0
> + export PATH
> + print_ver_ stdbuf
> + require_built_ stdbuf
> + skip_=no
> + for i in '"$@"'
> + case " $built_programs " in
> + test no = yes
> + test yes = yes
> + local i
> + for i in '$*'
> + env stdbuf --version
> stdbuf (GNU coreutils) 8.28
> Packaged by Gentoo (8.28-r1)
> Copyright (C) 2017 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> 
> Written by Padraig Brady.
> + getlimits_
> ++ getlimits
> + eval CHAR_MAX=127 CHAR_OFLOW=128 CHAR_MIN=-128 CHAR_UFLOW=-129 SCHAR_MAX=127 SCHAR_OFLOW=128 SCHAR_MIN=-128 SCHAR_UFLOW=-129 UCHAR_MAX=255 UCHAR_OFLOW=256 SHRT_MAX=32767 SHRT_OFLOW=32768 SHRT_MIN=-32768 SHRT_UFLOW=-32769 INT_MAX=2147483647 INT_OFLOW=2147483648 INT_MIN=-2147483648 INT_UFLOW=-2147483649 UINT_MAX=4294967295 UINT_OFLOW=4294967296 LONG_MAX=2147483647 LONG_OFLOW=2147483648 LONG_MIN=-2147483648 LONG_UFLOW=-2147483649 ULONG_MAX=4294967295 ULONG_OFLOW=4294967296 SIZE_MAX=4294967295 SIZE_OFLOW=4294967296 SSIZE_MAX=2147483647 SSIZE_OFLOW=2147483648 SSIZE_MIN=-2147483648 SSIZE_UFLOW=-2147483649 TIME_T_MAX=2147483647 TIME_T_OFLOW=2147483648 TIME_T_MIN=-2147483648 TIME_T_UFLOW=-2147483649 UID_T_MAX=4294967295 UID_T_OFLOW=4294967296 GID_T_MAX=4294967295 GID_T_OFLOW=4294967296 PID_T_MAX=2147483647 PID_T_OFLOW=2147483648 PID_T_MIN=-2147483648 PID_T_UFLOW=-2147483649 OFF_T_MAX=9223372036854775807 OFF_T_OFLOW=9223372036854775808 OFF_T_MIN=-9223372036854775808 OFF_T_UFLOW=-9223372036854775809 INTMAX_MAX=9223372036854775807 INTMAX_OFLOW=9223372036854775808 INTMAX_MIN=-9223372036854775808 INTMAX_UFLOW=-9223372036854775809 UINTMAX_MAX=18446744073709551615 UINTMAX_OFLOW=18446744073709551616 FLT_MIN=1.1754944e-38 FLT_MAX=3.4028235e+38 DBL_MIN=2.2250738585072014e-308 DBL_MAX=1.7976931348623157e+308 LDBL_MIN=3.3621031431120935062626778173217526e-4932 LDBL_MAX=1.189731495357231765085759326628007e+4932
> ++ CHAR_MAX=127
> ++ CHAR_OFLOW=128
> ++ CHAR_MIN=-128
> ++ CHAR_UFLOW=-129
> ++ SCHAR_MAX=127
> ++ SCHAR_OFLOW=128
> ++ SCHAR_MIN=-128
> ++ SCHAR_UFLOW=-129
> ++ UCHAR_MAX=255
> ++ UCHAR_OFLOW=256
> ++ SHRT_MAX=32767
> ++ SHRT_OFLOW=32768
> ++ SHRT_MIN=-32768
> ++ SHRT_UFLOW=-32769
> ++ INT_MAX=2147483647
> ++ INT_OFLOW=2147483648
> ++ INT_MIN=-2147483648
> ++ INT_UFLOW=-2147483649
> ++ UINT_MAX=4294967295
> ++ UINT_OFLOW=4294967296
> ++ LONG_MAX=2147483647
> ++ LONG_OFLOW=2147483648
> ++ LONG_MIN=-2147483648
> ++ LONG_UFLOW=-2147483649
> ++ ULONG_MAX=4294967295
> ++ ULONG_OFLOW=4294967296
> ++ SIZE_MAX=4294967295
> ++ SIZE_OFLOW=4294967296
> ++ SSIZE_MAX=2147483647
> ++ SSIZE_OFLOW=2147483648
> ++ SSIZE_MIN=-2147483648
> ++ SSIZE_UFLOW=-2147483649
> ++ TIME_T_MAX=2147483647
> ++ TIME_T_OFLOW=2147483648
> ++ TIME_T_MIN=-2147483648
> ++ TIME_T_UFLOW=-2147483649
> ++ UID_T_MAX=4294967295
> ++ UID_T_OFLOW=4294967296
> ++ GID_T_MAX=4294967295
> ++ GID_T_OFLOW=4294967296
> ++ PID_T_MAX=2147483647
> ++ PID_T_OFLOW=2147483648
> ++ PID_T_MIN=-2147483648
> ++ PID_T_UFLOW=-2147483649
> ++ OFF_T_MAX=9223372036854775807
> ++ OFF_T_OFLOW=9223372036854775808
> ++ OFF_T_MIN=-9223372036854775808
> ++ OFF_T_UFLOW=-9223372036854775809
> ++ INTMAX_MAX=9223372036854775807
> ++ INTMAX_OFLOW=9223372036854775808
> ++ INTMAX_MIN=-9223372036854775808
> ++ INTMAX_UFLOW=-9223372036854775809
> ++ UINTMAX_MAX=18446744073709551615
> ++ UINTMAX_OFLOW=18446744073709551616
> ++ FLT_MIN=1.1754944e-38
> ++ FLT_MAX=3.4028235e+38
> ++ DBL_MIN=2.2250738585072014e-308
> ++ DBL_MAX=1.7976931348623157e+308
> ++ LDBL_MIN=3.3621031431120935062626778173217526e-4932
> ++ LDBL_MAX=1.189731495357231765085759326628007e+4932
> + test 2147483647
> + lf='
> '
> + case $abs_top_builddir in
> + mkfifo_or_skip_ fifo
> + test 1 = 1
> + mkfifo fifo
> + stdbuf -o1 true
> + stdbuf -oK true
> + stdbuf -o0 true
> + stdbuf -oL true
> + returns_ 125 stdbuf -ol true
> stdbuf: invalid mode 'l'
> + returns_ 125 stdbuf -o4294967296 true
> stdbuf: invalid mode '4294967296': Value too large for defined data type
> + returns_ 125 stdbuf -iL true
> stdbuf: line buffering stdin is meaningless
> Try 'stdbuf --help' for more information.
> + returns_ 125 stdbuf true
> stdbuf: you must specify a buffering mode option
> Try 'stdbuf --help' for more information.
> + stdbuf -i0 -o0 -e0 true
> + returns_ 126 stdbuf -o1 .
> stdbuf: failed to run command '.': Permission denied
> + returns_ 127 stdbuf -o1 no_such
> stdbuf: failed to run command 'no_such': No such file or directory
> + retry_delay_ stdbuf_linebuffer .1 6
> + local test_func=stdbuf_linebuffer
> + local init_delay=.1
> + local max_n_tries=6
> + shift 3
> + local attempt=1
> + local num_sleeps=1
> + local time_fail
> + test 1 -le 6
> ++ gawk -v n=1 -v s=.1 'BEGIN { print s * n }'
> + local delay=0.1
> + stdbuf_linebuffer 0.1
> + local delay=0.1
> + printf '1\n'
> + pid=20475
> + dd count=1 if=fifo
> + printf '1\n'
> + sleep 0.1
> + stdbuf -oL uniq
> + printf '2\n'
> + wait 20475
> + compare exp out
> + compare_dev_null_ exp out
> + test 2 = 2
> + test xexp = x/dev/null
> + test xout = x/dev/null
> + return 2
> + case $? in
> + compare_ exp out
> + diff -u exp out
> --- exp	2017-11-23 17:08:16.406549228 +0100
> +++ out	2017-11-23 17:08:16.526549224 +0100
> @@ -1 +1,2 @@
>  1
> +2
> + time_fail=1
> ++ expr 1 + 1
> + attempt=2
> ++ expr 1 '*' 2
> + num_sleeps=2
> + test 2 -le 6
> ++ gawk -v n=2 -v s=.1 'BEGIN { print s * n }'
> + local delay=0.2
> + stdbuf_linebuffer 0.2
> + local delay=0.2
> + printf '1\n'
> + pid=20483
> + dd count=1 if=fifo
> + printf '1\n'
> + sleep 0.2
> + stdbuf -oL uniq
> + printf '2\n'
> + wait 20483
> + compare exp out
> + compare_dev_null_ exp out
> + test 2 = 2
> + test xexp = x/dev/null
> + test xout = x/dev/null
> + return 2
> + case $? in
> + compare_ exp out
> + diff -u exp out
> --- exp	2017-11-23 17:08:16.746549217 +0100
> +++ out	2017-11-23 17:08:16.976549209 +0100
> @@ -1 +1,2 @@
>  1
> +2
> + time_fail=1
> ++ expr 2 + 1
> + attempt=3
> ++ expr 2 '*' 2
> + num_sleeps=4
> + test 3 -le 6
> ++ gawk -v n=4 -v s=.1 'BEGIN { print s * n }'
> + local delay=0.4
> + stdbuf_linebuffer 0.4
> + local delay=0.4
> + printf '1\n'
> + pid=20491
> + dd count=1 if=fifo
> + printf '1\n'
> + sleep 0.4
> + stdbuf -oL uniq
> + printf '2\n'
> + wait 20491
> + compare exp out
> + compare_dev_null_ exp out
> + test 2 = 2
> + test xexp = x/dev/null
> + test xout = x/dev/null
> + return 2
> + case $? in
> + compare_ exp out
> + diff -u exp out
> --- exp	2017-11-23 17:08:17.066549206 +0100
> +++ out	2017-11-23 17:08:17.496549192 +0100
> @@ -1 +1,2 @@
>  1
> +2
> + time_fail=1
> ++ expr 3 + 1
> + attempt=4
> ++ expr 4 '*' 2
> + num_sleeps=8
> + test 4 -le 6
> ++ gawk -v n=8 -v s=.1 'BEGIN { print s * n }'
> + local delay=0.8
> + stdbuf_linebuffer 0.8
> + local delay=0.8
> + printf '1\n'
> + pid=20499
> + dd count=1 if=fifo
> + printf '1\n'
> + sleep 0.8
> + stdbuf -oL uniq
> + printf '2\n'
> + wait 20499
> + compare exp out
> + compare_dev_null_ exp out
> + test 2 = 2
> + test xexp = x/dev/null
> + test xout = x/dev/null
> + return 2
> + case $? in
> + compare_ exp out
> + diff -u exp out
> --- exp	2017-11-23 17:08:17.686549185 +0100
> +++ out	2017-11-23 17:08:18.506549158 +0100
> @@ -1 +1,2 @@
>  1
> +2
> + time_fail=1
> ++ expr 4 + 1
> + attempt=5
> ++ expr 8 '*' 2
> + num_sleeps=16
> + test 5 -le 6
> ++ gawk -v n=16 -v s=.1 'BEGIN { print s * n }'
> + local delay=1.6
> + stdbuf_linebuffer 1.6
> + local delay=1.6
> + printf '1\n'
> + pid=20507
> + dd count=1 if=fifo
> + printf '1\n'
> + sleep 1.6
> + stdbuf -oL uniq
> + printf '2\n'
> + wait 20507
> + compare exp out
> + compare_dev_null_ exp out
> + test 2 = 2
> + test xexp = x/dev/null
> + test xout = x/dev/null
> + return 2
> + case $? in
> + compare_ exp out
> + diff -u exp out
> --- exp	2017-11-23 17:08:18.606549154 +0100
> +++ out	2017-11-23 17:08:20.226549100 +0100
> @@ -1 +1,2 @@
>  1
> +2
> + time_fail=1
> ++ expr 5 + 1
> + attempt=6
> ++ expr 16 '*' 2
> + num_sleeps=32
> + test 6 -le 6
> ++ gawk -v n=32 -v s=.1 'BEGIN { print s * n }'
> + local delay=3.2
> + stdbuf_linebuffer 3.2
> + local delay=3.2
> + printf '1\n'
> + pid=20531
> + dd count=1 if=fifo
> + printf '1\n'
> + sleep 3.2
> + stdbuf -oL uniq
> + printf '2\n'
> + wait 20531
> + compare exp out
> + compare_dev_null_ exp out
> + test 2 = 2
> + test xexp = x/dev/null
> + test xout = x/dev/null
> + return 2
> + case $? in
> + compare_ exp out
> + diff -u exp out
> --- exp	2017-11-23 17:08:20.476549092 +0100
> +++ out	2017-11-23 17:08:23.696548984 +0100
> @@ -1 +1,2 @@
>  1
> +2
> + time_fail=1
> ++ expr 6 + 1
> + attempt=7
> ++ expr 32 '*' 2
> + num_sleeps=64
> + test 7 -le 6
> + test 1 = 0
> + fail=1
> + retry_delay_ stdbuf_unbuffer .1 6
> + local test_func=stdbuf_unbuffer
> + local init_delay=.1
> + local max_n_tries=6
> + shift 3
> + local attempt=1
> + local num_sleeps=1
> + local time_fail
> + test 1 -le 6
> ++ gawk -v n=1 -v s=.1 'BEGIN { print s * n }'
> + local delay=0.1
> + stdbuf_unbuffer 0.1
> + local delay=0.1
> + printf '1\n'
> + pid=20557
> + dd count=1 if=fifo
> + printf '1\n'
> + sleep 0.1
> + stdbuf -o0 uniq
> + printf '2\n'
> + wait 20557
> + compare exp out
> + compare_dev_null_ exp out
> + test 2 = 2
> + test xexp = x/dev/null
> + test xout = x/dev/null
> + return 2
> + case $? in
> + compare_ exp out
> + diff -u exp out
> --- exp	2017-11-23 17:08:23.956548975 +0100
> +++ out	2017-11-23 17:08:24.086548971 +0100
> @@ -1 +1,2 @@
>  1
> +2
> + time_fail=1
> ++ expr 1 + 1
> + attempt=2
> ++ expr 1 '*' 2
> + num_sleeps=2
> + test 2 -le 6
> ++ gawk -v n=2 -v s=.1 'BEGIN { print s * n }'
> + local delay=0.2
> + stdbuf_unbuffer 0.2
> + local delay=0.2
> + printf '1\n'
> + pid=20569
> + dd count=1 if=fifo
> + printf '1\n'
> + sleep 0.2
> + stdbuf -o0 uniq
> + printf '2\n'
> + wait 20569
> + compare exp out
> + compare_dev_null_ exp out
> + test 2 = 2
> + test xexp = x/dev/null
> + test xout = x/dev/null
> + return 2
> + case $? in
> + compare_ exp out
> + diff -u exp out
> --- exp	2017-11-23 17:08:24.176548968 +0100
> +++ out	2017-11-23 17:08:24.406548960 +0100
> @@ -1 +1,2 @@
>  1
> +2
> + time_fail=1
> ++ expr 2 + 1
> + attempt=3
> ++ expr 2 '*' 2
> + num_sleeps=4
> + test 3 -le 6
> ++ gawk -v n=4 -v s=.1 'BEGIN { print s * n }'
> + local delay=0.4
> + stdbuf_unbuffer 0.4
> + local delay=0.4
> + printf '1\n'
> + pid=20578
> + dd count=1 if=fifo
> + printf '1\n'
> + sleep 0.4
> + stdbuf -o0 uniq
> + printf '2\n'
> + wait 20578
> + compare exp out
> + compare_dev_null_ exp out
> + test 2 = 2
> + test xexp = x/dev/null
> + test xout = x/dev/null
> + return 2
> + case $? in
> + compare_ exp out
> + diff -u exp out
> --- exp	2017-11-23 17:08:24.506548957 +0100
> +++ out	2017-11-23 17:08:24.926548942 +0100
> @@ -1 +1,2 @@
>  1
> +2
> + time_fail=1
> ++ expr 3 + 1
> + attempt=4
> ++ expr 4 '*' 2
> + num_sleeps=8
> + test 4 -le 6
> ++ gawk -v n=8 -v s=.1 'BEGIN { print s * n }'
> + local delay=0.8
> + stdbuf_unbuffer 0.8
> + local delay=0.8
> + printf '1\n'
> + pid=20586
> + dd count=1 if=fifo
> + printf '1\n'
> + sleep 0.8
> + stdbuf -o0 uniq
> + printf '2\n'
> + wait 20586
> + compare exp out
> + compare_dev_null_ exp out
> + test 2 = 2
> + test xexp = x/dev/null
> + test xout = x/dev/null
> + return 2
> + case $? in
> + compare_ exp out
> + diff -u exp out
> --- exp	2017-11-23 17:08:25.026548939 +0100
> +++ out	2017-11-23 17:08:25.876548911 +0100
> @@ -1 +1,2 @@
>  1
> +2
> + time_fail=1
> ++ expr 4 + 1
> + attempt=5
> ++ expr 8 '*' 2
> + num_sleeps=16
> + test 5 -le 6
> ++ gawk -v n=16 -v s=.1 'BEGIN { print s * n }'
> + local delay=1.6
> + stdbuf_unbuffer 1.6
> + local delay=1.6
> + printf '1\n'
> + pid=20599
> + dd count=1 if=fifo
> + printf '1\n'
> + stdbuf -o0 uniq
> + sleep 1.6
> + printf '2\n'
> + wait 20599
> + compare exp out
> + compare_dev_null_ exp out
> + test 2 = 2
> + test xexp = x/dev/null
> + test xout = x/dev/null
> + return 2
> + case $? in
> + compare_ exp out
> + diff -u exp out
> --- exp	2017-11-23 17:08:26.076548904 +0100
> +++ out	2017-11-23 17:08:27.706548849 +0100
> @@ -1 +1,2 @@
>  1
> +2
> + time_fail=1
> ++ expr 5 + 1
> + attempt=6
> ++ expr 16 '*' 2
> + num_sleeps=32
> + test 6 -le 6
> ++ gawk -v n=32 -v s=.1 'BEGIN { print s * n }'
> + local delay=3.2
> + stdbuf_unbuffer 3.2
> + local delay=3.2
> + printf '1\n'
> + pid=20611
> + dd count=1 if=fifo
> + printf '1\n'
> + sleep 3.2
> + stdbuf -o0 uniq
> + printf '2\n'
> + wait 20611
> + compare exp out
> + compare_dev_null_ exp out
> + test 2 = 2
> + test xexp = x/dev/null
> + test xout = x/dev/null
> + return 2
> + case $? in
> + compare_ exp out
> + diff -u exp out
> --- exp	2017-11-23 17:08:27.966548840 +0100
> +++ out	2017-11-23 17:08:31.186548732 +0100
> @@ -1 +1,2 @@
>  1
> +2
> + time_fail=1
> ++ expr 6 + 1
> + attempt=7
> ++ expr 32 '*' 2
> + num_sleeps=64
> + test 7 -le 6
> + test 1 = 0
> + fail=1
> + Exit 1
> + set +e
> + exit 1
> + exit 1
> + remove_tmp_
> + __st=1
> + cleanup_
> + kill 20611
> + test '' = yes
> + cd /var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28
> + chmod -R u+rwx /var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28/gt-stdbuf.sh.g3HO
> + rm -rf /var/tmp/portage/sys-apps/coreutils-8.28-r1/work/coreutils-8.28/gt-stdbuf.sh.g3HO
> + exit 1
> FAIL tests/misc/stdbuf.sh (exit status: 1)

It is not reproducible but it happens sometimes.

Bug: https://bugs.gentoo.org/638578

-- 
Regards,
Thomas Deutschmann / Gentoo Linux Developer
C4DD 695F A713 8F24 2AA1 5638 5849 7EE5 1D5D 74A5