[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [coreutils] Re: Bug#609049: du: process_file: Assertion `level == pr
From: |
Jim Meyering |
Subject: |
Re: [coreutils] Re: Bug#609049: du: process_file: Assertion `level == prev_level - 1' failed |
Date: |
Mon, 10 Jan 2011 08:01:24 +0100 |
Pádraig Brady wrote:
> On 09/01/11 22:05, Jim Meyering wrote:
>> diff --git a/tests/du/move-dir-while-traversing
>> b/tests/du/move-dir-while-traversing
>
>> +# We use a python-inotify script, so...
>> +python -m pyinotify -h > /dev/null \
>> + || skip_ 'python-inotify package not installed'
>
> A small point is that error is a bit fedora specific.
> The package is python-pyinotify on debian/ubuntu for example.
Good point. I've dropped the "-":
|| skip_ 'python inotify package not installed'
>> +from pyinotify import *
>
> I generally don't include everything from a module,
> to keep the namespace clean.
> I'd do instead:
>
> import pyinotify as pn
> import os,sys
> ...
I prefer that, too.
>> +dir = sys.argv[1]
...
>> +print 'started'
>
> The above print is buffered by default.
> As we're using it for synchronization I'd
>
> sys.stdout.write('started\n')
> sys.stdout.flush()
Good catch!
...
>> +nonempty() { test -s start-msg && return 0; sleep $1; }
>> +retry_delay_ nonempty .1 5
>
> I think the above may iterate only once?
> How about:
>
> nonempty() {
> test -s start-msg || { sleep $1; return 1; }
> }
> retry_delay_ nonempty .1 5 || framework_failure
Yes, that fixes another bug.
>> +# The above delay is insufficient in ~50% of my trials.
>> +# Sometimes, when under heavy load, a parallel "make check" would
>> +# fail this test when sleeping just 0.1 seconds here.
>> +sleep 1
>
> Hopefully this extra sleep is not required now
Bingo. It does, so far.
Thanks for the advice and fixes.
Here's the incremental I'm testing with:
diff --git a/tests/du/move-dir-while-traversing
b/tests/du/move-dir-while-traversing
index e42bc93..fe1615c 100755
--- a/tests/du/move-dir-while-traversing
+++ b/tests/du/move-dir-while-traversing
@@ -21,7 +21,7 @@ print_ver_ du
# We use a python-inotify script, so...
python -m pyinotify -h > /dev/null \
- || skip_ 'python-inotify package not installed'
+ || skip_ 'python inotify package not installed'
# Move a directory "up" while du is processing its sub-directories.
# While du is processing a hierarchy .../B/C/D/... this script
@@ -33,12 +33,14 @@ python -m pyinotify -h > /dev/null \
cat <<'EOF' > inotify-watch-for-dir-access.py
#!/usr/bin/env python
-from pyinotify import *
+import pyinotify as pn
+import os,sys
+
dir = sys.argv[1]
dest_parent = os.path.dirname(os.path.dirname(dir))
dest = os.path.join(dest_parent, os.path.basename(dir))
-class ProcessDir(ProcessEvent):
+class ProcessDir(pn.ProcessEvent):
def process_IN_OPEN(self, event):
os.rename(dir, dest)
@@ -47,10 +49,11 @@ class ProcessDir(ProcessEvent):
def process_default(self, event):
pass
-wm = WatchManager()
-notifier = Notifier(wm)
-wm.watch_transient_file(dir, IN_OPEN, ProcessDir)
-print 'started'
+wm = pn.WatchManager()
+notifier = pn.Notifier(wm)
+wm.watch_transient_file(dir, pn.IN_OPEN, ProcessDir)
+sys.stdout.write('started\n')
+sys.stdout.flush()
notifier.loop()
EOF
chmod a+x inotify-watch-for-dir-access.py
@@ -61,14 +64,9 @@ mkdir -p $t/3/a/b/c/$long d2 || framework_failure
timeout 6 ./inotify-watch-for-dir-access.py $t/3/a/b > start-msg &
# Wait for the watcher to start...
-nonempty() { test -s start-msg && return 0; sleep $1; }
+nonempty() { test -s start-msg || { sleep $1; return 1; }; }
retry_delay_ nonempty .1 5
-# The above delay is insufficient in ~50% of my trials.
-# Sometimes, when under heavy load, a parallel "make check" would
-# fail this test when sleeping just 0.1 seconds here.
-sleep 1
-
# The above watches for an IN_OPEN event on $t/3/a/b,
# and when it triggers, moves the parent, $t/3/a, up one level
# so it's directly under $t.