From 8e69b19cdc7ca7218f468e7ebd10ac7a4b46c56a Mon Sep 17 00:00:00 2001 From: Nikolaus Rath Date: Fri, 23 Dec 2016 18:31:45 -0800 Subject: Added documentation and test case for null example --- ChangeLog.rst | 6 ++++++ example/null.c | 13 ++++++++----- test/test_examples.py | 22 ++++++++++++++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/ChangeLog.rst b/ChangeLog.rst index 56847cc..b8ad5e1 100644 --- a/ChangeLog.rst +++ b/ChangeLog.rst @@ -1,3 +1,9 @@ +libfuse 3.1.0 (UNRELEASED) +========================== + +* Re-introduced examples/null.c. + + libfuse 3.0.0 (2016-12-08) ========================== diff --git a/example/null.c b/example/null.c index 5e8ebda..bc99a84 100644 --- a/example/null.c +++ b/example/null.c @@ -8,14 +8,17 @@ /** @file * - * null.c - FUSE: Filesystem in Userspace + * This "filesystem" provides only a single file. The mountpoint + * needs to be a file rather than a directory. All writes to the + * file will be discarded, and reading the file always returns + * \0. * - * \section section_compile compiling this example + * Compile with: * - * gcc -Wall null.c `pkg-config fuse3 --cflags --libs` -o null + * gcc -Wall null.c `pkg-config fuse3 --cflags --libs` -o null * - * \section section_source the complete source - * \include null.c + * ## Source code ## + * \include passthrough_fh.c */ diff --git a/test/test_examples.py b/test/test_examples.py index 457c2a0..95eeb9a 100755 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -140,6 +140,28 @@ def test_poll(tmpdir): else: umount(mount_process, mnt_dir) +def test_null(tmpdir): + mnt_file = str(tmpdir) + '/file' + with open(mnt_file, 'w') as fh: + fh.write('dummy') + cmdline = base_cmdline + [pjoin(basename, 'example', 'null'), + '-f', mnt_file ] + mount_process = subprocess.Popen(cmdline) + def test_fn(name): + return os.stat(name).st_size > 4000 + try: + wait_for_mount(mount_process, mnt_file, test_fn) + with open(mnt_file, 'rb') as fh: + assert fh.read(382) == b'\0' * 382 + with open(mnt_file, 'wb') as fh: + fh.write(b'whatever') + except: + cleanup(mnt_file) + raise + else: + umount(mount_process, mnt_file) + + @pytest.mark.parametrize("name", ('notify_inval_inode', 'notify_store_retrieve')) -- cgit v1.2.3