summaryrefslogtreecommitdiff
path: root/test/bbackupd/testbbackupd.cpp
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2014-12-06 15:11:46 +0000
committerChris Wilson <chris+github@qwirx.com>2014-12-06 15:11:46 +0000
commitd2afea0af9291bd0d6967c6b8b418541c3c28f64 (patch)
tree4bf1de833e2e9dd152bcb925aff7257d61fd6e88 /test/bbackupd/testbbackupd.cpp
parentf3a1ce8af043dbdc9240df76f69424c20446e2a5 (diff)
Workaround for old gnu tar, failing to restore timestamps on symlinks.
Older versions of GNU tar fail to set the timestamps on symlinks, which makes them appear too recent/new to be backed up immediately, causing test_bbackupd_uploads_files() for example to fail. Fixed by restoring the timestamps manually after extracting the fixture archive. For more details about the issue in tar, please see: http://lists.gnu.org/archive/html/bug-tar/2009-08/msg00007.html http://git.savannah.gnu.org/cgit/tar.git/plain/NEWS?id=release_1_24 This resulted in symlinks in fixture test files
Diffstat (limited to 'test/bbackupd/testbbackupd.cpp')
-rw-r--r--test/bbackupd/testbbackupd.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp
index bd4df2dc..416aa139 100644
--- a/test/bbackupd/testbbackupd.cpp
+++ b/test/bbackupd/testbbackupd.cpp
@@ -416,6 +416,32 @@ bool setup_test_bbackupd(BackupDaemon& bbackupd, bool do_unpack_files = true,
if (do_unpack_files)
{
TEST_THAT_OR(unpack_files("test_base"), FAIL);
+ // Older versions of GNU tar fail to set the timestamps on
+ // symlinks, which makes them appear too recent to be backed
+ // up immediately, causing test_bbackupd_uploads_files() for
+ // example to fail. So restore the timestamps manually.
+ // http://lists.gnu.org/archive/html/bug-tar/2009-08/msg00007.html
+ // http://git.savannah.gnu.org/cgit/tar.git/plain/NEWS?id=release_1_24
+ #ifdef HAVE_UTIMENSAT
+ const struct timespec times[2] = {
+ {1065707200, 0},
+ {1065707200, 0},
+ };
+ const char * filenames[] = {
+ "testfiles/TestDir1/symlink1",
+ "testfiles/TestDir1/symlink2",
+ "testfiles/TestDir1/symlink3",
+ NULL,
+ };
+ for (int i = 0; filenames[i] != NULL; i++)
+ {
+ TEST_THAT_OR(utimensat(AT_FDCWD, filenames[i],
+ times, AT_SYMLINK_NOFOLLOW) == 0,
+ BOX_LOG_SYS_ERROR("Failed to change "
+ "timestamp on symlink: " <<
+ filenames[i]));
+ }
+ #endif
}
TEST_THAT_OR(configure_bbackupd(bbackupd, "testfiles/bbackupd.conf"),