summaryrefslogtreecommitdiff
path: root/test/backupdiff/testbackupdiff.cpp
diff options
context:
space:
mode:
authorMartin Ebourne <martin@ebourne.me.uk>2005-12-07 16:24:49 +0000
committerMartin Ebourne <martin@ebourne.me.uk>2005-12-07 16:24:49 +0000
commit065dc6f8cd168e3ee6e71ddfb06f42a92abfabbd (patch)
treeec09f9aff78d337b64ef4af7c7cba2d23a4ef0e9 /test/backupdiff/testbackupdiff.cpp
parent9950474440f85c5a35be8cfe7a85cee884209f20 (diff)
Merged chromi/diffopt at r116 to trunk
Diffstat (limited to 'test/backupdiff/testbackupdiff.cpp')
-rwxr-xr-xtest/backupdiff/testbackupdiff.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/test/backupdiff/testbackupdiff.cpp b/test/backupdiff/testbackupdiff.cpp
index d086253e..5fb10038 100755
--- a/test/backupdiff/testbackupdiff.cpp
+++ b/test/backupdiff/testbackupdiff.cpp
@@ -64,14 +64,25 @@ bool files_identical(const char *file1, const char *file2)
return true;
}
-void make_file_of_zeros(const char *filename, int size)
+void make_file_of_zeros(const char *filename, size_t size)
{
- void *b = malloc(size);
- memset(b, 0, size);
+ static const size_t bs = 0x10000;
+ size_t remSize = size;
+ void *b = malloc(bs);
+ memset(b, 0, bs);
FILE *f = fopen(filename, "wb");
- fwrite(b, size, 1, f);
+
+ // Using largish blocks like this is much faster, while not consuming too much RAM
+ while(remSize > bs)
+ {
+ fwrite(b, bs, 1, f);
+ remSize -= bs;
+ }
+ fwrite(b, remSize, 1, f);
+
fclose(f);
free(b);
+
TEST_THAT(TestGetFileSize(filename) == size);
}
@@ -455,8 +466,8 @@ int test(int argc, const char *argv[])
// 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!
- make_file_of_zeros("testfiles/zero.0", 20*1024);
- make_file_of_zeros("testfiles/zero.1", 200*1024);
+ 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");