[Box Backup-commit] COMMIT r1423 - box/chris/merge/test/bbackupd

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Thu Mar 22 23:19:20 GMT 2007


Author: chris
Date: 2007-03-22 23:19:19 +0000 (Thu, 22 Mar 2007)
New Revision: 1423

Modified:
   box/chris/merge/test/bbackupd/testbbackupd.cpp
Log:
Test expected behaviour for modifying a file without changing its modtime,
both tracked and untracked (refs #3)


Modified: box/chris/merge/test/bbackupd/testbbackupd.cpp
===================================================================
--- box/chris/merge/test/bbackupd/testbbackupd.cpp	2007-03-22 23:15:22 UTC (rev 1422)
+++ box/chris/merge/test/bbackupd/testbbackupd.cpp	2007-03-22 23:19:19 UTC (rev 1423)
@@ -1050,6 +1050,79 @@
 		TEST_THAT(compareReturnValue == 1*256);
 		TestRemoteProcessMemLeaks("bbackupquery.memleaks");
 
+		// rename an untracked file over an 
+		// existing untracked file
+		printf("Rename over existing untracked file\n");
+		int fd1 = open("testfiles/TestDir1/untracked-1", 
+			O_CREAT | O_EXCL | O_WRONLY, 0700);
+		int fd2 = open("testfiles/TestDir1/untracked-2",
+			O_CREAT | O_EXCL | O_WRONLY, 0700);
+		TEST_THAT(fd1 > 0);
+		TEST_THAT(fd2 > 0);
+		TEST_THAT(write(fd1, "hello", 5) == 5);
+		TEST_THAT(close(fd1) == 0);
+		sleep(1);
+		TEST_THAT(write(fd2, "world", 5) == 5);
+		TEST_THAT(close(fd2) == 0);
+		TEST_THAT(TestFileExists("testfiles/TestDir1/untracked-1"));
+		TEST_THAT(TestFileExists("testfiles/TestDir1/untracked-2"));
+		wait_for_operation(5);
+		// back up both files
+		wait_for_backup_operation();
+		compareReturnValue = ::system(BBACKUPQUERY " -q "
+			"-c testfiles/bbackupd.conf -l testfiles/query3t.log "
+			"\"compare -ac\" quit");
+		TEST_THAT(compareReturnValue == 1*256);
+		TestRemoteProcessMemLeaks("bbackupquery.memleaks");
+		TEST_THAT(::rename("testfiles/TestDir1/untracked-1", 
+			"testfiles/TestDir1/untracked-2") == 0);
+		TEST_THAT(!TestFileExists("testfiles/TestDir1/untracked-1"));
+		TEST_THAT( TestFileExists("testfiles/TestDir1/untracked-2"));
+		wait_for_backup_operation();
+		compareReturnValue = ::system(BBACKUPQUERY " -q "
+			"-c testfiles/bbackupd.conf -l testfiles/query3t.log "
+			"\"compare -ac\" quit");
+		TEST_THAT(compareReturnValue == 1*256);
+		TestRemoteProcessMemLeaks("bbackupquery.memleaks");
+
+		// case which went wrong: rename a tracked file over an
+		// existing tracked file
+		printf("Rename over existing tracked file\n");
+		fd1 = open("testfiles/TestDir1/tracked-1", 
+			O_CREAT | O_EXCL | O_WRONLY, 0700);
+		fd2 = open("testfiles/TestDir1/tracked-2",
+			O_CREAT | O_EXCL | O_WRONLY, 0700);
+		TEST_THAT(fd1 > 0);
+		TEST_THAT(fd2 > 0);
+		char buffer[1024];
+		TEST_THAT(write(fd1, "hello", 5) == 5);
+		TEST_THAT(write(fd1, buffer, sizeof(buffer)) == sizeof(buffer));
+		TEST_THAT(close(fd1) == 0);
+		sleep(1);
+		TEST_THAT(write(fd2, "world", 5) == 5);
+		TEST_THAT(write(fd2, buffer, sizeof(buffer)) == sizeof(buffer));
+		TEST_THAT(close(fd2) == 0);
+		TEST_THAT(TestFileExists("testfiles/TestDir1/tracked-1"));
+		TEST_THAT(TestFileExists("testfiles/TestDir1/tracked-2"));
+		wait_for_operation(5);
+		// back up both files
+		wait_for_backup_operation();
+		compareReturnValue = ::system(BBACKUPQUERY " -q "
+			"-c testfiles/bbackupd.conf -l testfiles/query3u.log "
+			"\"compare -ac\" quit");
+		TEST_THAT(compareReturnValue == 1*256);
+		TestRemoteProcessMemLeaks("bbackupquery.memleaks");
+		TEST_THAT(::rename("testfiles/TestDir1/tracked-1", 
+			"testfiles/TestDir1/tracked-2") == 0);
+		TEST_THAT(!TestFileExists("testfiles/TestDir1/tracked-1"));
+		TEST_THAT( TestFileExists("testfiles/TestDir1/tracked-2"));
+		wait_for_backup_operation();
+		compareReturnValue = ::system(BBACKUPQUERY " -q "
+			"-c testfiles/bbackupd.conf -l testfiles/query3v.log "
+			"\"compare -ac\" quit");
+		TEST_THAT(compareReturnValue == 1*256);
+		TestRemoteProcessMemLeaks("bbackupquery.memleaks");
+	
 		// case which went wrong: rename a tracked file over a deleted file
 		printf("Rename an existing file over a deleted file\n");
 		TEST_THAT(::rename("testfiles/TestDir1/df9834.dsf", "testfiles/TestDir1/x1/dsfdsfs98.fd") == 0);




More information about the Boxbackup-commit mailing list