[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] tests: clean up fedora.sh
From: |
Jim Meyering |
Subject: |
[PATCH] tests: clean up fedora.sh |
Date: |
Sun, 14 Mar 2010 12:18:44 +0100 |
The new fedora.sh test was annoyingly slow.
Yeah, 3 seconds is "slow" for some of us ;-)
This fixes it, along with a little clean up and concurrency-protection.
It relies on the "timeout" program[0], but if it's not available,
the three sub-tests that require that are silently skipped.
Jim
[0] timeout has been in coreutils since 7.0
>From 45be60187525b45b3d979d45f365c89fd321fc54 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 14 Mar 2010 11:07:39 +0100
Subject: [PATCH] tests: clean up fedora.sh
* tests/fedora.sh: Use "grep", not ${GREP}.
Use init.sh.
Use timeout 10, not sleep 1 (three times).
The latter would always sleep for 3 seconds, and the test would
fail with a false positive on a slow system or with a heavily
instrumented (valgrind) executable.
---
tests/fedora.sh | 56 +++++++++++++++++++++++++++++-------------------------
1 files changed, 30 insertions(+), 26 deletions(-)
diff --git a/tests/fedora.sh b/tests/fedora.sh
index a179271..2b2fe83 100644
--- a/tests/fedora.sh
+++ b/tests/fedora.sh
@@ -1,5 +1,8 @@
#!/bin/bash
+: ${srcdir=.}
+. "$srcdir/init.sh"; path_prepend_ ../src
+
# GREP Regression test suite for Fedora bugs and fixes
# (c) 2008 Lubomir Rintel
# Licensed under the same terms as GNU Grep itself
@@ -31,45 +34,46 @@ cat > 116909.out <<EOF
a
c
EOF
-${GREP} -F -w -f 116909.list 116909.in | diff - 116909.out && ok || fail
+grep -F -w -f 116909.list 116909.in | diff - 116909.out && ok || fail
U=https://bugzilla.redhat.com/show_bug.cgi?id=123362
echo -n "bad handling of brackets in UTF-8: "
echo Y > 123362.out
-echo Y | LC_ALL=de_DE.UTF-8 ${GREP} -i '[y,Y]' | diff - 123362.out && ok | fail
+echo Y | LC_ALL=de_DE.UTF-8 grep -i '[y,Y]' | diff - 123362.out && ok | fail
U=https://bugzilla.redhat.com/show_bug.cgi?id=112869
echo -n "crash with \W: "
echo '<form>' > 112869.out
-LANG=it_IT ${GREP} -iE '\Wform\W' 112869.out | diff - 112869.out && ok || fail
-
-U=https://bugzilla.redhat.com/show_bug.cgi?id=189580
-echo -n "grep -D skip opening a special file: "
-${GREP} -D skip foo /dev/zero &
-sleep 1
-kill $! 2>/dev/null && fail || ok
-
-U=https://bugzilla.redhat.com/show_bug.cgi?id=169524
-echo -n "grep -Fw looping infinitely: "
-echo foobar | ${GREP} -Fw "" &
-sleep 1
-kill $! 2>/dev/null && fail || ok
-
-U=https://bugzilla.redhat.com/show_bug.cgi?id=140781
-echo -n "fgrep hangs on binary files: "
-${GREP} -F grep $(which ${GREP}) >/dev/null &
-sleep 1
-kill $! 2>/dev/null && fail || ok
+LANG=it_IT grep -iE '\Wform\W' 112869.out | diff - 112869.out && ok || fail
+
+if ( timeout --version ) > /dev/null 2>&1; then
+
+ U=https://bugzilla.redhat.com/show_bug.cgi?id=189580
+ echo -n "grep -D skip opening a special file: "
+ timeout 10 grep -D skip foo /dev/zero
+ test $? = 124 && fail || ok
+
+ U=https://bugzilla.redhat.com/show_bug.cgi?id=169524
+ echo -n "grep -Fw looping infinitely: "
+ echo foobar | timeout 10 grep -Fw ""
+ test $? = 124 && fail || ok
+
+ U=https://bugzilla.redhat.com/show_bug.cgi?id=140781
+ echo -n "fgrep hangs on binary files: "
+ timeout 10 grep -F grep "$abs_top_builddir/src/grep" >/dev/null
+ test $? = 124 && fail || ok
+
+fi
U=https://bugzilla.redhat.com/show_bug.cgi?id=161700
echo -n "grep -Fw fails to match anything: "
echo test > 161700.out
-${GREP} -Fw test 161700.out | diff - 161700.out && ok || fail
+grep -Fw test 161700.out | diff - 161700.out && ok || fail
U=https://bugzilla.redhat.com/show_bug.cgi?id=179698
echo -n "grep -w broken in non-utf8 multibyte locales: "
echo za a > 179698.out
-LANG=ja_JP.eucjp ${GREP} -w a 179698.out | diff - 179698.out && ok || fail
+LANG=ja_JP.eucjp grep -w a 179698.out | diff - 179698.out && ok || fail
# Skip the rest of tests in compiled without PCRE
echo a |grep -P a >/dev/null || exit $failures
@@ -77,7 +81,7 @@ echo a |grep -P a >/dev/null || exit $failures
U=https://bugzilla.redhat.com/show_bug.cgi?id=171379
echo -n "grep -P crashes on whitespace lines: "
echo ' ' > 171379.out
-${GREP} -P '^\s+$' 171379.out | diff - 171379.out && ok || fail
+grep -P '^\s+$' 171379.out | diff - 171379.out && ok || fail
U=https://bugzilla.redhat.com/show_bug.cgi?id=204255
echo -n "-e '' does not work if not a first parameter: "
@@ -87,10 +91,10 @@ diff 204255.first 204255.second && ok || fail
U=https://bugzilla.redhat.com/show_bug.cgi?id=324781
echo -n "bad handling of line breaks with grep -P #1: "
-echo -ne "a\na" | ${GREP} -P '[^a]' >/dev/null && fail || ok
+echo -ne "a\na" | grep -P '[^a]' >/dev/null && fail || ok
# This is mostly a check that fix for above doesn't break -P further
echo -n "bad handling of line breaks with grep -P #2: "
-echo -ne "a\na" | ${GREP} -P '[^b].[^b]' >/dev/null && fail || ok
+echo -ne "a\na" | grep -P '[^b].[^b]' >/dev/null && fail || ok
exit $failures
--
1.7.0.2.393.gfb6b
- [PATCH] tests: clean up fedora.sh,
Jim Meyering <=