xdelta3-test.h (xdelta3-3.0.10) | : | xdelta3-test.h (xdelta3-3.0.11) | ||
---|---|---|---|---|
skipping to change at line 236 | skipping to change at line 236 | |||
if (strcmp (buf, expect) == 0) { | if (strcmp (buf, expect) == 0) { | |||
return 0; | return 0; | |||
} | } | |||
return XD3_INTERNAL; | return XD3_INTERNAL; | |||
} | } | |||
static void | static void | |||
test_unlink (char* file) | test_unlink (char* file) | |||
{ | { | |||
int ret; | int ret; | |||
if ((ret = unlink (file)) != 0 && errno != ENOENT) | if (file != NULL && *file != 0 && | |||
(ret = unlink (file)) != 0 && errno != ENOENT) | ||||
{ | { | |||
XPR(NT "unlink %s failed: %s\n", file, strerror(ret)); | XPR(NT "unlink %s failed: %s\n", file, strerror(ret)); | |||
} | } | |||
} | } | |||
static void | static void | |||
test_cleanup (void) | test_cleanup (void) | |||
{ | { | |||
#if 1 | #if 1 | |||
test_unlink (TEST_TARGET_FILE); | test_unlink (TEST_TARGET_FILE); | |||
skipping to change at line 261 | skipping to change at line 262 | |||
test_unlink (TEST_COPY_FILE); | test_unlink (TEST_COPY_FILE); | |||
test_unlink (TEST_NOPERM_FILE); | test_unlink (TEST_NOPERM_FILE); | |||
#endif | #endif | |||
} | } | |||
int test_setup (void) | int test_setup (void) | |||
{ | { | |||
static int x = 0; | static int x = 0; | |||
pid_t pid = getpid(); | pid_t pid = getpid(); | |||
x++; | x++; | |||
test_cleanup(); | ||||
snprintf_func (TEST_TARGET_FILE, TESTFILESIZE, | snprintf_func (TEST_TARGET_FILE, TESTFILESIZE, | |||
"/tmp/xdtest.%d.target.%d", pid, x); | "/tmp/xdtest.%d.target.%d", pid, x); | |||
snprintf_func (TEST_SOURCE_FILE, TESTFILESIZE, | snprintf_func (TEST_SOURCE_FILE, TESTFILESIZE, | |||
"/tmp/xdtest.%d.source.%d", pid, x); | "/tmp/xdtest.%d.source.%d", pid, x); | |||
snprintf_func (TEST_DELTA_FILE, TESTFILESIZE, | snprintf_func (TEST_DELTA_FILE, TESTFILESIZE, | |||
"/tmp/xdtest.%d.delta.%d", pid, x); | "/tmp/xdtest.%d.delta.%d", pid, x); | |||
snprintf_func (TEST_RECON_FILE, TESTFILESIZE, | snprintf_func (TEST_RECON_FILE, TESTFILESIZE, | |||
"/tmp/xdtest.%d.recon.%d", pid, x); | "/tmp/xdtest.%d.recon.%d", pid, x); | |||
snprintf_func (TEST_RECON2_FILE, TESTFILESIZE, | snprintf_func (TEST_RECON2_FILE, TESTFILESIZE, | |||
"/tmp/xdtest.%d.recon2.%d", pid, x); | "/tmp/xdtest.%d.recon2.%d", pid, x); | |||
snprintf_func (TEST_COPY_FILE, TESTFILESIZE, | snprintf_func (TEST_COPY_FILE, TESTFILESIZE, | |||
"/tmp/xdtest.%d.copy.%d", pid, x); | "/tmp/xdtest.%d.copy.%d", pid, x); | |||
snprintf_func (TEST_NOPERM_FILE, TESTFILESIZE, | snprintf_func (TEST_NOPERM_FILE, TESTFILESIZE, | |||
"/tmp/xdtest.%d.noperm.%d", pid, x); | "/tmp/xdtest.%d.noperm.%d", pid, x); | |||
test_cleanup(); | test_cleanup(); | |||
return 0; | return 0; | |||
} | } | |||
static int | static int | |||
test_make_inputs (xd3_stream *stream, xoff_t *ss_out, xoff_t *ts_out) | test_make_inputs (xd3_stream *stream, xoff_t *ss_out, xoff_t *ts_out) | |||
{ | { | |||
usize_t ts = (mt_random (&static_mtrand) % TEST_FILE_MEAN) + | usize_t ts = (mt_random (&static_mtrand) % TEST_FILE_MEAN) + | |||
TEST_FILE_MEAN / 2; | TEST_FILE_MEAN / 2; | |||
usize_t ss = (mt_random (&static_mtrand) % TEST_FILE_MEAN) + | usize_t ss = (mt_random (&static_mtrand) % TEST_FILE_MEAN) + | |||
skipping to change at line 1512 | skipping to change at line 1517 | |||
return 0; | return 0; | |||
} | } | |||
IF_FGK (static int test_secondary_fgk (xd3_stream *stream, usize_t gp) | IF_FGK (static int test_secondary_fgk (xd3_stream *stream, usize_t gp) | |||
{ return test_secondary (stream, & fgk_sec_type, gp); }) | { return test_secondary (stream, & fgk_sec_type, gp); }) | |||
IF_DJW (static int test_secondary_huff (xd3_stream *stream, usize_t gp) | IF_DJW (static int test_secondary_huff (xd3_stream *stream, usize_t gp) | |||
{ return test_secondary (stream, & djw_sec_type, gp); }) | { return test_secondary (stream, & djw_sec_type, gp); }) | |||
IF_LZMA (static int test_secondary_lzma (xd3_stream *stream, usize_t gp) | IF_LZMA (static int test_secondary_lzma (xd3_stream *stream, usize_t gp) | |||
{ return test_secondary (stream, & lzma_sec_type, gp); }) | { return test_secondary (stream, & lzma_sec_type, gp); }) | |||
#endif | ||||
#endif /* SECONDARY_ANY */ | ||||
/*********************************************************************** | /*********************************************************************** | |||
TEST INSTRUCTION TABLE | TEST INSTRUCTION TABLE | |||
***********************************************************************/ | ***********************************************************************/ | |||
/* Test that xd3_choose_instruction() does the right thing for its code | /* Test that xd3_choose_instruction() does the right thing for its code | |||
* table. */ | * table. */ | |||
static int | static int | |||
test_choose_instruction (xd3_stream *stream, int ignore) | test_choose_instruction (xd3_stream *stream, int ignore) | |||
{ | { | |||
skipping to change at line 1909 | skipping to change at line 1915 | |||
stream->msg = "encode cmd failed"; | stream->msg = "encode cmd failed"; | |||
return XD3_INTERNAL; | return XD3_INTERNAL; | |||
} | } | |||
/* Now recode */ | /* Now recode */ | |||
snprintf_func (recmd, TESTBUFSIZE, | snprintf_func (recmd, TESTBUFSIZE, | |||
"%s recode %s -f %s %s %s %s %s", program_name, test_softcfg_str, | "%s recode %s -f %s %s %s %s %s", program_name, test_softcfg_str, | |||
recoded_adler32 ? "" : "-n ", | recoded_adler32 ? "" : "-n ", | |||
!change_apphead ? "" : | !change_apphead ? "" : | |||
(recoded_apphead ? "-A=recode_apphead " : "-A= "), | (recoded_apphead ? "-A=recode_apphead " : "-A= "), | |||
recoded_secondary ? "-S djw " : "-S none ", | recoded_secondary ? "-S djw " : "-S= ", | |||
TEST_DELTA_FILE, | TEST_DELTA_FILE, | |||
TEST_COPY_FILE); | TEST_COPY_FILE); | |||
if ((ret = system (recmd)) != 0) | if ((ret = system (recmd)) != 0) | |||
{ | { | |||
XPR(NT "recode command: %s\n", recmd); | XPR(NT "recode command: %s\n", recmd); | |||
stream->msg = "recode cmd failed"; | stream->msg = "recode cmd failed"; | |||
return XD3_INTERNAL; | return XD3_INTERNAL; | |||
} | } | |||
skipping to change at line 2005 | skipping to change at line 2011 | |||
XPR(NT "decode command: %s\n", dcmd); | XPR(NT "decode command: %s\n", dcmd); | |||
stream->msg = "decode cmd failed"; | stream->msg = "decode cmd failed"; | |||
return XD3_INTERNAL; | return XD3_INTERNAL; | |||
} | } | |||
/* Now compare. */ | /* Now compare. */ | |||
if ((ret = test_compare_files (TEST_TARGET_FILE, TEST_RECON_FILE))) | if ((ret = test_compare_files (TEST_TARGET_FILE, TEST_RECON_FILE))) | |||
{ | { | |||
return ret; | return ret; | |||
} | } | |||
test_cleanup (); | ||||
return 0; | return 0; | |||
} | } | |||
static int | static int | |||
test_recode_command (xd3_stream *stream, int ignore) | test_recode_command (xd3_stream *stream, int ignore) | |||
{ | { | |||
/* Things to test: | /* Things to test: | |||
* - with and without a source file (recode does not change) | * - with and without a source file (recode does not change) | |||
* | * | |||
skipping to change at line 2043 | skipping to change at line 2050 | |||
{ | { | |||
return ret; | return ret; | |||
} | } | |||
} | } | |||
DOT (); | DOT (); | |||
} | } | |||
} | } | |||
return 0; | return 0; | |||
} | } | |||
#endif | ||||
#if SECONDARY_LZMA | ||||
int test_secondary_lzma_default (xd3_stream *stream, int ignore) | ||||
{ | ||||
char ecmd[TESTBUFSIZE]; | ||||
int ret; | ||||
test_setup (); | ||||
if ((ret = test_make_inputs (stream, NULL, NULL))) | ||||
{ | ||||
return ret; | ||||
} | ||||
/* First encode */ | ||||
snprintf_func (ecmd, TESTBUFSIZE, "%s -e %s %s", | ||||
program_name, | ||||
TEST_TARGET_FILE, | ||||
TEST_DELTA_FILE); | ||||
if ((ret = system (ecmd)) != 0) | ||||
{ | ||||
return XD3_INTERNAL; | ||||
} | ||||
if ((ret = check_vcdiff_header (stream, | ||||
TEST_DELTA_FILE, | ||||
"VCDIFF secondary compressor", | ||||
"lzma", | ||||
1))) | ||||
{ | ||||
return ret; | ||||
} | ||||
test_cleanup (); | ||||
return 0; | ||||
} | ||||
#endif /* SECONDARY_LZMA */ | ||||
#endif /* SHELL_TESTS */ | ||||
/*********************************************************************** | /*********************************************************************** | |||
EXTERNAL I/O DECOMPRESSION/RECOMPRESSION | EXTERNAL I/O DECOMPRESSION/RECOMPRESSION | |||
***********************************************************************/ | ***********************************************************************/ | |||
#if EXTERNAL_COMPRESSION | #if EXTERNAL_COMPRESSION | |||
/* This performs one step of the test_externally_compressed_io | /* This performs one step of the test_externally_compressed_io | |||
* function described below. It builds a pipe containing both Xdelta | * function described below. It builds a pipe containing both Xdelta | |||
* and external compression/decompression that should not modify the | * and external compression/decompression that should not modify the | |||
* data passing through. */ | * data passing through. */ | |||
skipping to change at line 2425 | skipping to change at line 2471 | |||
TEST_DELTA_FILE); | TEST_DELTA_FILE); | |||
if ((ret = do_cmd (stream, buf)) == 0) | if ((ret = do_cmd (stream, buf)) == 0) | |||
{ | { | |||
return XD3_INVALID; // Impossible | return XD3_INVALID; // Impossible | |||
} | } | |||
if (!WIFEXITED(ret)) | if (!WIFEXITED(ret)) | |||
{ | { | |||
return XD3_INVALID; // Must have crashed! | return XD3_INVALID; // Must have crashed! | |||
} | } | |||
test_cleanup (); | ||||
return 0; | return 0; | |||
} | } | |||
/*********************************************************************** | /*********************************************************************** | |||
Source identical optimization | Source identical optimization | |||
***********************************************************************/ | ***********************************************************************/ | |||
/* Computing a delta should be fastest when the two inputs are | /* Computing a delta should be fastest when the two inputs are | |||
* identical, this checks it. The library is called to compute a | * identical, this checks it. The library is called to compute a | |||
* delta between a 10000 byte file, 1000 byte winsize, 500 byte source | * delta between a 10000 byte file, 1000 byte winsize, 500 byte source | |||
skipping to change at line 2916 | skipping to change at line 2963 | |||
DO_TEST (no_output, 0, 0); | DO_TEST (no_output, 0, 0); | |||
DO_TEST (appheader, 0, 0); | DO_TEST (appheader, 0, 0); | |||
DO_TEST (command_line_arguments, 0, 0); | DO_TEST (command_line_arguments, 0, 0); | |||
#if EXTERNAL_COMPRESSION | #if EXTERNAL_COMPRESSION | |||
DO_TEST (source_decompression, 0, 0); | DO_TEST (source_decompression, 0, 0); | |||
DO_TEST (externally_compressed_io, 0, 0); | DO_TEST (externally_compressed_io, 0, 0); | |||
#endif | #endif | |||
DO_TEST (recode_command, 0, 0); | DO_TEST (recode_command, 0, 0); | |||
IF_LZMA (DO_TEST (secondary_lzma_default, 0, 0)); | ||||
#endif | #endif | |||
IF_LZMA (DO_TEST (secondary_lzma, 0, 1)); | IF_LZMA (DO_TEST (secondary_lzma, 0, 1)); | |||
IF_DJW (DO_TEST (secondary_huff, 0, DJW_MAX_GROUPS)); | IF_DJW (DO_TEST (secondary_huff, 0, DJW_MAX_GROUPS)); | |||
IF_FGK (DO_TEST (secondary_fgk, 0, 1)); | IF_FGK (DO_TEST (secondary_fgk, 0, 1)); | |||
DO_TEST (compressed_stream_overflow, 0, 0); | DO_TEST (compressed_stream_overflow, 0, 0); | |||
IF_LZMA (DO_TEST (compressed_stream_overflow, XD3_SEC_LZMA, 0)); | IF_LZMA (DO_TEST (compressed_stream_overflow, XD3_SEC_LZMA, 0)); | |||
failure: | failure: | |||
End of changes. 9 change blocks. | ||||
4 lines changed or deleted | 52 lines changed or added |