summaryrefslogtreecommitdiff
path: root/xdelta3/testing/regtest.cc
diff options
context:
space:
mode:
authorJosh MacDonald <josh.macdonald@gmail.com>2015-11-10 23:27:29 -0800
committerJosh MacDonald <josh.macdonald@gmail.com>2015-11-10 23:27:29 -0800
commit336f37f35beee264c22f7ce9baca1300bc292aa5 (patch)
treed15ec05f6e751f3500add4cc50c709310c104abd /xdelta3/testing/regtest.cc
parent248b9eb093d04d769eee4dff0ad7999c39f35556 (diff)
Merge command comments; VCD_TARGET cleanup
Diffstat (limited to 'xdelta3/testing/regtest.cc')
-rw-r--r--xdelta3/testing/regtest.cc36
1 files changed, 18 insertions, 18 deletions
diff --git a/xdelta3/testing/regtest.cc b/xdelta3/testing/regtest.cc
index 305dc43..eeb0e4b 100644
--- a/xdelta3/testing/regtest.cc
+++ b/xdelta3/testing/regtest.cc
@@ -92,7 +92,7 @@ public:
92 bool done = false; 92 bool done = false;
93 bool done_after_input = false; 93 bool done_after_input = false;
94 94
95 IF_DEBUG1 (XPR(NTR "source %"Q"u[%"Q"u] target %"Q"u winsize %lu\n", 95 IF_DEBUG1 (XPR(NTR "source %"Q"u[%"Q"u] target %"Q"u winsize %"Z"u\n",
96 source_file.Size(), options.block_size, 96 source_file.Size(), options.block_size,
97 target_file.Size(), 97 target_file.Size(),
98 Constants::WINDOW_SIZE)); 98 Constants::WINDOW_SIZE));
@@ -153,7 +153,7 @@ public:
153 xd3_source *src = (encoding ? &encode_source : &decode_source); 153 xd3_source *src = (encoding ? &encode_source : &decode_source);
154 Block *block = (encoding ? &encode_source_block : &decode_source_block); 154 Block *block = (encoding ? &encode_source_block : &decode_source_block);
155 if (encoding) { 155 if (encoding) {
156 IF_DEBUG1(XPR(NTR "[srcblock] %"Q"u last srcpos %"Q"u " 156 IF_DEBUG2(XPR(NTR "[srcblock] %"Q"u last srcpos %"Q"u "
157 "encodepos %"Q"u\n", 157 "encodepos %"Q"u\n",
158 encode_source.getblkno, 158 encode_source.getblkno,
159 encode_stream.match_last_srcpos, 159 encode_stream.match_last_srcpos,
@@ -931,13 +931,15 @@ void TestHalfBlockCopy() {
931 FileSpec spec0(&rand); 931 FileSpec spec0(&rand);
932 FileSpec spec1(&rand); 932 FileSpec spec1(&rand);
933 933
934 spec0.GenerateFixedSize(Constants::BLOCK_SIZE * 4); 934 // The test takes place over four blocks, but we create a 8-block
935 // file to ensure that the whole input doesn't fit in memory.
936 spec0.GenerateFixedSize(Constants::BLOCK_SIZE * 8);
935 937
936 // Create a half-block copy, 2.5 blocks apart, from the second half 938 // Create a half-block copy, 2.5 blocks apart, from the second half
937 // of the source version to the first half of the target version. 939 // of the source version to the first half of the target version.
938 // 0 1 2 3 940 // 0 1 2 3
939 // spec0 [bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb][ccccc][bbbbb] 941 // spec0 [bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb][ccccc][bbbbb...]
940 // spec1 [aaaaa][ccccc][aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] 942 // spec1 [aaaaa][ccccc][aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...]
941 ChangeList cl1; 943 ChangeList cl1;
942 cl1.push_back(Change(Change::MODIFY, 944 cl1.push_back(Change(Change::MODIFY,
943 Constants::BLOCK_SIZE / 2, // size 945 Constants::BLOCK_SIZE / 2, // size
@@ -947,17 +949,15 @@ void TestHalfBlockCopy() {
947 Constants::BLOCK_SIZE * 3, // offset 949 Constants::BLOCK_SIZE * 3, // offset
948 Constants::BLOCK_SIZE / 2)); 950 Constants::BLOCK_SIZE / 2));
949 cl1.push_back(Change(Change::MODIFY, 951 cl1.push_back(Change(Change::MODIFY,
950 Constants::BLOCK_SIZE * 3, 952 Constants::BLOCK_SIZE * 7,
951 Constants::BLOCK_SIZE)); 953 Constants::BLOCK_SIZE));
952 spec0.ModifyTo(ChangeListMutator(cl1), &spec1); 954 spec0.ModifyTo(ChangeListMutator(cl1), &spec1);
953 955
954 const int onecopy_adds = 956 const int nocopy_adds = 8 * Constants::BLOCK_SIZE;
955 4 * Constants::BLOCK_SIZE - Constants::BLOCK_SIZE / 2; 957 const int onecopy_adds = nocopy_adds - Constants::BLOCK_SIZE / 2;
956 const int nocopy_adds = 4 * Constants::BLOCK_SIZE;
957 958
958 // Note the case b=4 is contrived: the caller should use a single block 959 // TODO Note restricted loop
959 // containing the entire source, if possible. 960 for (int b = 4; b <= 4; b++)
960 for (int b = 1; b <= 4; b++)
961 { 961 {
962 Options options; 962 Options options;
963 options.encode_srcwin_maxsz = Constants::BLOCK_SIZE * b; 963 options.encode_srcwin_maxsz = Constants::BLOCK_SIZE * b;
@@ -974,12 +974,12 @@ void TestHalfBlockCopy() {
974 // the first target block is ready, the caller is expected to 974 // the first target block is ready, the caller is expected to
975 // use a single block. 975 // use a single block.
976 CHECK_EQ(nocopy_adds, delta0.AddedBytes()); 976 CHECK_EQ(nocopy_adds, delta0.AddedBytes());
977 if (Constants::BLOCK_SIZE < 8192 || b > 2) 977 if (Constants::BLOCK_SIZE < 8192 || b > 3)
978 { 978 {
979 // For small-block inputs, the entire file is read into one 979 // For small-block inputs, the entire file is read into one
980 // block (the min source window size is 16kB). 980 // block (the min source window size is 16kB).
981 // 981 //
982 // For large blocks, at least 3 blocks of source window are 982 // For large blocks, at least 4 blocks of source window are
983 // needed. 983 // needed.
984 CHECK_EQ(onecopy_adds, delta1.AddedBytes()); 984 CHECK_EQ(onecopy_adds, delta1.AddedBytes());
985 } 985 }
@@ -1299,10 +1299,10 @@ int main(int argc, char **argv)
1299 mcmd.push_back("test"); 1299 mcmd.push_back("test");
1300 mcmd.push_back(NULL); 1300 mcmd.push_back(NULL);
1301 1301
1302 UnitTest<SmallBlock>(); 1302 // UnitTest<SmallBlock>();
1303 MainTest<SmallBlock>(); 1303 // MainTest<SmallBlock>();
1304 MainTest<MixedBlock>(); 1304 // MainTest<MixedBlock>();
1305 MainTest<OversizeBlock>(); 1305 // MainTest<OversizeBlock>();
1306 MainTest<LargeBlock>(); 1306 MainTest<LargeBlock>();
1307 1307
1308 CHECK_EQ(0, xd3_main_cmdline(mcmd.size() - 1, 1308 CHECK_EQ(0, xd3_main_cmdline(mcmd.size() - 1,