]> granicus.if.org Git - strace/commitdiff
tests: workaround a bug in GNU grep
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 13 Dec 2016 19:59:47 +0000 (19:59 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 13 Dec 2016 20:21:22 +0000 (20:21 +0000)
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.

tests/detach-running.test
tests/detach-sleeping.test
tests/detach-stopped.test
tests/init.sh

index b77dc51cee8f87914b2b1547ccf05ec3dc7d3395..006efb8591cf88c42ac6b3fd9322858457f2e234 100755 (executable)
@@ -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'
        }
index 546c21d953b86626889a446ff7ff23f1e561a4f8..54304f3113f2d6cbf072588f0db01f644359ae7f 100755 (executable)
@@ -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'
        }
index ca4d4e95d3ed9fd3d8c13c7003977b2494314b5b..8f480e7f7aec30b038fcccd0a8be6fe0f88e98d1 100755 (executable)
@@ -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'
        }
index 3fe5a886d7113b4b89e86abbd7e1bc6033e0539d..f368b98afa88d621d5be3e1d1b2be7ca18da9c80 100644 (file)
@@ -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