Changeset 1583


Ignore:
Timestamp:
22/04/2007 23:15:44 (5 years ago)
Author:
chris
Message:

Test that file attributes are backed up and compared correctly on Win32
(refs #3, merges part of 694])

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/chris/merge/test/bbackupd/testbbackupd.cpp

    r1582 r1583  
    21252125                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
    21262126                 
     2127#ifdef WIN32 
     2128                // make one of the files read-only, expect a compare failure 
     2129                compareReturnValue = ::system("attrib +r " 
     2130                        "testfiles\\restore-Test1\\f1.dat"); 
     2131                TEST_RETURN(compareReturnValue, 0); 
     2132 
     2133                compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2134                        "-c testfiles/bbackupd.conf " 
     2135                        "-l testfiles/query10a.log " 
     2136                        "\"compare -cEQ Test1 testfiles/restore-Test1\" " 
     2137                        "quit"); 
     2138                TEST_RETURN(compareReturnValue, 2); 
     2139                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
     2140         
     2141                // set it back, expect no failures 
     2142                compareReturnValue = ::system("attrib -r " 
     2143                        "testfiles\\restore-Test1\\f1.dat"); 
     2144                TEST_RETURN(compareReturnValue, 0); 
     2145 
     2146                compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2147                        "-c testfiles/bbackupd.conf -l testfiles/query10a.log " 
     2148                        "\"compare -cEQ Test1 testfiles/restore-Test1\" " 
     2149                        "quit"); 
     2150                TEST_RETURN(compareReturnValue, 1); 
     2151                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
     2152 
     2153                // change the timestamp on a file, expect a compare failure 
     2154                char* testfile = "testfiles\\restore-Test1\\f1.dat"; 
     2155                HANDLE handle = openfile(testfile, O_RDWR, 0); 
     2156                TEST_THAT(handle != INVALID_HANDLE_VALUE); 
     2157                 
     2158                FILETIME creationTime, lastModTime, lastAccessTime; 
     2159                TEST_THAT(GetFileTime(handle, &creationTime, &lastAccessTime,  
     2160                        &lastModTime) != 0); 
     2161                TEST_THAT(CloseHandle(handle)); 
     2162 
     2163                FILETIME dummyTime = lastModTime; 
     2164                dummyTime.dwHighDateTime -= 100; 
     2165 
     2166                // creation time is backed up, so changing it should cause 
     2167                // a compare failure 
     2168                TEST_THAT(set_file_time(testfile, dummyTime, lastModTime, 
     2169                        lastAccessTime)); 
     2170                compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2171                        "-c testfiles/bbackupd.conf " 
     2172                        "-l testfiles/query10a.log " 
     2173                        "\"compare -cEQ Test1 testfiles/restore-Test1\" " 
     2174                        "quit"); 
     2175                TEST_RETURN(compareReturnValue, 2); 
     2176                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
     2177 
     2178                // last access time is not backed up, so it cannot be compared 
     2179                TEST_THAT(set_file_time(testfile, creationTime, lastModTime, 
     2180                        dummyTime)); 
     2181                compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2182                        "-c testfiles/bbackupd.conf " 
     2183                        "-l testfiles/query10a.log " 
     2184                        "\"compare -cEQ Test1 testfiles/restore-Test1\" " 
     2185                        "quit"); 
     2186                TEST_RETURN(compareReturnValue, 1); 
     2187                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
     2188 
     2189                // last write time is backed up, so changing it should cause 
     2190                // a compare failure 
     2191                TEST_THAT(set_file_time(testfile, creationTime, dummyTime, 
     2192                        lastAccessTime)); 
     2193                compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2194                        "-c testfiles/bbackupd.conf " 
     2195                        "-l testfiles/query10a.log " 
     2196                        "\"compare -cEQ Test1 testfiles/restore-Test1\" " 
     2197                        "quit"); 
     2198                TEST_RETURN(compareReturnValue, 2); 
     2199                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
     2200 
     2201                // set back to original values, check that compare succeeds 
     2202                TEST_THAT(set_file_time(testfile, creationTime, lastModTime, 
     2203                        lastAccessTime)); 
     2204                compareReturnValue = ::system(BBACKUPQUERY " -q " 
     2205                        "-c testfiles/bbackupd.conf " 
     2206                        "-l testfiles/query10a.log " 
     2207                        "\"compare -cEQ Test1 testfiles/restore-Test1\" " 
     2208                        "quit"); 
     2209                TEST_RETURN(compareReturnValue, 1); 
     2210                TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 
     2211#endif // WIN32 
     2212 
    21272213                printf("Add files with current time\n"); 
    21282214         
Note: See TracChangeset for help on using the changeset viewer.