Changeset 1923
- Timestamp:
- 05/11/2007 23:41:41 (5 years ago)
- Location:
- box/trunk
- Files:
-
- 2 edited
-
lib/common/Utils.cpp (modified) (1 diff)
-
test/bbackupd/testbbackupd.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/lib/common/Utils.cpp
r1920 r1923 99 99 { 100 100 struct stat st; 101 if(:: stat(Filename, &st) != 0)101 if(::lstat(Filename, &st) != 0) 102 102 { 103 103 if(errno == ENOENT) -
box/trunk/test/bbackupd/testbbackupd.cpp
r1913 r1923 1059 1059 #endif // PLATFORM_CLIB_FNS_INTERCEPTION_IMPOSSIBLE 1060 1060 1061 printf("\n==== Testing that redundant locations are deleted on time\n");1062 1063 1061 std::string cmd = BBACKUPD + bbackupd_args + 1064 1062 " testfiles/bbackupd-temploc.conf"; 1063 1065 1064 bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid"); 1066 1067 1065 TEST_THAT(bbackupd_pid != -1 && bbackupd_pid != 0); 1068 1069 1066 ::safe_sleep(1); 1070 1067 … … 1073 1070 if (!ServerIsAlive(bbackupd_pid)) return 1; 1074 1071 if (!ServerIsAlive(bbstored_pid)) return 1; 1072 1073 printf("\n==== Testing that absolute symlinks are not followed " 1074 "during restore\n"); 1075 1076 { 1077 #define SYM_DIR "testfiles" DIRECTORY_SEPARATOR "TestDir1" \ 1078 DIRECTORY_SEPARATOR "symlink_test" 1079 1080 TEST_THAT(::mkdir(SYM_DIR, 0777) == 0); 1081 TEST_THAT(::mkdir(SYM_DIR DIRECTORY_SEPARATOR "a", 0777) == 0); 1082 TEST_THAT(::mkdir(SYM_DIR DIRECTORY_SEPARATOR "a" 1083 DIRECTORY_SEPARATOR "subdir", 0777) == 0); 1084 TEST_THAT(::mkdir(SYM_DIR DIRECTORY_SEPARATOR "b", 0777) == 0); 1085 1086 FILE* fp = fopen(SYM_DIR DIRECTORY_SEPARATOR "a" 1087 DIRECTORY_SEPARATOR "subdir" 1088 DIRECTORY_SEPARATOR "content", "w"); 1089 TEST_THAT(fp != NULL); 1090 fputs("before\n", fp); 1091 fclose(fp); 1092 1093 char buf[PATH_MAX]; 1094 TEST_THAT(getcwd(buf, sizeof(buf)) != NULL); 1095 std::string path = buf; 1096 path += DIRECTORY_SEPARATOR SYM_DIR 1097 DIRECTORY_SEPARATOR "a" 1098 DIRECTORY_SEPARATOR "subdir"; 1099 TEST_THAT(symlink(path.c_str(), SYM_DIR 1100 DIRECTORY_SEPARATOR "b" 1101 DIRECTORY_SEPARATOR "link") == 0); 1102 1103 ::wait_for_operation(4); 1104 ::sync_and_wait(); 1105 1106 // Check that the backup was successful, i.e. no differences 1107 int compareReturnValue = ::system(BBACKUPQUERY " -q " 1108 "-c testfiles/bbackupd.conf " 1109 "-l testfiles/query1.log " 1110 "\"compare -acQ\" quit"); 1111 TEST_RETURN(compareReturnValue, 1); 1112 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1113 1114 // now stop bbackupd and update the test file, 1115 // make the original directory unreadable 1116 terminate_bbackupd(bbackupd_pid); 1117 1118 fp = fopen(SYM_DIR DIRECTORY_SEPARATOR "a" 1119 DIRECTORY_SEPARATOR "subdir" 1120 DIRECTORY_SEPARATOR "content", "w"); 1121 TEST_THAT(fp != NULL); 1122 fputs("after\n", fp); 1123 fclose(fp); 1124 1125 TEST_THAT(chmod(SYM_DIR, 0) == 0); 1126 1127 // check that we can restore it 1128 compareReturnValue = ::system(BBACKUPQUERY " " 1129 "-c testfiles/bbackupd.conf " 1130 "-q \"restore Test1 testfiles/restore-symlink\" " 1131 "quit"); 1132 TEST_RETURN(compareReturnValue, 0); 1133 1134 // make it accessible again 1135 TEST_THAT(chmod(SYM_DIR, 0755) == 0); 1136 1137 // check that the original file was not overwritten 1138 FileStream fs(SYM_DIR "/a/subdir/content"); 1139 IOStreamGetLine gl(fs); 1140 std::string line; 1141 TEST_THAT(gl.GetLine(line)); 1142 TEST_THAT(line != "before"); 1143 TEST_THAT(line == "after"); 1144 1145 #undef SYM_DIR 1146 1147 bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid"); 1148 TEST_THAT(bbackupd_pid != -1 && bbackupd_pid != 0); 1149 ::safe_sleep(1); 1150 1151 TEST_THAT(ServerIsAlive(bbackupd_pid)); 1152 TEST_THAT(ServerIsAlive(bbstored_pid)); 1153 if (!ServerIsAlive(bbackupd_pid)) return 1; 1154 if (!ServerIsAlive(bbstored_pid)) return 1; 1155 } 1156 1157 printf("\n==== Testing that redundant locations are deleted on time\n"); 1075 1158 1076 1159 {
Note: See TracChangeset
for help on using the changeset viewer.
