Added tests for Sparse mode support
Fixed : complex cli arg case involving a mix of `stdin` and `-o`
This commit is contained in:
parent
75424d1139
commit
32990b5dae
@ -75,6 +75,33 @@ echo "echo foo | $ZSTD | $ZSTD -d > /dev/full"
|
||||
echo foo | $ZSTD | $ZSTD -d > /dev/full && die "write error not detected!"
|
||||
|
||||
|
||||
echo "\n**** test sparse file support **** "
|
||||
|
||||
./datagen -g5M -P100 > tmpSparse
|
||||
$ZSTD tmpSparse -c | $ZSTD -dv -o tmpSparseRegen
|
||||
diff -s tmpSparse tmpSparseRegen
|
||||
$ZSTD tmpSparse -c | $ZSTD -dv --sparse -c > tmpOutSparse
|
||||
diff -s tmpSparse tmpOutSparse
|
||||
$ZSTD tmpSparse -c | $ZSTD -dv --no-sparse -c > tmpOutNoSparse
|
||||
diff -s tmpSparse tmpOutNoSparse
|
||||
ls -ls tmpSparse*
|
||||
./datagen -s1 -g1200007 -P100 | $ZSTD | $ZSTD -dv --sparse -c > tmpSparseOdd # Odd size file (to not finish on an exact nb of blocks)
|
||||
./datagen -s1 -g1200007 -P100 | diff -s - tmpSparseOdd
|
||||
ls -ls tmpSparseOdd
|
||||
echo "\n Sparse Compatibility with Console :"
|
||||
echo "Hello World 1 !" | $ZSTD | $ZSTD -d -c
|
||||
echo "Hello World 2 !" | $ZSTD | $ZSTD -d | cat
|
||||
echo "\n Sparse Compatibility with Append :"
|
||||
./datagen -P100 -g1M > tmpSparse1M
|
||||
cat tmpSparse1M tmpSparse1M > tmpSparse2M
|
||||
$ZSTD -v -f tmpSparse1M -o tmpSparseCompressed
|
||||
$ZSTD -d -v -f tmpSparseCompressed -o tmpSparseRegenerated
|
||||
$ZSTD -d -v -f tmpSparseCompressed -c >> tmpSparseRegenerated
|
||||
ls -ls tmpSparse*
|
||||
diff tmpSparse2M tmpSparseRegenerated
|
||||
# rm tmpSparse*
|
||||
|
||||
|
||||
echo "\n**** dictionary tests **** "
|
||||
|
||||
./datagen > tmpDict
|
||||
|
@ -176,7 +176,7 @@ static void waitEnter(void)
|
||||
|
||||
int main(int argCount, const char** argv)
|
||||
{
|
||||
int i,
|
||||
int argNb,
|
||||
bench=0,
|
||||
decode=0,
|
||||
forceStdout=0,
|
||||
@ -203,18 +203,21 @@ int main(int argCount, const char** argv)
|
||||
(void)recursive; (void)cLevelLast; (void)dictCLevel; /* not used when ZSTD_NOBENCH / ZSTD_NODICT set */
|
||||
(void)decode; (void)cLevel; /* not used when ZSTD_NOCOMPRESS set */
|
||||
if (filenameTable==NULL) { DISPLAY("not enough memory\n"); exit(1); }
|
||||
filenameTable[0] = stdinmark;
|
||||
displayOut = stderr;
|
||||
/* Pick out program name from path. Don't rely on stdlib because of conflicting behavior */
|
||||
for (i = (int)strlen(programName); i > 0; i--) { if (programName[i] == '/') { i++; break; } }
|
||||
programName += i;
|
||||
{ size_t pos;
|
||||
for (pos = (int)strlen(programName); pos > 0; pos--) { if (programName[pos] == '/') { pos++; break; } }
|
||||
programName += pos;
|
||||
}
|
||||
|
||||
/* preset behaviors */
|
||||
if (!strcmp(programName, ZSTD_UNZSTD)) decode=1;
|
||||
if (!strcmp(programName, ZSTD_CAT)) { decode=1; forceStdout=1; displayLevel=1; outFileName=stdoutmark; }
|
||||
|
||||
/* command switches */
|
||||
for(i=1; i<argCount; i++) {
|
||||
const char* argument = argv[i];
|
||||
for(argNb=1; argNb<argCount; argNb++) {
|
||||
const char* argument = argv[argNb];
|
||||
if(!argument) continue; /* Protection if argument empty */
|
||||
|
||||
/* long commands (--long-word) */
|
||||
@ -414,7 +417,8 @@ int main(int argCount, const char** argv)
|
||||
}
|
||||
|
||||
/* No input filename ==> use stdin and stdout */
|
||||
if(!filenameIdx) filenameIdx=1, filenameTable[0]=stdinmark, outFileName=stdoutmark;
|
||||
filenameIdx += !filenameIdx; /*< default input is stdin */
|
||||
if (!strcmp(filenameTable[0], stdinmark) && !outFileName ) outFileName = stdoutmark; /*< when input is stdin, default output is stdout */
|
||||
|
||||
/* Check if input/output defined as console; trigger an error in this case */
|
||||
if (!strcmp(filenameTable[0], stdinmark) && IS_CONSOLE(stdin) ) CLEAN_RETURN(badusage(programName));
|
||||
@ -443,9 +447,9 @@ int main(int argCount, const char** argv)
|
||||
{ /* decompression */
|
||||
#ifndef ZSTD_NODECOMPRESS
|
||||
if (filenameIdx==1 && outFileName)
|
||||
operationResult = FIO_decompressFilename(outFileName, filenameTable[0], dictFileName);
|
||||
operationResult = FIO_decompressFilename(outFileName, filenameTable[0], dictFileName);
|
||||
else
|
||||
operationResult = FIO_decompressMultipleFilenames(filenameTable, filenameIdx, outFileName ? outFileName : ZSTD_EXTENSION, dictFileName);
|
||||
operationResult = FIO_decompressMultipleFilenames(filenameTable, filenameIdx, outFileName ? outFileName : ZSTD_EXTENSION, dictFileName);
|
||||
#else
|
||||
DISPLAY("Decompression not supported\n");
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user