summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-03-18 07:54:23 +0000
committerLars Wirzenius <liw@liw.fi>2014-03-18 08:27:24 +0000
commite1556613f870e5ad173b6a2348671ae8fafa1561 (patch)
tree268964eb9d93ac129ecc8ca7d02fda4f1066f63b
parent7488d466afbfdc2d90cc976fe448d50e3ec0c7c7 (diff)
downloadobnam-e1556613f870e5ad173b6a2348671ae8fafa1561.tar.gz
Add test case for FUSE bug
-rwxr-xr-xmkdata59
-rw-r--r--yarns/0100-fuse.yarn23
-rw-r--r--yarns/9000-implements.yarn5
3 files changed, 87 insertions, 0 deletions
diff --git a/mkdata b/mkdata
new file mode 100755
index 00000000..0e115338
--- /dev/null
+++ b/mkdata
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+# Copyright 2014 Lars Wirzenius
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+# =*= License: GPL-3+ =*=
+
+
+'''Create files of specified size, filled with junk.'''
+
+
+import os
+
+import cliapp
+
+
+class MakeData(cliapp.Application):
+
+ def add_settings(self):
+ self.settings.bytesize(
+ ['size'],
+ 'how large a file to generate',
+ default=0)
+
+ def process_args(self, filenames):
+ for filename in filenames:
+ self.create_file(filename, self.settings['size'])
+
+ def create_file(self, filename, size):
+ self.create_parent_directory(filename)
+ with open(filename, 'w') as f:
+ self.write_data(f, size)
+
+ def create_parent_directory(self, filename):
+ dirname = os.path.dirname(filename)
+ if not os.path.exists(dirname):
+ os.makedirs(dirname)
+
+ def write_data(self, f, size):
+ chunk = 'x' * 2**20
+ written = 0
+ while written < size:
+ n = min(len(chunk), size - written)
+ f.write(chunk[:n])
+ written += n
+
+
+MakeData().run()
diff --git a/yarns/0100-fuse.yarn b/yarns/0100-fuse.yarn
index 0653d08e..d3433f0e 100644
--- a/yarns/0100-fuse.yarn
+++ b/yarns/0100-fuse.yarn
@@ -31,6 +31,20 @@ Clean up.
FINALLY unmount repository F
+In 2014, for Obnam 1.7, a bug was reported that the FUSE plugin would
+only read the first 64 kilobytes of a file. Verify that this is no
+longer a problem.
+
+ SCENARIO restoring a big file with FUSE
+ ASSUMING user is in group fuse
+ GIVEN 1M of data in file L/big.dat
+ AND a manifest of L in M
+ WHEN user U backs up directory L to repository R
+ AND user U FUSE mounts the repository R at F
+ THEN L, restored to F/latest, matches manifest M
+ AND big.dat in L and in mounted F compare equally
+ FINALLY unmount repository F
+
We can only run this test if the user is in the `fuse` group. This may
be a portability concern: this works in Debian GNU/Linux, but might be
different in other Linux distros, or on non-Linux systems. (If it
@@ -45,6 +59,15 @@ against the FUSE mount, and comparing the two manifests.
run_obnam "$MATCH_1" mount -r "$DATADIR/$MATCH_2" \
--to "$DATADIR/$MATCH_3"
+We also check a specific file by comparing it in the mount and in its
+original location. We do the comparison with cmp(1) instead of the
+usual way, because this triggered a bug.
+
+ IMPLEMENTS THEN (\S+) in (\S+) and in mounted (\S+) compare equally
+ cmp \
+ "$DATADIR/$MATCH_2/$MATCH_1" \
+ "$DATADIR/$MATCH_3/latest/$DATADIR/$MATCH_2/$MATCH_1"
+
If we did do the fuse mount, **always** unmount it, even when a step
failed. We do not want failed test runs to leavo mounts lying around.
diff --git a/yarns/9000-implements.yarn b/yarns/9000-implements.yarn
index 2117f927..f742bdf2 100644
--- a/yarns/9000-implements.yarn
+++ b/yarns/9000-implements.yarn
@@ -37,6 +37,11 @@ between steps.
IMPLEMENTS GIVEN (\S+) of new data in directory (\S+)
genbackupdata --quiet --create "$MATCH_1" "$DATADIR/$MATCH_2"
+Sometimes we need an amount of data in a specific file.
+
+ IMPLEMENTS GIVEN (\S+) of data in file (\S+)
+ "$SRCDIR/mkdata" --size "$MATCH_1" "$DATADIR/$MATCH_2"
+
We also need to generate a sparse file. A sparse file has at least one
hole in it, and it may matter where the hole is: at the beginning,
middle, or end of the file. Thus, we provide a way for scenarios to