[Box Backup-commit] COMMIT r3438 - in box/trunk: infrastructure/m4 test/bbackupd

subversion at boxbackup.org subversion at boxbackup.org
Sat Dec 6 15:11:46 GMT 2014


Author: chris
Date: 2014-12-06 15:11:46 +0000 (Sat, 06 Dec 2014)
New Revision: 3438

Modified:
   box/trunk/infrastructure/m4/boxbackup_tests.m4
   box/trunk/test/bbackupd/testbbackupd.cpp
Log:
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


Modified: box/trunk/infrastructure/m4/boxbackup_tests.m4
===================================================================
--- box/trunk/infrastructure/m4/boxbackup_tests.m4	2014-12-06 15:03:40 UTC (rev 3437)
+++ box/trunk/infrastructure/m4/boxbackup_tests.m4	2014-12-06 15:11:46 UTC (rev 3438)
@@ -274,7 +274,8 @@
 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

Modified: box/trunk/test/bbackupd/testbbackupd.cpp
===================================================================
--- box/trunk/test/bbackupd/testbbackupd.cpp	2014-12-06 15:03:40 UTC (rev 3437)
+++ box/trunk/test/bbackupd/testbbackupd.cpp	2014-12-06 15:11:46 UTC (rev 3438)
@@ -416,6 +416,32 @@
 	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"),




More information about the Boxbackup-commit mailing list