summaryrefslogtreecommitdiff
path: root/xdelta3/testing/regtest.cc
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2009-10-25 16:38:08 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2009-10-25 16:38:08 +0000
commitf7f72abe8fe48766b545df3949b09fe25f900aee (patch)
treeaf481d375c55ed44f2ee7d13a474afe4b8a086ef /xdelta3/testing/regtest.cc
parent8681251a19d6a845a725fba60eb0a4c9fa3c375c (diff)
Eliminates xd3_source->size, which is an _API Change_. Adds a new requirement, that
source->blocksize be a power-of-2. DOES NOT PASS ALL TESTS.
Diffstat (limited to 'xdelta3/testing/regtest.cc')
-rw-r--r--xdelta3/testing/regtest.cc35
1 files changed, 18 insertions, 17 deletions
diff --git a/xdelta3/testing/regtest.cc b/xdelta3/testing/regtest.cc
index 7618b38..2065ec6 100644
--- a/xdelta3/testing/regtest.cc
+++ b/xdelta3/testing/regtest.cc
@@ -55,10 +55,7 @@ void InMemoryEncodeDecode(const FileSpec &source_file,
55 CHECK_EQ(0, xd3_config_stream (&encode_stream, &encode_config)); 55 CHECK_EQ(0, xd3_config_stream (&encode_stream, &encode_config));
56 CHECK_EQ(0, xd3_config_stream (&decode_stream, &decode_config)); 56 CHECK_EQ(0, xd3_config_stream (&decode_stream, &decode_config));
57 57
58 encode_source.size = source_file.Size();
59 encode_source.blksize = Constants::BLOCK_SIZE; 58 encode_source.blksize = Constants::BLOCK_SIZE;
60
61 decode_source.size = source_file.Size();
62 decode_source.blksize = Constants::BLOCK_SIZE; 59 decode_source.blksize = Constants::BLOCK_SIZE;
63 60
64 xd3_set_source (&encode_stream, &encode_source); 61 xd3_set_source (&encode_stream, &encode_source);
@@ -72,20 +69,20 @@ void InMemoryEncodeDecode(const FileSpec &source_file,
72 bool done = false; 69 bool done = false;
73 bool done_after_input = false; 70 bool done_after_input = false;
74 71
75 DP(RINT "source %"Q"u[%"Q"u] target %"Q"u[%lu] winsize %lu\n", 72 IF_DEBUG1 (DP(RINT "source %"Q"u[%"Q"u] target %"Q"u[%lu] winsize %lu\n",
76 source_file.Size(), Constants::BLOCK_SIZE, 73 source_file.Size(), Constants::BLOCK_SIZE,
77 target_file.Size(), Constants::READ_SIZE, 74 target_file.Size(), Constants::READ_SIZE,
78 Constants::WINDOW_SIZE); 75 Constants::WINDOW_SIZE));
79 76
80 while (!done) { 77 while (!done) {
81 target_iterator.Get(&target_block); 78 target_iterator.Get(&target_block);
82 79
83 xoff_t blks = target_iterator.Blocks(); 80 xoff_t blks = target_iterator.Blocks();
84 81
85 //DP(RINT "target in %s: %llu..%llu %"Q"u(%"Q"u) verified %"Q"u\n", 82 IF_DEBUG1(DP(RINT "target in %s: %llu..%llu %"Q"u(%"Q"u) verified %"Q"u\n",
86 // encoding ? "encoding" : "decoding", 83 encoding ? "encoding" : "decoding",
87 // target_iterator.Offset(), target_iterator.Offset() + target_block.Size(), 84 target_iterator.Offset(), target_iterator.Offset() + target_block.Size(),
88 // target_iterator.Blkno(), blks, verified_bytes); 85 target_iterator.Blkno(), blks, verified_bytes));
89 86
90 if (blks == 0 || target_iterator.Blkno() == (blks - 1)) { 87 if (blks == 0 || target_iterator.Blkno() == (blks - 1)) {
91 xd3_set_flags(&encode_stream, XD3_FLUSH | encode_stream.flags); 88 xd3_set_flags(&encode_stream, XD3_FLUSH | encode_stream.flags);
@@ -96,14 +93,18 @@ void InMemoryEncodeDecode(const FileSpec &source_file,
96 93
97 process: 94 process:
98 int ret; 95 int ret;
96 const char *msg;
99 if (encoding) { 97 if (encoding) {
100 ret = xd3_encode_input(&encode_stream); 98 ret = xd3_encode_input(&encode_stream);
99 msg = encode_stream.msg;
101 } else { 100 } else {
102 ret = xd3_decode_input(&decode_stream); 101 ret = xd3_decode_input(&decode_stream);
102 msg = decode_stream.msg;
103 } 103 }
104 104
105 //DP(RINT "%s = %s\n", encoding ? "E " : " D", 105 IF_DEBUG1(DP(RINT "%s = %s %s\n", encoding ? "E " : " D",
106 // xd3_strerror(ret)); 106 xd3_strerror(ret),
107 msg == NULL ? "" : msg));
107 108
108 switch (ret) { 109 switch (ret) {
109 case XD3_OUTPUT: 110 case XD3_OUTPUT:
@@ -130,10 +131,10 @@ void InMemoryEncodeDecode(const FileSpec &source_file,
130 xd3_source *src = (encoding ? &encode_source : &decode_source); 131 xd3_source *src = (encoding ? &encode_source : &decode_source);
131 Block *block = (encoding ? &encode_source_block : &decode_source_block); 132 Block *block = (encoding ? &encode_source_block : &decode_source_block);
132 if (encoding) { 133 if (encoding) {
133 //DP(RINT "block %"Q"u last srcpos %"Q"u encodepos %u\n", 134 IF_DEBUG1(DP(RINT "block %"Q"u last srcpos %"Q"u encodepos %u\n",
134 // encode_source.getblkno, 135 encode_source.getblkno,
135 // encode_stream.match_last_srcpos, 136 encode_stream.match_last_srcpos,
136 // encode_stream.input_position); 137 encode_stream.input_position));
137 } 138 }
138 139
139 source_iterator.SetBlock(src->getblkno); 140 source_iterator.SetBlock(src->getblkno);