Changeset 694
- Timestamp:
- 27/07/2006 00:13:14 (6 years ago)
- File:
-
- 1 edited
-
box/chris/general/test/bbackupd/testbbackupd.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/chris/general/test/bbackupd/testbbackupd.cpp
r671 r694 561 561 } 562 562 563 bool set_file_time(const char* filename, FILETIME creationTime, 564 FILETIME lastModTime, FILETIME lastAccessTime) 565 { 566 HANDLE handle = openfile(filename, O_RDWR, 0); 567 TEST_THAT(handle != INVALID_HANDLE_VALUE); 568 if (handle == INVALID_HANDLE_VALUE) return false; 569 570 BOOL success = SetFileTime(handle, &creationTime, &lastAccessTime, 571 &lastModTime); 572 TEST_THAT(success); 573 574 TEST_THAT(CloseHandle(handle)); 575 return success; 576 } 577 563 578 int test_bbackupd() 564 579 { … … 986 1001 compareReturnValue = ::system(BBACKUPQUERY " -q " 987 1002 "-c testfiles/bbackupd.conf -l testfiles/query10.log " 1003 "\"compare -cE Test1 testfiles/restore-Test1\" " 1004 "quit"); 1005 TEST_RETURN(compareReturnValue, 1); 1006 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1007 988 1008 #ifdef WIN32 989 "\"compare -cAE Test1 testfiles/restore-Test1\" " 990 #else 1009 // make one of the files read-only, expect a compare failure 1010 compareReturnValue = ::system("attrib +r " 1011 "testfiles\\restore-Test1\\f1.dat"); 1012 TEST_RETURN(compareReturnValue, 0); 1013 1014 compareReturnValue = ::system(BBACKUPQUERY " -q " 1015 "-c testfiles/bbackupd.conf -l testfiles/query10a.log " 991 1016 "\"compare -cE Test1 testfiles/restore-Test1\" " 1017 "quit"); 1018 TEST_RETURN(compareReturnValue, 2); 1019 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1020 1021 // set it back, expect no failures 1022 compareReturnValue = ::system("attrib -r " 1023 "testfiles\\restore-Test1\\f1.dat"); 1024 TEST_RETURN(compareReturnValue, 0); 1025 1026 compareReturnValue = ::system(BBACKUPQUERY " -q " 1027 "-c testfiles/bbackupd.conf -l testfiles/query10a.log " 1028 "\"compare -cE Test1 testfiles/restore-Test1\" " 1029 "quit"); 1030 TEST_RETURN(compareReturnValue, 1); 1031 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1032 1033 // change the timestamp on a file, expect a compare failure 1034 char* testfile = "testfiles\\restore-Test1\\f1.dat"; 1035 HANDLE handle = openfile(testfile, O_RDWR, 0); 1036 TEST_THAT(handle != INVALID_HANDLE_VALUE); 1037 1038 FILETIME creationTime, lastModTime, lastAccessTime; 1039 TEST_THAT(GetFileTime(handle, &creationTime, &lastAccessTime, 1040 &lastModTime) != 0); 1041 TEST_THAT(CloseHandle(handle)); 1042 1043 FILETIME dummyTime = lastModTime; 1044 dummyTime.dwHighDateTime -= 100; 1045 1046 // creation time is backed up, so changing it should cause 1047 // a compare failure 1048 TEST_THAT(set_file_time(testfile, dummyTime, lastModTime, 1049 lastAccessTime)); 1050 compareReturnValue = ::system(BBACKUPQUERY " -q " 1051 "-c testfiles/bbackupd.conf -l testfiles/query10a.log " 1052 "\"compare -cE Test1 testfiles/restore-Test1\" " 1053 "quit"); 1054 TEST_RETURN(compareReturnValue, 2); 1055 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1056 1057 // last access time is not backed up, so it cannot be compared 1058 TEST_THAT(set_file_time(testfile, creationTime, lastModTime, 1059 dummyTime)); 1060 compareReturnValue = ::system(BBACKUPQUERY " -q " 1061 "-c testfiles/bbackupd.conf -l testfiles/query10a.log " 1062 "\"compare -cE Test1 testfiles/restore-Test1\" " 1063 "quit"); 1064 TEST_RETURN(compareReturnValue, 1); 1065 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1066 1067 // last write time is backed up, so changing it should cause 1068 // a compare failure 1069 TEST_THAT(set_file_time(testfile, creationTime, dummyTime, 1070 lastAccessTime)); 1071 compareReturnValue = ::system(BBACKUPQUERY " -q " 1072 "-c testfiles/bbackupd.conf -l testfiles/query10a.log " 1073 "\"compare -cE Test1 testfiles/restore-Test1\" " 1074 "quit"); 1075 TEST_RETURN(compareReturnValue, 2); 1076 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1077 1078 // set back to original values, check that compare succeeds 1079 TEST_THAT(set_file_time(testfile, creationTime, lastModTime, 1080 lastAccessTime)); 1081 compareReturnValue = ::system(BBACKUPQUERY " -q " 1082 "-c testfiles/bbackupd.conf -l testfiles/query10a.log " 1083 "\"compare -cE Test1 testfiles/restore-Test1\" " 1084 "quit"); 1085 TEST_RETURN(compareReturnValue, 1); 1086 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 992 1087 #endif 993 "quit");994 995 TEST_RETURN(compareReturnValue, 1);996 TestRemoteProcessMemLeaks("bbackupquery.memleaks");997 1088 998 1089 printf("Add files with current time\n"); … … 1165 1256 " -q -c testfiles/bbackupd.conf " 1166 1257 "-l testfiles/query11.log " 1167 "\"compare " 1168 #ifdef WIN32 1169 // cannot restore attributes, so don't compare 1170 "-cAE " 1171 #else 1172 "-cE " 1173 #endif 1258 "\"compare -cE " 1174 1259 "Test1/x1 testfiles/restore-Test1-x1-2\" quit"); 1175 1260 TEST_RETURN(compareReturnValue, 1); … … 1190 1275 // Now we have about three seconds to work 1191 1276 1192 HANDLEhandle = openfile("testfiles/TestDir1/lockedfile",1277 handle = openfile("testfiles/TestDir1/lockedfile", 1193 1278 O_CREAT | O_EXCL, 0); 1194 TEST_THAT(handle != 0);1279 TEST_THAT(handle != INVALID_HANDLE_VALUE); 1195 1280 1196 1281 if (handle != 0) … … 1225 1310 handle = openfile("testfiles/TestDir1/lockedfile", 1226 1311 O_CREAT | O_EXCL, 0); 1227 TEST_THAT(handle != 0);1312 TEST_THAT(handle != INVALID_HANDLE_VALUE); 1228 1313 1229 1314 compareReturnValue = ::system(BBACKUPQUERY
Note: See TracChangeset
for help on using the changeset viewer.
