Added documentation and test case for null example
authorNikolaus Rath <Nikolaus@rath.org>
Sat, 24 Dec 2016 02:31:45 +0000 (18:31 -0800)
committerNikolaus Rath <Nikolaus@rath.org>
Sat, 24 Dec 2016 02:31:45 +0000 (18:31 -0800)
ChangeLog.rst
example/null.c
test/test_examples.py

index 56847cc67ba3eb43a8151c33547c553f3872cc03..b8ad5e19596e3c6c4707279db6e36a865142d1ec 100644 (file)
@@ -1,3 +1,9 @@
+libfuse 3.1.0 (UNRELEASED)
+==========================
+
+* Re-introduced examples/null.c.
+
+
 libfuse 3.0.0 (2016-12-08)
 ==========================
 
index 5e8ebdaed42f91f0c27158e980f24cfb8e1a8902..bc99a844c00d764249b74b72c5c127bcfb3e1f95 100644 (file)
@@ -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
  */
 
 
index 457c2a01bcc1d18429f5e362791ec7bf9dbbee93..95eeb9a5a5125890fbba893881d7586af42d8561 100755 (executable)
@@ -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'))