Hi Jim,
Jim Meyering <[email protected]> writes: > Thanks for doing that. > A couple suggestions: Thanks for the suggestions! I am using a 1.5 seconds time interval before kill the debugged process, I hope it is enough when there are many parallel tests. Giuseppe >From e5532992b1e7c018e5754c7082c2d9ac256cee3d Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano <[email protected]> Date: Tue, 20 Oct 2009 10:49:17 +0200 Subject: [PATCH] tests: add a new test that checks for a possible `tail' race. If new data is available between the initial read and tail registers the inotify watch descriptors, ensure that it is read before a new event happens on the file. * tests/Makefile.am (TESTS): Add tail-2/inotify-race. * tests/tail-2/inotify-race: New file. --- tests/Makefile.am | 1 + tests/tail-2/inotify-race | 72 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 0 deletions(-) create mode 100755 tests/tail-2/inotify-race diff --git a/tests/Makefile.am b/tests/Makefile.am index 751db1c..bb11c23 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -74,6 +74,7 @@ EXTRA_DIST += $(TESTS) TESTS = \ misc/help-version \ + tail-2/inotify-race \ misc/invalid-opt \ rm/ext3-perf \ rm/cycle \ diff --git a/tests/tail-2/inotify-race b/tests/tail-2/inotify-race new file mode 100755 index 0000000..3222204 --- /dev/null +++ b/tests/tail-2/inotify-race @@ -0,0 +1,72 @@ +#!/bin/sh +# Copyright (C) 2006, 2009 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + tail --version +fi + +. $srcdir/test-lib.sh + +fail=0 + +umask 2 +touch file || framework_failure + +( gdb --version ) > gdb.out 2>&1 +case $(cat gdb.out) in + 'GNU gdb'*) ;; + *) echo "$0: can't run gdb. Skipping this test." 1>&2; + (exit 77); exit 77;; +esac + + +# Use `xnanosleep' to sleep the debugged process for a specified +# amount of time. `xnanosleep' is used by tail and the symbol is +# exported, so we can use it without problems. + +gdb -nx --batch-silent \ + --eval-command='break tail_forever_inotify' \ + --eval-command='run -f file' \ + --eval-command='quit' \ + $abs_top_builddir/src/tail < /dev/null > gdb.out 2>&1 + +if test -s gdb.out; then + cat <<EOF 1>&2 +$0: can't set breakpoints in tail. Skipping this test. +EOF + exit 77 +fi + +gdb -nx --batch-silent \ + --eval-command='break tail_forever_inotify' \ + --eval-command='run -f file' \ + --eval-command="shell echo never-seen-with-tail-7.5 >> file" \ + --eval-command='continue' \ + --eval-command='quit' \ + $abs_top_builddir/src/tail < /dev/null > gdb.out & + +pid=$! + +sleep 1.5s + +kill $pid + +test -s gdb.out || fail=1 + +Exit $fail -- 1.6.5
