From 9f19d71a766af5881cf763e6ce8d6c1bafe8ada5 Mon Sep 17 00:00:00 2001 From: Nikolaus Rath Date: Sat, 8 Oct 2016 21:24:13 -0700 Subject: Added timefs3 to test notify_inval_entry. Fixes #32. --- test/test_examples.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/test_examples.py b/test/test_examples.py index a3c234f..ef4932c 100755 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -172,7 +172,7 @@ def test_fsel(tmpdir): @pytest.mark.parametrize("name", ('timefs1', 'timefs2')) @pytest.mark.parametrize("options", LL_OPTIONS) @pytest.mark.parametrize("notify", (True, False)) -def test_timefs(tmpdir, name, options, notify): +def test_timefs12(tmpdir, name, options, notify): mnt_dir = str(tmpdir) cmdline = base_cmdline + \ [ pjoin(basename, 'example', name), @@ -198,6 +198,38 @@ def test_timefs(tmpdir, name, options, notify): else: umount(mount_process, mnt_dir) +@pytest.mark.parametrize("notify", (True, False)) +def test_timefs3(tmpdir, notify): + mnt_dir = str(tmpdir) + cmdline = base_cmdline + \ + [ pjoin(basename, 'example', 'timefs3'), + '-f', '--update-interval=2', + '--timeout=4', mnt_dir ] + if not notify: + cmdline.append('--no-notify') + mount_process = subprocess.Popen(cmdline) + try: + wait_for_mount(mount_process, mnt_dir) + fname = pjoin(mnt_dir, os.listdir(mnt_dir)[0]) + try: + os.stat(fname) + except FileNotFoundError: + # We may have hit a race condition + fname = pjoin(mnt_dir, os.listdir(mnt_dir)[0]) + os.stat(fname) + + safe_sleep(2) + if not notify: + os.stat(fname) + safe_sleep(4) + with pytest.raises(FileNotFoundError): + os.stat(fname) + except: + cleanup(mnt_dir) + raise + else: + umount(mount_process, mnt_dir) + def checked_unlink(filename, path, isdir=False): fullname = pjoin(path, filename) if isdir: -- cgit v1.2.3