summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2010-02-21 23:03:48 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2010-02-21 23:03:48 +0000
commit0cdb6aeccd29f82ab5128a9cac2172ffd3d8386b (patch)
tree09e09441c60466060ee32d9954954dfb8c318234
parent03795531fa7e3d68bd18329aceeaba57859aebd3 (diff)
Fix the handling of external source decompression, which changed in 3.0w
and was inadequately tested. Mark version 3.0y.
-rw-r--r--xdelta3/Makefile4
-rw-r--r--xdelta3/Makefile.mingw2
-rw-r--r--xdelta3/setup.py2
-rw-r--r--xdelta3/xdelta3-main.h108
-rw-r--r--xdelta3/xdelta3-test.h81
5 files changed, 116 insertions, 81 deletions
diff --git a/xdelta3/Makefile b/xdelta3/Makefile
index 62a4adf..398c255 100644
--- a/xdelta3/Makefile
+++ b/xdelta3/Makefile
@@ -57,7 +57,7 @@ CFLAGS= -Wall -Wshadow -fno-builtin
57WFLAGS= -Wextra -Wsign-compare -Wconversion -Wextra -Wno-unused-parameter 57WFLAGS= -Wextra -Wsign-compare -Wconversion -Wextra -Wno-unused-parameter
58 58
59# $Format: "REL=$Xdelta3Version$" $ 59# $Format: "REL=$Xdelta3Version$" $
60REL=3.0x 60REL=3.0y
61 61
62RELDIR = xdelta$(REL) 62RELDIR = xdelta$(REL)
63 63
@@ -72,7 +72,7 @@ EXTRA = Makefile COPYING linkxd3lib.c badcopy.c xdelta3.swig \
72 testing/cmp.h testing/delta.h testing/file.h \ 72 testing/cmp.h testing/delta.h testing/file.h \
73 testing/modify.h testing/random.h testing/segment.h \ 73 testing/modify.h testing/random.h testing/segment.h \
74 testing/sizes.h testing/test.h testing/Makefile \ 74 testing/sizes.h testing/test.h testing/Makefile \
75 testing/regtest.cc README readme.txt 75 testing/regtest.cc README readme.txt xdelta3.1
76 76
77SWIG_FLAGS = -DXD3_DEBUG=1 \ 77SWIG_FLAGS = -DXD3_DEBUG=1 \
78 -DEXTERNAL_COMPRESSION=0 \ 78 -DEXTERNAL_COMPRESSION=0 \
diff --git a/xdelta3/Makefile.mingw b/xdelta3/Makefile.mingw
index e775ec6..22877b3 100644
--- a/xdelta3/Makefile.mingw
+++ b/xdelta3/Makefile.mingw
@@ -55,7 +55,7 @@ CFLAGS= -Wall -Wshadow -fno-builtin
55XDWINFLAGS:=-DXD3_STDIO=0 -DXD3_POSIX=0 -DXD3_WIN32=1 -DEXTERNAL_COMPRESSION=0 55XDWINFLAGS:=-DXD3_STDIO=0 -DXD3_POSIX=0 -DXD3_WIN32=1 -DEXTERNAL_COMPRESSION=0
56 56
57# $Format: "REL=$Xdelta3Version$" $ 57# $Format: "REL=$Xdelta3Version$" $
58REL=3.0x 58REL=3.0y
59 59
60RELDIR = xdelta$(REL) 60RELDIR = xdelta$(REL)
61 61
diff --git a/xdelta3/setup.py b/xdelta3/setup.py
index 218bb4e..53722bb 100644
--- a/xdelta3/setup.py
+++ b/xdelta3/setup.py
@@ -50,7 +50,7 @@ xdelta3_ext = Extension('xdelta3main',
50 ]) 50 ])
51 51
52# $Format: "REL='$Xdelta3Version$'" $ 52# $Format: "REL='$Xdelta3Version$'" $
53REL='3.0x' 53REL='3.0y'
54 54
55# This provides xdelta3.main(), which calls the xdelta3 command-line main() 55# This provides xdelta3.main(), which calls the xdelta3 command-line main()
56# from python. 56# from python.
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h
index 56c283a..19def5d 100644
--- a/xdelta3/xdelta3-main.h
+++ b/xdelta3/xdelta3-main.h
@@ -150,9 +150,9 @@ static STARTUPINFO winStartupInfo;
150 * inputs to the Xdelta encoder. */ 150 * inputs to the Xdelta encoder. */
151typedef enum 151typedef enum
152{ 152{
153 RD_FIRST = (1 << 0), 153 RD_FIRST = (1 << 0),
154 RD_NONEXTERNAL = (1 << 1), 154 RD_NONEXTERNAL = (1 << 1),
155 RD_EXTERNAL_V1 = (1 << 2), 155 RD_DECOMPSET = (1 << 2),
156} xd3_read_flags; 156} xd3_read_flags;
157 157
158/* main_file->mode values */ 158/* main_file->mode values */
@@ -388,7 +388,7 @@ static int
388main_version (void) 388main_version (void)
389{ 389{
390 /* $Format: " DP(RINT \"Xdelta version $Xdelta3Version$, Copyright (C) 2007, 2008, 2009, 2010, Joshua MacDonald\n\");" $ */ 390 /* $Format: " DP(RINT \"Xdelta version $Xdelta3Version$, Copyright (C) 2007, 2008, 2009, 2010, Joshua MacDonald\n\");" $ */
391 DP(RINT "Xdelta version 3.0x, Copyright (C) 2007, 2008, 2009, 2010, Joshua MacDonald\n"); 391 DP(RINT "Xdelta version 3.0y, Copyright (C) 2007, 2008, 2009, 2010, Joshua MacDonald\n");
392 DP(RINT "Xdelta comes with ABSOLUTELY NO WARRANTY.\n"); 392 DP(RINT "Xdelta comes with ABSOLUTELY NO WARRANTY.\n");
393 DP(RINT "This is free software, and you are welcome to redistribute it\n"); 393 DP(RINT "This is free software, and you are welcome to redistribute it\n");
394 DP(RINT "under certain conditions; see \"COPYING\" for details.\n"); 394 DP(RINT "under certain conditions; see \"COPYING\" for details.\n");
@@ -1923,7 +1923,7 @@ main_merge_output (xd3_stream *stream, main_file *ofile)
1923 (stream->dec_win_ind & VCD_ADLER32) != 0) 1923 (stream->dec_win_ind & VCD_ADLER32) != 0)
1924 { 1924 {
1925 recode_stream->flags |= XD3_ADLER32_RECODE; 1925 recode_stream->flags |= XD3_ADLER32_RECODE;
1926 recode_stream->recode_adler32 = 1926 recode_stream->recode_adler32 =
1927 stream->whole_target.wininfo[window_num].adler32; 1927 stream->whole_target.wininfo[window_num].adler32;
1928 } 1928 }
1929 1929
@@ -2206,14 +2206,14 @@ main_pipe_copier (uint8_t *pipe_buf,
2206 * the decompression command, the second process copies data to the 2206 * the decompression command, the second process copies data to the
2207 * input of the first. */ 2207 * input of the first. */
2208static int 2208static int
2209main_input_decompress_setup (const main_extcomp *decomp, 2209main_input_decompress_setup (const main_extcomp *decomp,
2210 main_file *ifile, 2210 main_file *ifile,
2211 uint8_t *input_buf, 2211 uint8_t *input_buf,
2212 usize_t input_bufsize, 2212 usize_t input_bufsize,
2213 uint8_t *pipe_buf, 2213 uint8_t *pipe_buf,
2214 usize_t pipe_bufsize, 2214 usize_t pipe_bufsize,
2215 usize_t pipe_avail, 2215 usize_t pipe_avail,
2216 usize_t *nread) 2216 usize_t *nread)
2217{ 2217{
2218 /* The two pipes: input and output file descriptors. */ 2218 /* The two pipes: input and output file descriptors. */
2219 int outpipefd[2], inpipefd[2]; 2219 int outpipefd[2], inpipefd[2];
@@ -2352,6 +2352,7 @@ main_secondary_decompress_check (main_file *file,
2352 usize_t try_read = min (input_size, XD3_ALLOCSIZE); 2352 usize_t try_read = min (input_size, XD3_ALLOCSIZE);
2353 usize_t check_nread; 2353 usize_t check_nread;
2354 uint8_t check_buf[XD3_ALLOCSIZE]; /* TODO: stack limit */ 2354 uint8_t check_buf[XD3_ALLOCSIZE]; /* TODO: stack limit */
2355 const main_extcomp *decompressor = NULL;
2355 2356
2356 if ((ret = main_file_read (file, check_buf, 2357 if ((ret = main_file_read (file, check_buf,
2357 try_read, 2358 try_read,
@@ -2360,25 +2361,49 @@ main_secondary_decompress_check (main_file *file,
2360 return ret; 2361 return ret;
2361 } 2362 }
2362 2363
2363 for (i = 0; i < SIZEOF_ARRAY (extcomp_types); i += 1) 2364 if (file->flags & RD_DECOMPSET)
2364 { 2365 {
2365 const main_extcomp *decomp = & extcomp_types[i]; 2366 /* This allows the application header to override the magic
2366 2367 * number, for whatever reason. */
2367 if ((check_nread > decomp->magic_size) && 2368 decompressor = file->compressor;
2368 /* The following expr skips decompression if we are trying 2369 }
2369 * to read a VCDIFF input and that is the magic number. */ 2370 else
2370 !((decomp->flags & RD_NONEXTERNAL) && 2371 {
2371 (file->flags & RD_NONEXTERNAL)) && 2372 for (i = 0; i < SIZEOF_ARRAY (extcomp_types); i += 1)
2372 memcmp (check_buf, decomp->magic, decomp->magic_size) == 0)
2373 { 2373 {
2374 file->size_known = 0; 2374 const main_extcomp *decomp = & extcomp_types[i];
2375 return main_input_decompress_setup (decomp, file, 2375
2376 input_buf, input_size, 2376 if (check_nread > decomp->magic_size)
2377 check_buf, XD3_ALLOCSIZE, 2377 {
2378 check_nread, nread); 2378 /* The following expr checks if we are trying to read a
2379 * VCDIFF input, in which case do not treat it as
2380 * "secondary" decompression. */
2381 int skip_this_type = (decomp->flags & RD_NONEXTERNAL) &&
2382 (file->flags & RD_NONEXTERNAL);
2383
2384 if (skip_this_type)
2385 {
2386 continue;
2387 }
2388
2389 if (memcmp (check_buf, decomp->magic, decomp->magic_size) == 0)
2390 {
2391 decompressor = decomp;
2392 break;
2393 }
2394 }
2379 } 2395 }
2380 } 2396 }
2381 2397
2398 if (decompressor != NULL)
2399 {
2400 file->size_known = 0;
2401 return main_input_decompress_setup (decompressor, file,
2402 input_buf, input_size,
2403 check_buf, XD3_ALLOCSIZE,
2404 check_nread, nread);
2405 }
2406
2382 /* Now read the rest of the input block. */ 2407 /* Now read the rest of the input block. */
2383 (*nread) = 0; 2408 (*nread) = 0;
2384 2409
@@ -2655,6 +2680,7 @@ main_get_appheader_params (main_file *file, char **parsed,
2655 /* Set the compressor, initiate de/recompression later. */ 2680 /* Set the compressor, initiate de/recompression later. */
2656 if (file->compressor == NULL && *parsed[1] != 0) 2681 if (file->compressor == NULL && *parsed[1] != 0)
2657 { 2682 {
2683 file->flags |= RD_DECOMPSET;
2658 file->compressor = main_get_compressor (parsed[1]); 2684 file->compressor = main_get_compressor (parsed[1]);
2659 } 2685 }
2660} 2686}
@@ -2723,22 +2749,13 @@ static int
2723main_read_primary_input (main_file *file, 2749main_read_primary_input (main_file *file,
2724 uint8_t *buf, 2750 uint8_t *buf,
2725 usize_t size, 2751 usize_t size,
2726 usize_t *nread, 2752 usize_t *nread)
2727 int is_source)
2728{ 2753{
2729#if EXTERNAL_COMPRESSION 2754#if EXTERNAL_COMPRESSION
2730 if (option_decompress_inputs && file->flags & RD_FIRST) 2755 if (option_decompress_inputs && file->flags & RD_FIRST)
2731 { 2756 {
2732 file->flags &= ~RD_FIRST; 2757 file->flags &= ~RD_FIRST;
2733 2758 return main_secondary_decompress_check (file, buf, size, nread);
2734 if (is_source && file->compressor == NULL)
2735 {
2736 /* Application header overrides magic number. */
2737 }
2738 else
2739 {
2740 return main_secondary_decompress_check (file, buf, size, nread);
2741 }
2742 } 2759 }
2743#endif 2760#endif
2744 2761
@@ -2879,7 +2896,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
2879 2896
2880 /* We have to read the first block into the cache now, because 2897 /* We have to read the first block into the cache now, because
2881 * size_known can still change (due to secondary 2898 * size_known can still change (due to secondary
2882 * decompression). Calls main_decompress_input_check() via 2899 * decompression). Calls main_secondary_decompress_check() via
2883 * main_read_primary_input(). */ 2900 * main_read_primary_input(). */
2884 /* TODO(jmacd): This is a huge hack! Fix me. */ 2901 /* TODO(jmacd): This is a huge hack! Fix me. */
2885 lru_size = 1; 2902 lru_size = 1;
@@ -3051,7 +3068,7 @@ main_get_winsize (main_file *ifile) {
3051 *******************************************************************/ 3068 *******************************************************************/
3052 3069
3053static int 3070static int
3054main_getblk_lru (xd3_source *source, xoff_t blkno, 3071main_getblk_lru (xd3_source *source, xoff_t blkno,
3055 main_blklru** blrup, int *is_new) 3072 main_blklru** blrup, int *is_new)
3056{ 3073{
3057 main_blklru *blru = NULL; 3074 main_blklru *blru = NULL;
@@ -3178,7 +3195,7 @@ main_read_seek_source (xd3_stream *stream,
3178 xoff_t skip_blkno; 3195 xoff_t skip_blkno;
3179 usize_t skip_offset; 3196 usize_t skip_offset;
3180 3197
3181 xd3_blksize_div (sfile->source_position, source, 3198 xd3_blksize_div (sfile->source_position, source,
3182 &skip_blkno, &skip_offset); 3199 &skip_blkno, &skip_offset);
3183 3200
3184 /* Read past unused data */ 3201 /* Read past unused data */
@@ -3196,8 +3213,7 @@ main_read_seek_source (xd3_stream *stream,
3196 if ((ret = main_read_primary_input (sfile, 3213 if ((ret = main_read_primary_input (sfile,
3197 (uint8_t*) blru->blk, 3214 (uint8_t*) blru->blk,
3198 source->blksize, 3215 source->blksize,
3199 & nread, 3216 & nread)))
3200 1 /* source */)))
3201 { 3217 {
3202 return ret; 3218 return ret;
3203 } 3219 }
@@ -3295,8 +3311,7 @@ main_getblk_func (xd3_stream *stream,
3295 if ((ret = main_read_primary_input (sfile, 3311 if ((ret = main_read_primary_input (sfile,
3296 (uint8_t*) blru->blk, 3312 (uint8_t*) blru->blk,
3297 source->blksize, 3313 source->blksize,
3298 & nread, 3314 & nread)))
3299 1 /* source */)))
3300 { 3315 {
3301 return ret; 3316 return ret;
3302 } 3317 }
@@ -3564,8 +3579,7 @@ main_input (xd3_cmd cmd,
3564 try_read = (usize_t) min ((xoff_t) config.winsize, input_remain); 3579 try_read = (usize_t) min ((xoff_t) config.winsize, input_remain);
3565 3580
3566 if ((ret = main_read_primary_input (ifile, main_bdata, 3581 if ((ret = main_read_primary_input (ifile, main_bdata,
3567 try_read, & nread, 3582 try_read, & nread)))
3568 0 /* !source */)))
3569 { 3583 {
3570 return EXIT_FAILURE; 3584 return EXIT_FAILURE;
3571 } 3585 }
diff --git a/xdelta3/xdelta3-test.h b/xdelta3/xdelta3-test.h
index 21d7283..9050554 100644
--- a/xdelta3/xdelta3-test.h
+++ b/xdelta3/xdelta3-test.h
@@ -43,7 +43,7 @@ void mt_init(mtrand *mt, uint32_t seed) {
43 /* In the previous versions, MSBs of the seed affect */ 43 /* In the previous versions, MSBs of the seed affect */
44 /* only MSBs of the array mt[]. */ 44 /* only MSBs of the array mt[]. */
45 /* 2002/01/09 modified by Makoto Matsumoto */ 45 /* 2002/01/09 modified by Makoto Matsumoto */
46 mt->mt_buffer_[i] = 46 mt->mt_buffer_[i] =
47 (1812433253UL * (mt->mt_buffer_[i-1] ^ (mt->mt_buffer_[i-1] >> 30)) + i); 47 (1812433253UL * (mt->mt_buffer_[i-1] ^ (mt->mt_buffer_[i-1] >> 30)) + i);
48 } 48 }
49} 49}
@@ -70,14 +70,14 @@ uint32_t mt_random (mtrand *mt) {
70 mt->mt_buffer_[MT_LEN - 1] = mt->mt_buffer_[MT_IA - 1] ^ (y >> 1) ^ mag01[y & 0x1UL]; 70 mt->mt_buffer_[MT_LEN - 1] = mt->mt_buffer_[MT_IA - 1] ^ (y >> 1) ^ mag01[y & 0x1UL];
71 mt->mt_index_ = 0; 71 mt->mt_index_ = 0;
72 } 72 }
73 73
74 y = mt->mt_buffer_[mt->mt_index_++]; 74 y = mt->mt_buffer_[mt->mt_index_++];
75 75
76 y ^= (y >> 11); 76 y ^= (y >> 11);
77 y ^= (y << 7) & 0x9d2c5680UL; 77 y ^= (y << 7) & 0x9d2c5680UL;
78 y ^= (y << 15) & 0xefc60000UL; 78 y ^= (y << 15) & 0xefc60000UL;
79 y ^= (y >> 18); 79 y ^= (y >> 18);
80 80
81 return y; 81 return y;
82} 82}
83 83
@@ -89,7 +89,7 @@ static uint32_t
89mt_exp_rand (uint32_t mean, uint32_t max_value) 89mt_exp_rand (uint32_t mean, uint32_t max_value)
90{ 90{
91 double mean_d = mean; 91 double mean_d = mean;
92 double erand = log (1.0 / (mt_random (&static_mtrand) / 92 double erand = log (1.0 / (mt_random (&static_mtrand) /
93 (double)UINT32_MAX)); 93 (double)UINT32_MAX));
94 uint32_t x = (uint32_t) (mean_d * erand + 0.5); 94 uint32_t x = (uint32_t) (mean_d * erand + 0.5);
95 95
@@ -1961,7 +1961,7 @@ test_recode_command2 (xd3_stream *stream, int has_source,
1961 1961
1962 /* Now decode */ 1962 /* Now decode */
1963 sprintf (dcmd, "%s -fd ", program_name); 1963 sprintf (dcmd, "%s -fd ", program_name);
1964 1964
1965 if (has_source) 1965 if (has_source)
1966 { 1966 {
1967 strcat (dcmd, "-s "); 1967 strcat (dcmd, "-s ");
@@ -1987,14 +1987,14 @@ test_recode_command2 (xd3_stream *stream, int has_source,
1987 } 1987 }
1988 1988
1989 return 0; 1989 return 0;
1990} 1990}
1991 1991
1992static int 1992static int
1993test_recode_command (xd3_stream *stream, int ignore) 1993test_recode_command (xd3_stream *stream, int ignore)
1994{ 1994{
1995 /* Things to test: 1995 /* Things to test:
1996 * - with and without a source file (recode does not change) 1996 * - with and without a source file (recode does not change)
1997 * 1997 *
1998 * (recode may or may not change -- 8 variations) 1998 * (recode may or may not change -- 8 variations)
1999 * - with and without adler32 1999 * - with and without adler32
2000 * - with and without app header 2000 * - with and without app header
@@ -2146,6 +2146,7 @@ test_source_decompression (xd3_stream *stream, int ignore)
2146 int ret; 2146 int ret;
2147 char buf[TESTBUFSIZE]; 2147 char buf[TESTBUFSIZE];
2148 const main_extcomp *ext; 2148 const main_extcomp *ext;
2149 xoff_t dsize;
2149 2150
2150 mt_init (& static_mtrand, 0x9f73f7fc); 2151 mt_init (& static_mtrand, 0x9f73f7fc);
2151 2152
@@ -2153,53 +2154,73 @@ test_source_decompression (xd3_stream *stream, int ignore)
2153 if ((ret = test_make_inputs (stream, NULL, NULL))) { return ret; } 2154 if ((ret = test_make_inputs (stream, NULL, NULL))) { return ret; }
2154 2155
2155 /* Use gzip. */ 2156 /* Use gzip. */
2156 if ((ext = main_get_compressor ("G")) == NULL) { DP(RINT "skipped"); return 0; } 2157 if ((ext = main_get_compressor ("G")) == NULL)
2158 {
2159 DP(RINT "skipped");
2160 return 0;
2161 }
2157 2162
2158 /* Save an uncompressed copy. */ 2163 /* Save an uncompressed copy. */
2159 if ((ret = test_save_copy (TEST_TARGET_FILE))) { return ret; } 2164 if ((ret = test_save_copy (TEST_TARGET_FILE))) { return ret; }
2160 2165
2161 /* Compress the target. */ 2166 /* Compress the source. */
2162 sprintf (buf, "%s %s < %s > %s", ext->recomp_cmdname, 2167 sprintf (buf, "%s -1 %s < %s > %s", ext->recomp_cmdname,
2163 ext->recomp_options, TEST_TARGET_FILE, TEST_SOURCE_FILE); 2168 ext->recomp_options, TEST_COPY_FILE, TEST_SOURCE_FILE);
2164 if ((ret = do_cmd (stream, buf))) { return ret; } 2169 if ((ret = do_cmd (stream, buf))) { return ret; }
2165 2170 /* Compress the target. */
2166 /* Copy back to the source. */ 2171 sprintf (buf, "%s -9 %s < %s > %s", ext->recomp_cmdname,
2167 sprintf (buf, "cp -f %s %s", TEST_SOURCE_FILE, TEST_TARGET_FILE); 2172 ext->recomp_options, TEST_COPY_FILE, TEST_TARGET_FILE);
2168 if ((ret = do_cmd (stream, buf))) { return ret; } 2173 if ((ret = do_cmd (stream, buf))) { return ret; }
2169 2174
2170 /* Now the two identical files are compressed. Delta-encode the target, 2175 /* Now the two identical files are compressed. Delta-encode the target,
2171 * with decompression. */ 2176 * with decompression. */
2172 sprintf (buf, "%s -v -eq -s%s %s %s", program_name, TEST_SOURCE_FILE, TEST_TARGET_FILE, TEST_DELTA_FILE); 2177 sprintf (buf, "%s -e -A -vfq -s%s %s %s", program_name, TEST_SOURCE_FILE,
2178 TEST_TARGET_FILE, TEST_DELTA_FILE);
2173 if ((ret = do_cmd (stream, buf))) { return ret; } 2179 if ((ret = do_cmd (stream, buf))) { return ret; }
2174 2180
2181 /* Check that the compressed file is small (b/c inputs are
2182 * identical). */
2183 if ((ret = test_file_size (TEST_DELTA_FILE, & dsize))) { return ret; }
2184 /* Deltas for identical files should be very small. */
2185 if (dsize > 200)
2186 {
2187 DP(RINT "external compression did not happen\n");
2188 stream->msg = "external compression did not happen";
2189 return XD3_INTERNAL;
2190 }
2191
2175 /* Decode the delta file with recompression disabled, should get an 2192 /* Decode the delta file with recompression disabled, should get an
2176 * uncompressed file out. */ 2193 * uncompressed file out. */
2177 sprintf (buf, "%s -v -dq -R -s%s %s %s", program_name, TEST_SOURCE_FILE, TEST_DELTA_FILE, TEST_RECON_FILE); 2194 sprintf (buf, "%s -v -dq -R -s%s %s %s", program_name,
2195 TEST_SOURCE_FILE, TEST_DELTA_FILE, TEST_RECON_FILE);
2178 if ((ret = do_cmd (stream, buf))) { return ret; } 2196 if ((ret = do_cmd (stream, buf))) { return ret; }
2179 if ((ret = compare_files (stream, TEST_COPY_FILE, TEST_RECON_FILE))) { return ret; } 2197 if ((ret = compare_files (stream, TEST_COPY_FILE,
2198 TEST_RECON_FILE))) { return ret; }
2180 2199
2181 /* Decode the delta file with recompression, should get a compressed file 2200 /* Decode the delta file with recompression, should get a compressed file
2182 * out. But we can't compare compressed files directly. */ 2201 * out. But we can't compare compressed files directly. */
2183 sprintf (buf, "%s -v -dqf -s%s %s %s", program_name, TEST_SOURCE_FILE, TEST_DELTA_FILE, TEST_RECON_FILE); 2202 sprintf (buf, "%s -v -dqf -s%s %s %s", program_name,
2203 TEST_SOURCE_FILE, TEST_DELTA_FILE, TEST_RECON_FILE);
2184 if ((ret = do_cmd (stream, buf))) { return ret; } 2204 if ((ret = do_cmd (stream, buf))) { return ret; }
2185 sprintf (buf, "%s %s < %s > %s", ext->decomp_cmdname, ext->decomp_options, TEST_RECON_FILE, TEST_RECON2_FILE); 2205 sprintf (buf, "%s %s < %s > %s", ext->decomp_cmdname, ext->decomp_options,
2206 TEST_RECON_FILE, TEST_RECON2_FILE);
2186 if ((ret = do_cmd (stream, buf))) { return ret; } 2207 if ((ret = do_cmd (stream, buf))) { return ret; }
2187 if ((ret = compare_files (stream, TEST_COPY_FILE, TEST_RECON2_FILE))) { return ret; } 2208 if ((ret = compare_files (stream, TEST_COPY_FILE,
2209 TEST_RECON2_FILE))) { return ret; }
2188 2210
2189 /* Encode with decompression disabled */ 2211 /* Encode with decompression disabled */
2190 sprintf (buf, "%s -v -feqD -s%s %s %s", program_name, TEST_SOURCE_FILE, TEST_TARGET_FILE, TEST_DELTA_FILE); 2212 sprintf (buf, "%s -e -D -vfq -s%s %s %s", program_name,
2213 TEST_SOURCE_FILE, TEST_TARGET_FILE, TEST_DELTA_FILE);
2191 if ((ret = do_cmd (stream, buf))) { return ret; } 2214 if ((ret = do_cmd (stream, buf))) { return ret; }
2192 2215
2193 /* Decode the delta file with recompression enabled, it doesn't matter, 2216 /* Decode the delta file with decompression disabled, should get the
2194 * should get the compressed file out. */ 2217 * identical compressed file out. */
2195 sprintf (buf, "%s -v -fdq -s%s %s %s", program_name, TEST_SOURCE_FILE, TEST_DELTA_FILE, TEST_RECON_FILE); 2218 sprintf (buf, "%s -d -D -vfq -s%s %s %s", program_name,
2219 TEST_SOURCE_FILE, TEST_DELTA_FILE, TEST_RECON_FILE);
2196 if ((ret = do_cmd (stream, buf))) { return ret; } 2220 if ((ret = do_cmd (stream, buf))) { return ret; }
2197 if ((ret = compare_files (stream, TEST_TARGET_FILE, TEST_RECON_FILE))) { return ret; } 2221 if ((ret = compare_files (stream, TEST_TARGET_FILE,
2222 TEST_RECON_FILE))) { return ret; }
2198 2223
2199 /* Try again with recompression disabled, it doesn't make a difference. */
2200 sprintf (buf, "%s -v -fqRd -s%s %s %s", program_name, TEST_SOURCE_FILE, TEST_DELTA_FILE, TEST_RECON_FILE);
2201 if ((ret = do_cmd (stream, buf))) { return ret; }
2202 if ((ret = compare_files (stream, TEST_TARGET_FILE, TEST_RECON_FILE))) { return ret; }
2203 test_cleanup(); 2224 test_cleanup();
2204 return 0; 2225 return 0;
2205} 2226}