summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/pre-epoch-mtime.script39
-rw-r--r--yarns/0030-basics.yarn14
-rw-r--r--yarns/9000-implements.yarn22
3 files changed, 36 insertions, 39 deletions
diff --git a/tests/pre-epoch-mtime.script b/tests/pre-epoch-mtime.script
deleted file mode 100755
index 92d85bed..00000000
--- a/tests/pre-epoch-mtime.script
+++ /dev/null
@@ -1,39 +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
-
-# This doesn't work for sftp restores. paramiko or sftp can't handle
-# negative timestamps. Meh.
-if [ "$OBNAM_TEST_SFTP_ROOT" = yes ]
-then
- exit 0
-fi
-
-# It's possible to have timestamps before the epoch, i.e., negative
-# ones. For example, in the UK during DST, "touch -t 197001010000"
-# will create one.
-
-echo foo > "$DATADIR/data/foo"
-python -c '
-import os
-os.utime(os.path.join(os.environ["DATADIR"], "data", "foo"), (-3600, -3600))
-'
-
-$SRCDIR/tests/backup
-$SRCDIR/tests/restore
-$SRCDIR/tests/verify
-
diff --git a/yarns/0030-basics.yarn b/yarns/0030-basics.yarn
index 92304a50..4a89d64e 100644
--- a/yarns/0030-basics.yarn
+++ b/yarns/0030-basics.yarn
@@ -151,3 +151,17 @@ new backup.
AND user U backs up directory L2 to repository R
AND user U lists latest generation in repository R into F
THEN nothing in F matches L1
+
+Pre-epoch timestamps
+--------------------
+
+It's possible to have timestamps before the epoch, i.e., negative
+ones. For example, in the UK during DST, `touch -t 197001010000` will
+create one. Test that such timestamps work.
+
+ SCENARIO pre-epoch timestamps
+ GIVEN file L/file has Unix timestamp -3600
+ AND a manifest of directory L in M
+ WHEN user U backs up directory L to repository R
+ AND user U restores their latest generation in repository R into X
+ THEN L, restored to X, matches manifest M
diff --git a/yarns/9000-implements.yarn b/yarns/9000-implements.yarn
index aeb253d1..5ac48997 100644
--- a/yarns/9000-implements.yarn
+++ b/yarns/9000-implements.yarn
@@ -61,6 +61,28 @@ Some directories will be tagged as cache directories
printf 'Signature: 8a477f597d28d172789f06886806bc55' \
> "$DATADIR/$MATCH_1/CACHEDIR.TAG"
+Sometimes it is necessary to set the modification filestamp of a file.
+Actually, it's usually useful to set both `st_mtime` and `st_atime` to
+the same value. The timestamp is given in the "seconds after epoch" in
+UTC format, as is common in Unix.
+
+ IMPLEMENTS GIVEN file (\S+) has Unix timestamp (-?\d+)
+ parent=$(dirname "$MATCH_1")
+ if [ ! -e "$DATADIR/$parent" ]
+ then
+ mkdir "$DATADIR/$parent"
+ fi
+ touch "$DATADIR/$MATCH_1"
+ python -c '
+ import os
+ filename = os.path.join(
+ os.environ["DATADIR"],
+ os.environ["MATCH_1"])
+ timestamp = int(os.environ["MATCH_2"])
+ os.utime(filename, (timestamp, timestamp))
+ '
+
+
Manifest creation and checking
------------------------------