mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-05 16:55:25 +08:00
6.5.3 clean
This commit is contained in:
@ -2614,6 +2614,7 @@ static void unixPipe_helper(int pipes[2])
|
||||
c = 2;
|
||||
qt_safe_write(fd, &c, 1);
|
||||
}));
|
||||
|
||||
thr->start();
|
||||
|
||||
// synchronize with the thread having started
|
||||
@ -2622,12 +2623,11 @@ static void unixPipe_helper(int pipes[2])
|
||||
QCOMPARE(c, '\1');
|
||||
|
||||
QFETCH(bool, useStdio);
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
QFile f;
|
||||
if (useStdio) {
|
||||
FILE *fh = fdopen(pipes[0], "rb");
|
||||
QVERIFY(f.open(fh, QIODevice::ReadOnly | QIODevice::Unbuffered, QFileDevice::AutoCloseHandle));
|
||||
pipes[0] = -1; // QFile fclose()s the FILE* and that close()s the fd
|
||||
} else {
|
||||
QVERIFY(f.open(pipes[0], QIODevice::ReadOnly | QIODevice::Unbuffered));
|
||||
}
|
||||
@ -2636,8 +2636,6 @@ static void unixPipe_helper(int pipes[2])
|
||||
c = 0;
|
||||
QCOMPARE(f.read(&c, 1), 1);
|
||||
QCOMPARE(c, '\2');
|
||||
int elapsed = timer.elapsed();
|
||||
QVERIFY2(elapsed >= Timeout, QByteArray::number(elapsed));
|
||||
|
||||
thr->wait();
|
||||
}
|
||||
@ -2654,7 +2652,8 @@ void tst_QFile::unixPipe()
|
||||
int pipes[2] = { -1, -1 };
|
||||
QVERIFY2(pipe(pipes) == 0, qPrintable(qt_error_string()));
|
||||
unixPipe_helper(pipes);
|
||||
qt_safe_close(pipes[0]);
|
||||
if (pipes[0] != -1)
|
||||
qt_safe_close(pipes[0]);
|
||||
qt_safe_close(pipes[1]);
|
||||
}
|
||||
|
||||
@ -2663,7 +2662,8 @@ void tst_QFile::socketPair()
|
||||
int pipes[2] = { -1, -1 };
|
||||
QVERIFY2(socketpair(AF_UNIX, SOCK_STREAM, 0, pipes) == 0, qPrintable(qt_error_string()));
|
||||
unixPipe_helper(pipes);
|
||||
qt_safe_close(pipes[0]);
|
||||
if (pipes[0] != -1)
|
||||
qt_safe_close(pipes[0]);
|
||||
qt_safe_close(pipes[1]);
|
||||
}
|
||||
#endif
|
||||
|
@ -2310,13 +2310,15 @@ void tst_QFileInfo::stdfilesystem()
|
||||
// We compare using absoluteFilePath since QFileInfo::operator== ends up using
|
||||
// canonicalFilePath which evaluates to empty-string for non-existent paths causing
|
||||
// these tests to always succeed.
|
||||
#define COMPARE_CONSTRUCTION(filepath) \
|
||||
QCOMPARE(QFileInfo(fs::path(filepath)).absoluteFilePath(), \
|
||||
QFileInfo(QString::fromLocal8Bit(filepath)).absoluteFilePath()); \
|
||||
QCOMPARE(QFileInfo(base, fs::path(filepath)).absoluteFilePath(), \
|
||||
QFileInfo(base, QString::fromLocal8Bit(filepath)).absoluteFilePath())
|
||||
|
||||
QDir base{ "../" }; // Used for the QFileInfo(QDir, <path>) ctor
|
||||
auto doCompare = [&base](const char *filepath) {
|
||||
QCOMPARE(QFileInfo(fs::path(filepath)).absoluteFilePath(),
|
||||
QFileInfo(QString::fromLocal8Bit(filepath)).absoluteFilePath());
|
||||
QCOMPARE(QFileInfo(base, fs::path(filepath)).absoluteFilePath(),
|
||||
QFileInfo(base, QString::fromLocal8Bit(filepath)).absoluteFilePath());
|
||||
};
|
||||
#define COMPARE_CONSTRUCTION(filepath) \
|
||||
doCompare(filepath); if (QTest::currentTestFailed()) return
|
||||
|
||||
COMPARE_CONSTRUCTION("./file");
|
||||
|
||||
@ -2329,7 +2331,10 @@ void tst_QFileInfo::stdfilesystem()
|
||||
COMPARE_CONSTRUCTION("/path/TO/file.txt");
|
||||
COMPARE_CONSTRUCTION("./path/TO/file.txt");
|
||||
COMPARE_CONSTRUCTION("../file.txt");
|
||||
#if !(defined(__GLIBCXX__) && defined(Q_OS_WIN32))
|
||||
// libstdc++ bug on Windows - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111244
|
||||
COMPARE_CONSTRUCTION("./filæ.txt");
|
||||
#endif
|
||||
|
||||
#undef COMPARE_CONSTRUCTION
|
||||
{
|
||||
|
@ -42,7 +42,6 @@ private slots:
|
||||
void getSetCheck();
|
||||
void constructing();
|
||||
void simpleStart();
|
||||
void setChildProcessModifier();
|
||||
void startCommand();
|
||||
void startWithOpen();
|
||||
void startWithOldOpen();
|
||||
@ -111,6 +110,9 @@ private slots:
|
||||
void nativeArguments();
|
||||
void createProcessArgumentsModifier();
|
||||
#endif // Q_OS_WIN
|
||||
#if defined(Q_OS_UNIX)
|
||||
void setChildProcessModifier();
|
||||
#endif
|
||||
void exitCodeTest();
|
||||
void systemEnvironment();
|
||||
void lockupsInStartDetached();
|
||||
@ -253,44 +255,6 @@ void tst_QProcess::simpleStart()
|
||||
QCOMPARE(qvariant_cast<QProcess::ProcessState>(spy.at(2).at(0)), QProcess::NotRunning);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
static const char messageFromChildProcess[] = "Message from the child process";
|
||||
static void childProcessModifier(int fd)
|
||||
{
|
||||
QT_WRITE(fd, messageFromChildProcess, sizeof(messageFromChildProcess) - 1);
|
||||
QT_CLOSE(fd);
|
||||
}
|
||||
#endif
|
||||
|
||||
void tst_QProcess::setChildProcessModifier()
|
||||
{
|
||||
#ifdef Q_OS_UNIX
|
||||
int pipes[2] = { -1 , -1 };
|
||||
QVERIFY(qt_safe_pipe(pipes) == 0);
|
||||
|
||||
QProcess process;
|
||||
process.setChildProcessModifier([pipes]() {
|
||||
::childProcessModifier(pipes[1]);
|
||||
});
|
||||
process.start("testProcessNormal/testProcessNormal");
|
||||
if (process.state() != QProcess::Starting)
|
||||
QCOMPARE(process.state(), QProcess::Running);
|
||||
QVERIFY2(process.waitForStarted(5000), qPrintable(process.errorString()));
|
||||
|
||||
char buf[sizeof messageFromChildProcess] = {};
|
||||
qt_safe_close(pipes[1]);
|
||||
QCOMPARE(qt_safe_read(pipes[0], buf, sizeof(buf)), qint64(sizeof(messageFromChildProcess)) - 1);
|
||||
QCOMPARE(buf, messageFromChildProcess);
|
||||
qt_safe_close(pipes[0]);
|
||||
|
||||
QVERIFY2(process.waitForFinished(5000), qPrintable(process.errorString()));
|
||||
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||
QCOMPARE(process.exitCode(), 0);
|
||||
#else
|
||||
QSKIP("Unix-only test");
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QProcess::startCommand()
|
||||
{
|
||||
QProcess process;
|
||||
@ -1472,6 +1436,41 @@ void tst_QProcess::createProcessArgumentsModifier()
|
||||
}
|
||||
#endif // Q_OS_WIN
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
static constexpr char messageFromChildProcess[] = "Message from the child process";
|
||||
static_assert(std::char_traits<char>::length(messageFromChildProcess) <= PIPE_BUF);
|
||||
static void childProcessModifier(int fd)
|
||||
{
|
||||
QT_WRITE(fd, messageFromChildProcess, strlen(messageFromChildProcess));
|
||||
QT_CLOSE(fd);
|
||||
}
|
||||
|
||||
void tst_QProcess::setChildProcessModifier()
|
||||
{
|
||||
int pipes[2] = { -1 , -1 };
|
||||
QVERIFY(qt_safe_pipe(pipes) == 0);
|
||||
|
||||
QProcess process;
|
||||
process.setChildProcessModifier([pipes]() {
|
||||
::childProcessModifier(pipes[1]);
|
||||
});
|
||||
process.start("testProcessNormal/testProcessNormal");
|
||||
if (process.state() != QProcess::Starting)
|
||||
QCOMPARE(process.state(), QProcess::Running);
|
||||
QVERIFY2(process.waitForStarted(5000), qPrintable(process.errorString()));
|
||||
|
||||
char buf[sizeof messageFromChildProcess] = {};
|
||||
qt_safe_close(pipes[1]);
|
||||
QCOMPARE(qt_safe_read(pipes[0], buf, sizeof(buf)), qint64(sizeof(messageFromChildProcess)) - 1);
|
||||
QCOMPARE(buf, messageFromChildProcess);
|
||||
qt_safe_close(pipes[0]);
|
||||
|
||||
QVERIFY2(process.waitForFinished(5000), qPrintable(process.errorString()));
|
||||
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||
QCOMPARE(process.exitCode(), 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
void tst_QProcess::exitCodeTest()
|
||||
{
|
||||
for (int i = 0; i < 255; ++i) {
|
||||
|
Reference in New Issue
Block a user