]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Update unit tests
authorsenhuang42 <senhuang96@fb.com>
Thu, 24 Sep 2020 20:44:33 +0000 (16:44 -0400)
committersenhuang42 <senhuang96@fb.com>
Thu, 24 Sep 2020 20:44:33 +0000 (16:44 -0400)
programs/fileio.c
tests/playTests.sh

index bfcb58c277944e6409374190e16c918480035be3..3ee3386778da5b40cbda9379eb58c095052d41e1 100644 (file)
@@ -542,7 +542,7 @@ void FIO_setNbFilesTotal(FIO_ctx_t* const fCtx, int value)
 }
 
 void FIO_determineHasStdinInput(FIO_ctx_t* const fCtx, const FileNamesTable* const filenames) {
-    int i = 0;
+    size_t i = 0;
     for ( ; i < filenames->tableSize; ++i) {
         if (!strcmp(stdinmark, filenames->fileNames[i])) {
             fCtx->hasStdinInput = 1;
index aee790da534f341df4859c0a075c312f94ca8655..e55b02f1f0b6dcbe4400ec2d434827921b3c0291 100755 (executable)
@@ -311,13 +311,19 @@ println "Test completed"
 
 
 
-println "\n===>  warning prompt does not swallow characters"
+println "\n===>  warning prompts should not occur if stdin is an input"
 println "y" > tmpPrompt
 println "hello world" >> tmpPrompt
-zstd tmpPrompt
-zstd < tmpPrompt -o tmpPrompt.zst
-zstd -q -d tmpPrompt.zst -o tmpPromptRegenerated
-$DIFF tmpPromptRegenerated tmpPrompt
+zstd tmpPrompt -f
+zstd < tmpPrompt -o tmpPrompt.zst && die "should have aborted immediately and failed to overwrite"
+zstd < tmpPrompt -o tmpPrompt.zst -f    # should successfully overwrite with -f
+zstd -q -d -f tmpPrompt.zst -o tmpPromptRegenerated
+$DIFF tmpPromptRegenerated tmpPrompt    # the first 'y' character should not be swallowed
+
+echo 'yes' | zstd tmpPrompt -o tmpPrompt.zst  # accept piped "y" input to force overwrite when using files
+echo 'yes' | zstd < tmpPrompt -o tmpPrompt.zst && die "should have aborted immediately and failed to overwrite"
+zstd tmpPrompt - < tmpPrompt -o tmpPromp.zst --rm && die "should have aborted immediately and failed to remove"
+
 println "Test completed"