summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-03-27 20:29:56 +0000
committerLars Wirzenius <liw@liw.fi>2014-03-27 20:29:56 +0000
commita17cdfe3eca1aa308809697ddc2c170a7cc6b501 (patch)
treed581e79813e7795af21e81858684722828d92340
parent29de9e039fe41ad6957b82cbb745e7d690598b7c (diff)
downloadobnam-a17cdfe3eca1aa308809697ddc2c170a7cc6b501.tar.gz
Convert unreadable-file cmdtest to yarn
Doing this exposed a bug in yarn, which meant that the test needs a newer yarn to run. (Not yet released.)
-rw-r--r--debian/changelog2
-rw-r--r--debian/control2
-rw-r--r--test-gpghome/random_seedbin600 -> 600 bytes
-rw-r--r--tests/unreadable-file.exit1
-rwxr-xr-xtests/unreadable-file.script46
-rw-r--r--tests/unreadable-file.stderr2
-rw-r--r--yarns/0030-basics.yarn19
-rw-r--r--yarns/9000-implements.yarn33
8 files changed, 43 insertions, 62 deletions
diff --git a/debian/changelog b/debian/changelog
index e3acdd19..91fccb83 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,8 @@ obnam (1.7.3-1) UNRELEASED; urgency=low
* New upstream release.
* Fix "several consecutive runs back up unmodified files"
(Closes: #742384)
+ * debian/control: Increase build-dependency on cmdtest to 0.12 so
+ that yarn will not fail when a test creates an unreadable file.
-- Lars Wirzenius <liw@liw.fi> Mon, 24 Mar 2014 21:19:14 +0000
diff --git a/debian/control b/debian/control
index 55fde933..f3eeb0be 100644
--- a/debian/control
+++ b/debian/control
@@ -14,7 +14,7 @@ Build-Depends: debhelper (>= 7.3.8),
python-cliapp (>= 1.20130808~),
genbackupdata (>= 1.7~),
summain (>= 0.18),
- cmdtest (>= 0.11~),
+ cmdtest (>= 0.12~),
attr,
python-fuse,
pandoc,
diff --git a/test-gpghome/random_seed b/test-gpghome/random_seed
index f350ffb8..6a8dce29 100644
--- a/test-gpghome/random_seed
+++ b/test-gpghome/random_seed
Binary files differ
diff --git a/tests/unreadable-file.exit b/tests/unreadable-file.exit
deleted file mode 100644
index d00491fd..00000000
--- a/tests/unreadable-file.exit
+++ /dev/null
@@ -1 +0,0 @@
-1
diff --git a/tests/unreadable-file.script b/tests/unreadable-file.script
deleted file mode 100755
index 1ad4f7f8..00000000
--- a/tests/unreadable-file.script
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/sh
-# Copyright 2011 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/>.
-
-set -e
-
-echo aaa > "$DATADIR/data/aaa"
-echo bbb > "$DATADIR/data/bbb"
-chmod 0 "$DATADIR/data/bbb"
-echo ccc > "$DATADIR/data/ccc"
-
-if $SRCDIR/tests/backup
-then
- exit=0
-else
- exit=1
-fi
-$SRCDIR/tests/restore
-
-# Remove the problematic directory so that verify works.
-# Don't do this if running as root, since in that case
-# obnam _can_ back it up. (Yes, this is convoluted.)
-# When removing the directory, make sure the mtime doesn't
-# change of the parent.
-if [ "$(whoami)" != root ]
-then
- touch -r "$DATADIR/data" "$DATADIR/timestamp"
- rm -f "$DATADIR/data/bbb"
- touch -r "$DATADIR/timestamp" "$DATADIR/data"
-fi
-
-$SRCDIR/tests/verify
-
-exit $exit
diff --git a/tests/unreadable-file.stderr b/tests/unreadable-file.stderr
deleted file mode 100644
index b6ac2bda..00000000
--- a/tests/unreadable-file.stderr
+++ /dev/null
@@ -1,2 +0,0 @@
-ERROR: Can't back up TMP/data/bbb: RCE08AX: I/O error: TMP/data/bbb: 13: Permission denied
-ERROR: R4C3BCX: There were errors during the backup
diff --git a/yarns/0030-basics.yarn b/yarns/0030-basics.yarn
index 936d3be8..0a04c98b 100644
--- a/yarns/0030-basics.yarn
+++ b/yarns/0030-basics.yarn
@@ -123,6 +123,25 @@ backup run.
AND L, restored to X, matches manifest M
+Backup when a file or directory is unreadable
+---------------------------------------------
+
+The backup shouldn't fail even if a file or directory is inaccessible.
+
+ SCENARIO unreadable live data file
+
+We can't run this test as the `root` user, since then everything is
+readable.
+
+ ASSUMING not running as root
+
+Create some live data, and a file that is unreadable.
+
+ GIVEN 1k of new data in directory L
+ AND file L/unreadable-file with permissions 000
+ WHEN user U attempts to back up directory L to repository R
+ THEN the error message matches "RCE08AX.*L/unreadable-file"
+
Backup to roots at once
-----------------------
diff --git a/yarns/9000-implements.yarn b/yarns/9000-implements.yarn
index 5591370f..26716143 100644
--- a/yarns/9000-implements.yarn
+++ b/yarns/9000-implements.yarn
@@ -1,4 +1,4 @@
-Test implementation
+ implementation
===================
This chapter documents the generic, shared IMPLEMENTS sections for
@@ -87,6 +87,12 @@ UTC format, as is common in Unix.
os.utime(filename, (timestamp, timestamp))
'
+Create a file with given permissions.
+
+ IMPLEMENTS GIVEN file (\S+) with permissions (\S+)
+ touch "$DATADIR/$MATCH_1"
+ chmod "$MATCH_2" "$DATADIR/$MATCH_1"
+
We need to manipulate extended attributes.
IMPLEMENTS GIVEN file (\S+) has extended attribute (\S+) set to (\S+)
@@ -213,6 +219,13 @@ addition to backing up, this makes a manifest of the data.
IMPLEMENTS WHEN user (\S+) backs up directory (\S+) to repository (\S+)
run_obnam "$MATCH_1" backup -r "$DATADIR/$MATCH_3" "$DATADIR/$MATCH_2"
+A test may make a backup fail. Run without failing the test so the
+failure may be inspected.
+
+ IMPLEMENTS WHEN user (\S+) attempts to back up directory (\S+) to repository (\S+)
+ attempt run_obnam "$MATCH_1" \
+ backup -r "$DATADIR/$MATCH_3" "$DATADIR/$MATCH_2"
+
We may also need to backup two directories at once.
IMPLEMENTS WHEN user (\S+) backs up directories (\S+) and (\S+) to repository (\S+)
@@ -256,15 +269,6 @@ that is unpredictable.
run_obnam "$client" restore -r "$repo" \
--to "$to" --generation "$id"
-We want to match the stdout against a regular expression.
-
- IMPLEMENTS THEN the output matches "(.+)"
- echo -----------------------
- echo stdout being matched:
- cat "$DATADIR/attempt.stdout"
- echo -----------------------
- attempt_matches stdout "$MATCH_1"
-
We may also need to attempt a restore in a situation when we expect it
to fail.
@@ -550,8 +554,13 @@ by the user.
IMPLEMENTS WHEN user (\S+) reads file (\S+)
cat "$DATADIR/$MATCH_2"
-Check on user group membership
-------------------------------
+Check on user running test suite
+--------------------------------
+
+Some tests won't work correctly when `root` is running them.
+
+ IMPLEMENTS ASSUMING not running as root
+ test "$(id -u)" != 0
Some tests, such as those for the FUSE plugin, require the user to be
in a specific group.