summaryrefslogtreecommitdiff
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
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
-rw-r--r--infrastructure/m4/boxbackup_tests.m43
-rw-r--r--test/bbackupd/testbbackupd.cpp26
2 files changed, 28 insertions, 1 deletions
diff --git a/infrastructure/m4/boxbackup_tests.m4 b/infrastructure/m4/boxbackup_tests.m4
index ccb46646..cd1b33f3 100644
--- a/infrastructure/m4/boxbackup_tests.m4
+++ b/infrastructure/m4/boxbackup_tests.m4
@@ -274,7 +274,8 @@ AC_FUNC_CLOSEDIR_VOID
AC_FUNC_ERROR_AT_LINE
AC_TYPE_SIGNAL
AC_FUNC_STAT
-AC_CHECK_FUNCS([getpeereid getpeername lchown setproctitle getpid gettimeofday waitpid ftruncate])
+AC_CHECK_FUNCS([getpeereid getpeername getpid gettimeofday lchown setproctitle])
+AC_CHECK_FUNCS([utimensat])
AC_SEARCH_LIBS([setproctitle], ["bsd"])
# NetBSD implements kqueue too differently for us to get it fixed by 0.10
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"),