diff options
author | Reinhard Tartler <siretart@tauware.de> | 2008-01-19 15:08:54 +0100 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2008-01-19 15:08:54 +0100 |
commit | 2733267954e91e394fbb512ea3abb4c497c0752f (patch) | |
tree | d6cdebd8776bceba06a2fb5e4ed06a4744bc1b57 /test/backupdiff | |
parent | 1d56581c644c53f1b9a182c6574bc2fc5243d4d1 (diff) |
import version 0.11rc1
This commit has been made by 'bzr import'. I used the upstream tarball
of Version 0.11rc1 for creating it. It has the md5sum:
75608d8bb72dff9a556850ccd0ae8cb9
Diffstat (limited to 'test/backupdiff')
-rw-r--r-- | test/backupdiff/difftestfiles.cpp | 2 | ||||
-rw-r--r-- | test/backupdiff/testbackupdiff.cpp | 79 | ||||
-rw-r--r-- | test/backupdiff/testextra | 2 |
3 files changed, 63 insertions, 20 deletions
diff --git a/test/backupdiff/difftestfiles.cpp b/test/backupdiff/difftestfiles.cpp index cf28fab1..40e5da52 100644 --- a/test/backupdiff/difftestfiles.cpp +++ b/test/backupdiff/difftestfiles.cpp @@ -1,4 +1,4 @@ -// distribution boxbackup-0.10 (svn version: 494) +// distribution boxbackup-0.11rc1 (svn version: 2023_2024) // // Copyright (c) 2003 - 2006 // Ben Summers and contributors. All rights reserved. diff --git a/test/backupdiff/testbackupdiff.cpp b/test/backupdiff/testbackupdiff.cpp index bab6c941..09b4875e 100644 --- a/test/backupdiff/testbackupdiff.cpp +++ b/test/backupdiff/testbackupdiff.cpp @@ -1,4 +1,4 @@ -// distribution boxbackup-0.10 (svn version: 494) +// distribution boxbackup-0.11rc1 (svn version: 2023_2024) // // Copyright (c) 2003 - 2006 // Ben Summers and contributors. All rights reserved. @@ -104,22 +104,26 @@ bool files_identical(const char *file1, const char *file2) void make_file_of_zeros(const char *filename, size_t size) { - static const size_t bs = 0x10000; - size_t remSize = size; - void *b = malloc(bs); - memset(b, 0, bs); - FILE *f = fopen(filename, "wb"); - - // Using largish blocks like this is much faster, while not consuming too much RAM - while(remSize > bs) + #ifdef WIN32 + HANDLE handle = openfile(filename, O_WRONLY | O_CREAT | O_EXCL, 0); + TEST_THAT(handle != INVALID_HANDLE_VALUE); + TEST_THAT(SetFilePointer(handle, size, NULL, FILE_BEGIN) + != INVALID_SET_FILE_POINTER); + TEST_THAT(GetLastError() == NO_ERROR); + BOOL result = SetEndOfFile(handle); + if (result != TRUE) { - fwrite(b, bs, 1, f); - remSize -= bs; + printf("Error %u\n", GetLastError()); } - fwrite(b, remSize, 1, f); - - fclose(f); - free(b); + TEST_THAT(result == TRUE); + TEST_THAT(CloseHandle(handle) == TRUE); + #else + int fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0600); + if (fd < 0) perror(filename); + TEST_THAT(fd >= 0); + TEST_THAT(ftruncate(fd, size) == 0); + TEST_THAT(close(fd) == 0); + #endif TEST_THAT((size_t)TestGetFileSize(filename) == size); } @@ -156,12 +160,20 @@ void check_encoded_file(const char *filename, int64_t OtherFileID, int new_block if(s > 0) { nnew++; + #ifdef WIN32 + TRACE2("%8I64d this s=%8I64d", b, s); + #else TRACE2("%8lld this s=%8lld", b, s); + #endif } else { nold++; + #ifdef WIN32 + TRACE2("%8I64d other i=%8I64d", b, 0 - s); + #else TRACE2("%8lld other i=%8lld", b, 0 - s); + #endif } // Decode the rest uint64_t iv = box_ntoh64(hdr.mEntryIVBase); @@ -245,10 +257,18 @@ void test_diff(int from, int to, int new_blocks_expected, int old_blocks_expecte } else { +#ifdef WIN32 + // Emulate the above stage! + char src[256], dst[256]; + sprintf(src, "testfiles\\f%d.diff", to); + sprintf(dst, "testfiles\\f%d.encoded", to); + TEST_THAT(CopyFile(src, dst, FALSE) != 0) +#else // Emulate the above stage! char cmd[256]; sprintf(cmd, "cp testfiles/f%d.diff testfiles/f%d.encoded", to, to); ::system(cmd); +#endif } // Decode it @@ -393,8 +413,10 @@ int test(int argc, const char *argv[]) { // Want to trace out all the details #ifndef NDEBUG + #ifndef WIN32 BackupStoreFile::TraceDetailsOfDiffProcess = true; #endif + #endif // Create all the test files create_test_files(); @@ -408,6 +430,7 @@ int test(int argc, const char *argv[]) FileStream out("testfiles/f0.encoded", O_WRONLY | O_CREAT | O_EXCL); std::auto_ptr<IOStream> encoded(BackupStoreFile::EncodeFile("testfiles/f0", 1 /* dir ID */, f0name)); encoded->CopyStreamTo(out); + out.Close(); check_encoded_file("testfiles/f0.encoded", 0, 33, 0); } @@ -468,6 +491,7 @@ int test(int argc, const char *argv[]) FileStream out("testfiles/f9.zerotest", O_WRONLY | O_CREAT | O_EXCL); std::auto_ptr<IOStream> encoded(BackupStoreFile::EncodeFile("testfiles/f9", 1 /* dir ID */, fn)); encoded->CopyStreamTo(out); + out.Close(); check_encoded_file("testfiles/f9.zerotest", 0, 0, 0); } { @@ -478,6 +502,7 @@ int test(int argc, const char *argv[]) } } +#ifndef WIN32 // Check that symlinks aren't diffed TEST_THAT(::symlink("f2", "testfiles/f2.symlink") == 0) // And go and diff it against the previous encoded file @@ -505,8 +530,10 @@ int test(int argc, const char *argv[]) TEST_THAT(completelyDifferent == true); check_encoded_file("testfiles/f2.symlink.diff", 0, 0, 0); } +#endif - // Check that diffing against a file which isn't "complete" and referes another isn't allowed + // Check that diffing against a file which isn't "complete" and + // references another isn't allowed { FileStream blockindex("testfiles/f1.diff"); BackupStoreFile::MoveStreamPositionToBlockIndex(blockindex); @@ -518,10 +545,19 @@ int test(int argc, const char *argv[]) 0, 0), BackupStoreException, CannotDiffAnIncompleteStoreFile); } - // Found a nasty case where files of lots of the same thing sock up lots of processor - // time -- because of lots of matches found. Check this out! + // Found a nasty case where files of lots of the same thing + // suck up lots of processor time -- because of lots of matches + // found. Check this out! + + #ifdef WIN32 + ::fprintf(stdout, "Testing diffing two large streams, " + "may take a while!\n"); + ::fflush(stdout); + #endif + make_file_of_zeros("testfiles/zero.0", 20*1024*1024); make_file_of_zeros("testfiles/zero.1", 200*1024*1024); + // Generate a first encoded file { BackupStoreFilenameClear f0name("zero.0"); @@ -541,7 +577,14 @@ int test(int argc, const char *argv[]) 2000 /* object ID of the file diffing from */, blockindex, IOStream::TimeOutInfinite, 0, 0)); encoded->CopyStreamTo(out); + + printf("Time taken: %d seconds\n", (int)(time(0) - beginTime)); + + #ifdef WIN32 + TEST_THAT(time(0) < (beginTime + 300)); + #else TEST_THAT(time(0) < (beginTime + 40)); + #endif } // Remove zero-files to save disk space remove("testfiles/zero.0"); diff --git a/test/backupdiff/testextra b/test/backupdiff/testextra index 6f5f4473..8a493f53 100644 --- a/test/backupdiff/testextra +++ b/test/backupdiff/testextra @@ -1,4 +1,4 @@ -# distribution boxbackup-0.10 (svn version: 494) +# distribution boxbackup-0.11rc1 (svn version: 2023_2024) # # Copyright (c) 2003 - 2006 # Ben Summers and contributors. All rights reserved. |