summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <Cyan4973@users.noreply.github.com>2016-11-04 04:08:06 (GMT)
committerGitHub <noreply@github.com>2016-11-04 04:08:06 (GMT)
commit6d6a3e0fb582be4979404a5e8e368df8b891d686 (patch)
tree75c1e64bf9d21575ef0a65ffc81d2306ecc1689d
parent4c6610709e455f046bd0156828865ea7405580ea (diff)
parent136caa552bdc5657449e540b8becff826b80ade7 (diff)
downloadlz4-6d6a3e0fb582be4979404a5e8e368df8b891d686.zip
lz4-6d6a3e0fb582be4979404a5e8e368df8b891d686.tar.gz
lz4-6d6a3e0fb582be4979404a5e8e368df8b891d686.tar.bz2
Merge pull request #250 from terrelln/test-mode
Fix test mode and write to null
-rw-r--r--programs/lz4cli.c2
-rw-r--r--programs/lz4io.c12
-rw-r--r--programs/lz4io.h4
-rw-r--r--tests/Makefile5
4 files changed, 19 insertions, 4 deletions
diff --git a/programs/lz4cli.c b/programs/lz4cli.c
index 7cf035e..a6f4b4e 100644
--- a/programs/lz4cli.c
+++ b/programs/lz4cli.c
@@ -393,7 +393,7 @@ int main(int argc, const char** argv)
case 'c': forceStdout=1; output_filename=stdoutmark; displayLevel=1; break;
/* Test integrity */
- case 't': decode=1; LZ4IO_setOverwrite(1); output_filename=nulmark; break;
+ case 't': decode=1; LZ4IO_setTestMode(1); output_filename=nulmark; break;
/* Overwrite */
case 'f': LZ4IO_setOverwrite(1); break;
diff --git a/programs/lz4io.c b/programs/lz4io.c
index f2d7b51..2f64561 100644
--- a/programs/lz4io.c
+++ b/programs/lz4io.c
@@ -136,6 +136,7 @@ static clock_t g_time = 0;
* Local Parameters
**************************************/
static int g_overwrite = 1;
+static int g_testMode = 0;
static int g_blockSizeId = LZ4IO_BLOCKSIZEID_DEFAULT;
static int g_blockChecksum = 0;
static int g_streamChecksum = 1;
@@ -184,6 +185,13 @@ int LZ4IO_setOverwrite(int yes)
return g_overwrite;
}
+/* Default setting : testMode = 0; return : testMode (0/1) */
+int LZ4IO_setTestMode(int yes)
+{
+ g_testMode = (yes!=0);
+ return g_testMode;
+}
+
/* blockSizeID : valid values : 4-5-6-7 */
int LZ4IO_setBlockSizeID(int bsid)
{
@@ -283,7 +291,7 @@ static int LZ4IO_getFiles(const char* input_filename, const char* output_filenam
} else {
/* Check if destination file already exists */
*pfoutput=0;
- if (output_filename != nulmark) *pfoutput = fopen( output_filename, "rb" );
+ if (strcmp(output_filename, nulmark)) *pfoutput = fopen( output_filename, "rb" );
if (*pfoutput!=0) {
fclose(*pfoutput);
if (!g_overwrite) {
@@ -908,7 +916,7 @@ static unsigned long long selectDecoder(dRess_t ress, FILE* finput, FILE* foutpu
EXTENDED_FORMAT; /* macro extension for custom formats */
default:
if (nbCalls == 1) { /* just started */
- if (g_overwrite)
+ if (!g_testMode && g_overwrite)
return LZ4IO_passThrough(finput, foutput, MNstore);
EXM_THROW(44,"Unrecognized header : file cannot be decoded"); /* Wrong magic number at the beginning of 1st stream */
}
diff --git a/programs/lz4io.h b/programs/lz4io.h
index 4f0e02a..bf076ee 100644
--- a/programs/lz4io.h
+++ b/programs/lz4io.h
@@ -63,6 +63,10 @@ int LZ4IO_decompressMultipleFilenames(const char** inFileNamesTable, int ifntSiz
return : overwrite mode (0/1) */
int LZ4IO_setOverwrite(int yes);
+/* Default setting : testMode = 0;
+ return : testMode (0/1) */
+int LZ4IO_setTestMode(int yes);
+
/* blockSizeID : valid values : 4-5-6-7
return : -1 if error, blockSize if OK */
int LZ4IO_setBlockSizeID(int blockSizeID);
diff --git a/tests/Makefile b/tests/Makefile
index d7a195a..0c44b21 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -217,7 +217,10 @@ test-lz4-basic: lz4 datagen
test-lz4: lz4 datagen test-lz4-basic test-lz4-multiple test-lz4-sparse test-lz4-contentSize test-lz4-frame-concatenation
@echo "\n ---- test pass-through ----"
- ./datagen | $(PRGDIR)/lz4 -tf
+ ./datagen | $(PRGDIR)/lz4 -t && false || true
+ ./datagen | $(PRGDIR)/lz4 -tf && false || true
+ ./datagen | $(PRGDIR)/lz4 -d > $(VOID) && false || true
+ ./datagen | $(PRGDIR)/lz4 -df > $(VOID)
test-lz4c: lz4c datagen
@echo "\n ---- test lz4c version ----"