summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/backupdiff/testbackupdiff.cpp23
-rwxr-xr-xtest/crypto/testcrypto.cpp6
2 files changed, 23 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");
diff --git a/test/crypto/testcrypto.cpp b/test/crypto/testcrypto.cpp
index 2b055f91..983ae57e 100755
--- a/test/crypto/testcrypto.cpp
+++ b/test/crypto/testcrypto.cpp
@@ -270,6 +270,12 @@ int test(int argc, const char *argv[])
RAND_pseudo_bytes(checkdata, CHECKSUM_DATA_SIZE);
for(int size = CHECKSUM_BLOCK_SIZE_BASE; size <= CHECKSUM_BLOCK_SIZE_LAST; ++size)
{
+ // Test skip-roll code
+ RollingChecksum rollFast(checkdata, size);
+ rollFast.RollForwardSeveral(checkdata, checkdata+size, size, CHECKSUM_ROLLS/2);
+ RollingChecksum calc(checkdata + (CHECKSUM_ROLLS/2), size);
+ TEST_THAT(calc.GetChecksum() == rollFast.GetChecksum());
+
//printf("size = %d\n", size);
// Checksum to roll
RollingChecksum roll(checkdata, size);