From: Dmitry V. Levin Date: Tue, 13 Dec 2016 19:59:47 +0000 (+0000) Subject: tests: workaround a bug in GNU grep X-Git-Tag: v4.15~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3dac7272e880b9136869f5d72caadf6d68cf99af;p=strace tests: workaround a bug in GNU grep Workaround a bug introduced in GNU grep 2.27, for details see https://lists.gnu.org/archive/html/bug-grep/2016-12/msg00011.html * tests/init.sh (grep_pid_status): New function. * tests/detach-running.test: Use it instead of grep to search in /proc/$pid/status. * tests/detach-sleeping.test: Likewise. * tests/detach-stopped.test: Likewise. --- diff --git a/tests/detach-running.test b/tests/detach-running.test index b77dc51c..006efb85 100755 --- a/tests/detach-running.test +++ b/tests/detach-running.test @@ -79,8 +79,8 @@ if [ -f /proc/self/status ]; then cleanup dump_log_and_fail_with 'tracee died after detach' } - grep '^State:.*R (running)' < /proc/$tracee_pid/status > /dev/null || { - grep '^State:' < /proc/$tracee_pid/status + grep_pid_status "$tracee_pid" '^State:.*R (running)' > /dev/null || { + grep_pid_status "$tracee_pid" '^State:' cleanup dump_log_and_fail_with 'tracee is not running after detach' } diff --git a/tests/detach-sleeping.test b/tests/detach-sleeping.test index 546c21d9..54304f31 100755 --- a/tests/detach-sleeping.test +++ b/tests/detach-sleeping.test @@ -80,8 +80,8 @@ if [ -f /proc/self/status ]; then cleanup dump_log_and_fail_with 'tracee died after detach' } - grep '^State:.*S (sleeping)' < /proc/$tracee_pid/status > /dev/null || { - grep '^State:' < /proc/$tracee_pid/status + grep_pid_status "$tracee_pid" '^State:.*S (sleeping)' > /dev/null || { + grep_pid_status "$tracee_pid" '^State:' cleanup dump_log_and_fail_with 'tracee is not sleeping after detach' } diff --git a/tests/detach-stopped.test b/tests/detach-stopped.test index ca4d4e95..8f480e7f 100755 --- a/tests/detach-stopped.test +++ b/tests/detach-stopped.test @@ -95,8 +95,8 @@ if [ -f /proc/self/status ]; then cleanup dump_log_and_fail_with 'tracee died after detach' } - grep '^State:.*T (stopped)' < /proc/$tracee_pid/status > /dev/null || { - grep '^State:' < /proc/$tracee_pid/status + grep_pid_status "$tracee_pid" '^State:.*T (stopped)' > /dev/null || { + grep_pid_status "$tracee_pid" '^State:' cleanup dump_log_and_fail_with 'tracee is not group-stopped after detach' } diff --git a/tests/init.sh b/tests/init.sh index 3fe5a886..f368b98a 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -242,6 +242,14 @@ require_min_kernel_version_or_skip() skip_ "the kernel release $uname_r is not $1 or newer" } +# Usage: grep_pid_status $pid GREP-OPTIONS... +grep_pid_status() +{ + local pid + pid=$1; shift + cat < "/proc/$pid/status" | grep "$@" +} + check_prog cat check_prog rm