Autotest: fix blacklisted test about position on non-regular files
On BSD systems (tested on macOS and FreeBSD), you *can* lseek(2) or ftell(3) on a pipe and get its current position. But QFile will not get the position when the file is sequential, so we need to return 0. Technically speaking, we ought to do the same for block devices, but if you're redirecting stdin, stdout or stderr in the unit test to or from a block device, you deserve the extra work to add that yourself to the test. Change-Id: I3868166e5efc45538544fffd14d8a74e92963fe7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
This commit is contained in:
parent
e94830f496
commit
5d2240718c
@ -5,7 +5,3 @@ msvc-2017 ci
|
||||
[readLineStdin_lineByLine]
|
||||
msvc-2015 ci
|
||||
msvc-2017 ci
|
||||
[openStandardStreamsFileDescriptors]
|
||||
osx
|
||||
[openStandardStreamsBufferedStreams]
|
||||
osx
|
||||
|
@ -3185,22 +3185,39 @@ static qint64 streamExpectedSize(int fd)
|
||||
QT_STATBUF sb;
|
||||
if (QT_FSTAT(fd, &sb) != -1)
|
||||
return sb.st_size;
|
||||
qErrnoWarning("Could not fstat fd %d", fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static qint64 streamCurrentPosition(int fd)
|
||||
{
|
||||
QT_OFF_T pos = QT_LSEEK(fd, 0, SEEK_CUR);
|
||||
if (pos != -1)
|
||||
return pos;
|
||||
QT_STATBUF sb;
|
||||
if (QT_FSTAT(fd, &sb) != -1) {
|
||||
QT_OFF_T pos = -1;
|
||||
if ((sb.st_mode & QT_STAT_MASK) == QT_STAT_REG)
|
||||
pos = QT_LSEEK(fd, 0, SEEK_CUR);
|
||||
if (pos != -1)
|
||||
return pos;
|
||||
// failure to lseek() is not a problem
|
||||
} else {
|
||||
qErrnoWarning("Could not fstat fd %d", fd);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static qint64 streamCurrentPosition(FILE *f)
|
||||
{
|
||||
QT_OFF_T pos = QT_FTELL(f);
|
||||
if (pos != -1)
|
||||
return pos;
|
||||
QT_STATBUF sb;
|
||||
if (QT_FSTAT(QT_FILENO(f), &sb) != -1) {
|
||||
QT_OFF_T pos = -1;
|
||||
if ((sb.st_mode & QT_STAT_MASK) == QT_STAT_REG)
|
||||
pos = QT_FTELL(f);
|
||||
if (pos != -1)
|
||||
return pos;
|
||||
// failure to ftell() is not a problem
|
||||
} else {
|
||||
qErrnoWarning("Could not fstat fd %d", QT_FILENO(f));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user