Skip to content

Commit 2a12bba

Browse files
committed
Update cli-tests/file-stat tests
1 parent 3bd5aa3 commit 2a12bba

7 files changed

+23
-3
lines changed

programs/fileio.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ FIO_openDstFile(FIO_ctx_t* fCtx, FIO_prefs_t* const prefs,
630630
}
631631

632632
{
633+
int isDstRegFile;
633634
#if defined(_WIN32)
634635
/* Windows requires opening the file as a "binary" file to avoid
635636
* mangling. This macro doesn't exist on unix. */
@@ -648,10 +649,11 @@ FIO_openDstFile(FIO_ctx_t* fCtx, FIO_prefs_t* const prefs,
648649
}
649650
#endif
650651

652+
/* Check regular file after opening with O_CREAT */
653+
isDstRegFile = UTIL_isFdRegularFile(fd);
651654
if (prefs->sparseFileSupport == 1) {
652655
prefs->sparseFileSupport = ZSTD_SPARSE_DEFAULT;
653-
/* Check regular file after opening with O_CREAT */
654-
if (!UTIL_isFdRegularFile(fd)) {
656+
if (!isDstRegFile) {
655657
prefs->sparseFileSupport = 0;
656658
DISPLAYLEVEL(4, "Sparse File Support is disabled when output is not a file \n");
657659
}

programs/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ int UTIL_isFdRegularFile(int fd)
202202
stat_t statbuf;
203203
int ret;
204204
UTIL_TRACE_CALL("UTIL_isFdRegularFile(%d)", fd);
205-
ret = UTIL_fstat(fd, "", &statbuf) && UTIL_isRegularFileStat(&statbuf);
205+
ret = fd >= 0 && UTIL_fstat(fd, "", &statbuf) && UTIL_isRegularFileStat(&statbuf);
206206
UTIL_TRACE_RET(ret);
207207
return ret;
208208
}

tests/cli-tests/file-stat/compress-file-to-dir-without-write-perm.sh.stderr.exact

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Trace:FileStat: > UTIL_isRegularFile(out/file.zst)
2222
Trace:FileStat: > UTIL_stat(-1, out/file.zst)
2323
Trace:FileStat: < 0
2424
Trace:FileStat: < 0
25+
Trace:FileStat: > UTIL_isFdRegularFile(-1)
26+
Trace:FileStat: < 0
2527
Trace:FileStat: > UTIL_isFileDescriptorPipe(out/file.zst)
2628
Trace:FileStat: < 0
2729
zstd: out/file.zst: Permission denied

tests/cli-tests/file-stat/compress-file-to-file.sh.stderr.exact renamed to tests/cli-tests/file-stat/compress-file-to-file.sh.stderr.glob

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Trace:FileStat: > UTIL_isRegularFile(file.zst)
2222
Trace:FileStat: > UTIL_stat(-1, file.zst)
2323
Trace:FileStat: < 0
2424
Trace:FileStat: < 0
25+
Trace:FileStat: > UTIL_isFdRegularFile(*)
26+
Trace:FileStat: > UTIL_stat(*, )
27+
Trace:FileStat: < 1
28+
Trace:FileStat: < 1
2529
Trace:FileStat: > UTIL_isRegularFile(file.zst)
2630
Trace:FileStat: > UTIL_stat(-1, file.zst)
2731
Trace:FileStat: < 1

tests/cli-tests/file-stat/compress-stdin-to-file.sh.stderr.exact renamed to tests/cli-tests/file-stat/compress-stdin-to-file.sh.stderr.glob

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Trace:FileStat: > UTIL_isRegularFile(file.zst)
1414
Trace:FileStat: > UTIL_stat(-1, file.zst)
1515
Trace:FileStat: < 0
1616
Trace:FileStat: < 0
17+
Trace:FileStat: > UTIL_isFdRegularFile(*)
18+
Trace:FileStat: > UTIL_stat(*, )
19+
Trace:FileStat: < 1
20+
Trace:FileStat: < 1
1721
Trace:FileStat: > UTIL_isRegularFile(file.zst)
1822
Trace:FileStat: > UTIL_stat(-1, file.zst)
1923
Trace:FileStat: < 1

tests/cli-tests/file-stat/decompress-file-to-file.sh.stderr.exact renamed to tests/cli-tests/file-stat/decompress-file-to-file.sh.stderr.glob

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Trace:FileStat: > UTIL_isRegularFile(file)
2222
Trace:FileStat: > UTIL_stat(-1, file)
2323
Trace:FileStat: < 0
2424
Trace:FileStat: < 0
25+
Trace:FileStat: > UTIL_isFdRegularFile(*)
26+
Trace:FileStat: > UTIL_stat(*, )
27+
Trace:FileStat: < 1
28+
Trace:FileStat: < 1
2529
Trace:FileStat: > UTIL_isRegularFile(file)
2630
Trace:FileStat: > UTIL_stat(-1, file)
2731
Trace:FileStat: < 1

tests/cli-tests/file-stat/decompress-stdin-to-file.sh.stderr.exact renamed to tests/cli-tests/file-stat/decompress-stdin-to-file.sh.stderr.glob

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Trace:FileStat: > UTIL_isRegularFile(file)
1414
Trace:FileStat: > UTIL_stat(-1, file)
1515
Trace:FileStat: < 0
1616
Trace:FileStat: < 0
17+
Trace:FileStat: > UTIL_isFdRegularFile(*)
18+
Trace:FileStat: > UTIL_stat(*, )
19+
Trace:FileStat: < 1
20+
Trace:FileStat: < 1
1721
Trace:FileStat: > UTIL_isRegularFile(file)
1822
Trace:FileStat: > UTIL_stat(-1, file)
1923
Trace:FileStat: < 1

0 commit comments

Comments
 (0)