summaryrefslogtreecommitdiff
path: root/xdelta3/examples/encode_decode_test.c
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2008-04-15 04:01:06 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2008-04-15 04:01:06 +0000
commit13a3797683e06fc55c5e19415fe70d0caef53f08 (patch)
tree38a5769518ba9d7774204114d0a8a8b1ec59d2d9 /xdelta3/examples/encode_decode_test.c
parenta5fcf7340127e5f55b7cec9af06dcf2386d2dbdb (diff)
Fixes for issue 70. The test inputs tickled a case where the
non-blocking API would not make progress, searching for match on the page boundary and repeatedly asking the application to get another source block. This is only a non-blocking issue, glad it's fixed. I'll add encode_decode_test to my test suite before another release.
Diffstat (limited to 'xdelta3/examples/encode_decode_test.c')
-rw-r--r--xdelta3/examples/encode_decode_test.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/xdelta3/examples/encode_decode_test.c b/xdelta3/examples/encode_decode_test.c
index 2b585df..353d8db 100644
--- a/xdelta3/examples/encode_decode_test.c
+++ b/xdelta3/examples/encode_decode_test.c
@@ -65,7 +65,7 @@ int code (
65 Input_Buf_Read = fread(Input_Buf, 1, BufSize, InFile); 65 Input_Buf_Read = fread(Input_Buf, 1, BufSize, InFile);
66 if (Input_Buf_Read < BufSize) 66 if (Input_Buf_Read < BufSize)
67 { 67 {
68 xd3_set_flags(&stream, XD3_FLUSH); 68 xd3_set_flags(&stream, XD3_FLUSH | stream.flags);
69 } 69 }
70 xd3_avail_input(&stream, Input_Buf, Input_Buf_Read); 70 xd3_avail_input(&stream, Input_Buf, Input_Buf_Read);
71 71
@@ -156,11 +156,21 @@ int main(int argc, char* argv[])
156 FILE* OutFile; 156 FILE* OutFile;
157 int r; 157 int r;
158 158
159 if (argc != 3) {
160 fprintf (stderr, "usage: %s source input output\n", argv[0]);
161 return 1;
162 }
163
164 char *input = argv[2];
165 char *source = argv[1];
166 const char *output = "encoded.testdata";
167 const char *decoded = "decoded.testdata";
168
159 /* Encode */ 169 /* Encode */
160 170
161 InFile = fopen("input.txt", "rb"); 171 InFile = fopen(input, "rb");
162 SrcFile = fopen("source.txt", "rb"); 172 SrcFile = fopen(source, "rb");
163 OutFile = fopen("encoded.txt", "wb"); 173 OutFile = fopen(output, "wb");
164 174
165 r = code (1, InFile, SrcFile, OutFile, 0x1000); 175 r = code (1, InFile, SrcFile, OutFile, 0x1000);
166 176
@@ -168,14 +178,16 @@ int main(int argc, char* argv[])
168 fclose(SrcFile); 178 fclose(SrcFile);
169 fclose(InFile); 179 fclose(InFile);
170 180
171 if (r) 181 if (r) {
182 fprintf (stderr, "Encode error: %d\n", r);
172 return r; 183 return r;
184 }
173 185
174 /* Decode */ 186 /* Decode */
175 187
176 InFile = fopen("encoded.txt", "rb"); 188 InFile = fopen(output, "rb");
177 SrcFile = fopen("source.txt", "rb"); 189 SrcFile = fopen(source, "rb");
178 OutFile = fopen("decoded.txt", "wb"); 190 OutFile = fopen(decoded, "wb");
179 191
180 r = code (0, InFile, SrcFile, OutFile, 0x1000); 192 r = code (0, InFile, SrcFile, OutFile, 0x1000);
181 193
@@ -183,8 +195,10 @@ int main(int argc, char* argv[])
183 fclose(SrcFile); 195 fclose(SrcFile);
184 fclose(InFile); 196 fclose(InFile);
185 197
186 if (r) 198 if (r) {
199 fprintf (stderr, "Decode error: %d\n", r);
187 return r; 200 return r;
201 }
188 202
189 return 0; 203 return 0;
190} 204}