mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-04 16:25:27 +08:00
qt 6.5.1 original
This commit is contained in:
6
tests/auto/corelib/io/qprocess/BLACKLIST
Normal file
6
tests/auto/corelib/io/qprocess/BLACKLIST
Normal file
@ -0,0 +1,6 @@
|
||||
[lockupsInStartDetached]
|
||||
redhatenterpriselinuxworkstation-6.6
|
||||
# QTBUG-48455
|
||||
[fileWriterProcess]
|
||||
windows-10 msvc-2017
|
||||
|
30
tests/auto/corelib/io/qprocess/CMakeLists.txt
Normal file
30
tests/auto/corelib/io/qprocess/CMakeLists.txt
Normal file
@ -0,0 +1,30 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(testProcessCrash)
|
||||
add_subdirectory(testProcessEcho)
|
||||
add_subdirectory(testProcessEcho2)
|
||||
add_subdirectory(testProcessEcho3)
|
||||
add_subdirectory(testProcessEnvironment)
|
||||
add_subdirectory(testProcessHang)
|
||||
add_subdirectory(testProcessNormal)
|
||||
add_subdirectory(testProcessOutput)
|
||||
add_subdirectory(testProcessDeadWhileReading)
|
||||
add_subdirectory(testProcessEOF)
|
||||
add_subdirectory(testExitCodes)
|
||||
add_subdirectory(testForwarding)
|
||||
add_subdirectory(testForwardingHelper)
|
||||
if(TARGET Qt::Widgets)
|
||||
add_subdirectory(testGuiProcess)
|
||||
endif()
|
||||
add_subdirectory(testDetached)
|
||||
add_subdirectory(fileWriterProcess)
|
||||
add_subdirectory(testSetWorkingDirectory)
|
||||
add_subdirectory(testSoftExit)
|
||||
add_subdirectory(testProcessSpacesArgs)
|
||||
add_subdirectory(testSpaceInName)
|
||||
if(WIN32)
|
||||
add_subdirectory(testProcessEchoGui)
|
||||
add_subdirectory(testSetNamedPipeHandleState)
|
||||
endif()
|
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## fileWriterProcess Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(fileWriterProcess
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
28
tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp
Normal file
28
tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#include <QCoreApplication>
|
||||
#include <QFile>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication ca(argc, argv);
|
||||
QFile f;
|
||||
f.open(stdin, QIODevice::ReadOnly);
|
||||
QByteArray input;
|
||||
char buf[1024];
|
||||
qint64 len;
|
||||
while ((len = f.read(buf, 1024)) > 0)
|
||||
input.append(buf, len);
|
||||
f.close();
|
||||
QFile f2("fileWriterProcess.txt");
|
||||
if (!f2.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
fprintf(stderr, "Cannot open %s for writing: %s\n",
|
||||
qPrintable(f2.fileName()), qPrintable(f2.errorString()));
|
||||
return 1;
|
||||
}
|
||||
f2.write(input);
|
||||
f2.close();
|
||||
return 0;
|
||||
}
|
44
tests/auto/corelib/io/qprocess/test/CMakeLists.txt
Normal file
44
tests/auto/corelib/io/qprocess/test/CMakeLists.txt
Normal file
@ -0,0 +1,44 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## tst_qprocess Test:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_test(tst_qprocess
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../"
|
||||
SOURCES
|
||||
../tst_qprocess.cpp
|
||||
LIBRARIES
|
||||
Qt::CorePrivate
|
||||
Qt::Network
|
||||
Qt::TestPrivate
|
||||
)
|
||||
|
||||
## Build assorted sub-programs called from the test:
|
||||
add_dependencies(tst_qprocess
|
||||
testProcessCrash
|
||||
testProcessEcho
|
||||
testProcessEcho2
|
||||
testProcessEcho3
|
||||
testProcessEnvironment
|
||||
testProcessHang
|
||||
testProcessNormal
|
||||
testProcessOutput
|
||||
testProcessDeadWhileReading
|
||||
testProcessEOF
|
||||
testExitCodes
|
||||
testForwarding
|
||||
testDetached
|
||||
fileWriterProcess
|
||||
testSetWorkingDirectory
|
||||
testSoftExit
|
||||
nospace onespace twospaces
|
||||
testSpaceInName
|
||||
)
|
||||
if(TARGET Qt::Widgets)
|
||||
add_dependencies(tst_qprocess testGuiProcess)
|
||||
endif()
|
||||
if(WIN32)
|
||||
add_dependencies(tst_qprocess testProcessEchoGui testSetNamedPipeHandleState)
|
||||
endif()
|
2
tests/auto/corelib/io/qprocess/testBatFiles/simple.bat
Normal file
2
tests/auto/corelib/io/qprocess/testBatFiles/simple.bat
Normal file
@ -0,0 +1,2 @@
|
||||
@echo off
|
||||
echo Hello
|
@ -0,0 +1,2 @@
|
||||
@echo off
|
||||
echo Hello
|
12
tests/auto/corelib/io/qprocess/testDetached/CMakeLists.txt
Normal file
12
tests/auto/corelib/io/qprocess/testDetached/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testDetached Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testDetached
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
104
tests/auto/corelib/io/qprocess/testDetached/main.cpp
Normal file
104
tests/auto/corelib/io/qprocess/testDetached/main.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(Q_OS_UNIX)
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#elif defined(Q_OS_WIN)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
static void writeStuff(QFile &f)
|
||||
{
|
||||
f.write(QDir::currentPath().toUtf8());
|
||||
f.putChar('\n');
|
||||
#if defined(Q_OS_UNIX)
|
||||
f.write(QByteArray::number(quint64(getpid())));
|
||||
#elif defined(Q_OS_WIN)
|
||||
f.write(QByteArray::number(quint64(GetCurrentProcessId())));
|
||||
#endif
|
||||
f.putChar('\n');
|
||||
f.write(qgetenv("tst_QProcess"));
|
||||
f.putChar('\n');
|
||||
}
|
||||
|
||||
struct Args
|
||||
{
|
||||
int exitCode = 0;
|
||||
QByteArray errorMessage;
|
||||
QString fileName;
|
||||
FILE *channel = nullptr;
|
||||
QByteArray channelName;
|
||||
};
|
||||
|
||||
static Args parseArguments(const QStringList &args)
|
||||
{
|
||||
Args result;
|
||||
if (args.size() < 2) {
|
||||
result.exitCode = 128;
|
||||
result.errorMessage = "Usage: testDetached [--out-channel={stdout|stderr}] filename.txt\n";
|
||||
return result;
|
||||
}
|
||||
for (const QString &arg : args) {
|
||||
if (arg.startsWith("--")) {
|
||||
if (!arg.startsWith("--out-channel=")) {
|
||||
result.exitCode = 2;
|
||||
result.errorMessage = "Unknown argument " + arg.toLocal8Bit();
|
||||
return result;
|
||||
}
|
||||
result.channelName = arg.mid(14).toLocal8Bit();
|
||||
if (result.channelName == "stdout") {
|
||||
result.channel = stdout;
|
||||
} else if (result.channelName == "stderr") {
|
||||
result.channel = stderr;
|
||||
} else {
|
||||
result.exitCode = 3;
|
||||
result.errorMessage = "Unknown channel " + result.channelName;
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
result.fileName = arg;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
const Args args = parseArguments(app.arguments());
|
||||
if (args.exitCode) {
|
||||
fprintf(stderr, "testDetached: %s\n", args.errorMessage.constData());
|
||||
return args.exitCode;
|
||||
}
|
||||
|
||||
if (args.channel) {
|
||||
QFile channel;
|
||||
if (!channel.open(args.channel, QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
fprintf(stderr, "Cannot open channel %s for writing: %s\n",
|
||||
qPrintable(args.channelName), qPrintable(channel.errorString()));
|
||||
return 4;
|
||||
}
|
||||
writeStuff(channel);
|
||||
}
|
||||
|
||||
QFile f(args.fileName);
|
||||
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
|
||||
fprintf(stderr, "Cannot open %s for writing: %s\n",
|
||||
qPrintable(f.fileName()), qPrintable(f.errorString()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
writeStuff(f);
|
||||
f.close();
|
||||
|
||||
return 0;
|
||||
}
|
12
tests/auto/corelib/io/qprocess/testExitCodes/CMakeLists.txt
Normal file
12
tests/auto/corelib/io/qprocess/testExitCodes/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testExitCodes Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testExitCodes
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
10
tests/auto/corelib/io/qprocess/testExitCodes/main.cpp
Normal file
10
tests/auto/corelib/io/qprocess/testExitCodes/main.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return argc >= 2 ? atoi(argv[1]) : -1;
|
||||
}
|
||||
|
14
tests/auto/corelib/io/qprocess/testForwarding/CMakeLists.txt
Normal file
14
tests/auto/corelib/io/qprocess/testForwarding/CMakeLists.txt
Normal file
@ -0,0 +1,14 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testForwarding Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testForwarding
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
||||
|
||||
add_dependencies(testForwarding testForwardingHelper)
|
78
tests/auto/corelib/io/qprocess/testForwarding/main.cpp
Normal file
78
tests/auto/corelib/io/qprocess/testForwarding/main.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDeadlineTimer>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtCore/QTemporaryFile>
|
||||
#include <QtCore/QThread>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
static bool waitForDoneFileWritten(const QString &filePath, int msecs = 30000)
|
||||
{
|
||||
QDeadlineTimer t(msecs);
|
||||
do {
|
||||
QThread::msleep(250);
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
continue;
|
||||
if (file.readAll() == "That's all folks!")
|
||||
return true;
|
||||
} while (!t.hasExpired());
|
||||
return false;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
if (argc < 4)
|
||||
return 13;
|
||||
|
||||
QProcess process;
|
||||
|
||||
QProcess::ProcessChannelMode mode = (QProcess::ProcessChannelMode)atoi(argv[1]);
|
||||
process.setProcessChannelMode(mode);
|
||||
if (process.processChannelMode() != mode)
|
||||
return 1;
|
||||
|
||||
QProcess::InputChannelMode inmode = (QProcess::InputChannelMode)atoi(argv[2]);
|
||||
process.setInputChannelMode(inmode);
|
||||
if (process.inputChannelMode() != inmode)
|
||||
return 11;
|
||||
|
||||
if (atoi(argv[3])) {
|
||||
QTemporaryFile doneFile("testForwarding_XXXXXX.txt");
|
||||
if (!doneFile.open())
|
||||
return 12;
|
||||
doneFile.close();
|
||||
|
||||
process.setProgram("testForwardingHelper/testForwardingHelper");
|
||||
process.setArguments(QStringList(doneFile.fileName()));
|
||||
if (!process.startDetached())
|
||||
return 13;
|
||||
if (!waitForDoneFileWritten(doneFile.fileName()))
|
||||
return 14;
|
||||
} else {
|
||||
process.start("testProcessEcho2/testProcessEcho2");
|
||||
|
||||
if (!process.waitForStarted(5000))
|
||||
return 2;
|
||||
|
||||
if (inmode == QProcess::ManagedInputChannel && process.write("forwarded") != 9)
|
||||
return 3;
|
||||
|
||||
process.closeWriteChannel();
|
||||
if (!process.waitForFinished(5000))
|
||||
return 4;
|
||||
|
||||
if ((mode == QProcess::ForwardedOutputChannel || mode == QProcess::ForwardedChannels)
|
||||
&& !process.readAllStandardOutput().isEmpty())
|
||||
return 5;
|
||||
if ((mode == QProcess::ForwardedErrorChannel || mode == QProcess::ForwardedChannels)
|
||||
&& !process.readAllStandardError().isEmpty())
|
||||
return 6;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testForwardingHelper Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testForwardingHelper
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
20
tests/auto/corelib/io/qprocess/testForwardingHelper/main.cpp
Normal file
20
tests/auto/corelib/io/qprocess/testForwardingHelper/main.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2018 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <fstream>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 2) {
|
||||
puts("Usage: testForwardingHelper <doneFilePath>");
|
||||
return 1;
|
||||
}
|
||||
fputs("out data", stdout);
|
||||
fflush(stdout);
|
||||
fputs("err data", stderr);
|
||||
fflush(stderr);
|
||||
std::ofstream out(argv[1]);
|
||||
out << "That's all folks!";
|
||||
return 0;
|
||||
}
|
15
tests/auto/corelib/io/qprocess/testGuiProcess/CMakeLists.txt
Normal file
15
tests/auto/corelib/io/qprocess/testGuiProcess/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testGuiProcess Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testGuiProcess
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
)
|
21
tests/auto/corelib/io/qprocess/testGuiProcess/main.cpp
Normal file
21
tests/auto/corelib/io/qprocess/testGuiProcess/main.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QLabel label("This process is just waiting to die");
|
||||
label.show();
|
||||
|
||||
int c;
|
||||
Q_UNUSED(c);
|
||||
fgetc(stdin); // block until fed
|
||||
|
||||
qDebug("Process is running");
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testProcessCrash Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testProcessCrash
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
50
tests/auto/corelib/io/qprocess/testProcessCrash/main.cpp
Normal file
50
tests/auto/corelib/io/qprocess/testProcessCrash/main.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// Copyright (C) 2020 Intel Corporation.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#if __has_include(<sys/resource.h>)
|
||||
# include <sys/resource.h>
|
||||
# if defined(RLIMIT_CORE)
|
||||
static bool disableCoreDumps()
|
||||
{
|
||||
// Unix: set our core dump limit to zero to request no dialogs.
|
||||
if (struct rlimit rlim; getrlimit(RLIMIT_CORE, &rlim) == 0) {
|
||||
rlim.rlim_cur = 0;
|
||||
setrlimit(RLIMIT_CORE, &rlim);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static bool disabledCoreDumps = disableCoreDumps();
|
||||
# endif // RLIMIT_CORE
|
||||
#endif // <sys/resource.h>
|
||||
|
||||
void crashFallback(volatile int *ptr = nullptr)
|
||||
{
|
||||
*ptr = 0;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# include <intrin.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
# if defined(_M_IX86) || defined(_M_X64)
|
||||
__ud2();
|
||||
# endif
|
||||
|
||||
crashFallback();
|
||||
}
|
||||
#elif defined(__MINGW32__)
|
||||
int main()
|
||||
{
|
||||
asm("ud2");
|
||||
crashFallback();
|
||||
}
|
||||
#else
|
||||
# include <stdlib.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
abort();
|
||||
}
|
||||
#endif
|
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testProcessDeadWhileReading Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testProcessDeadWhileReading
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
for (int i=0; i<10240; i++)
|
||||
fprintf(stdout, "%d dead while reading\n", i);
|
||||
fflush(stdout);
|
||||
|
||||
return 0;
|
||||
}
|
12
tests/auto/corelib/io/qprocess/testProcessEOF/CMakeLists.txt
Normal file
12
tests/auto/corelib/io/qprocess/testProcessEOF/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testProcessEOF Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testProcessEOF
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
20
tests/auto/corelib/io/qprocess/testProcessEOF/main.cpp
Normal file
20
tests/auto/corelib/io/qprocess/testProcessEOF/main.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
char buf[32];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
char *cptr = buf;
|
||||
int c;
|
||||
while (cptr != buf + 31 && (c = fgetc(stdin)) != EOF)
|
||||
*cptr++ = (char) c;
|
||||
|
||||
printf("%s", buf);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testProcessEcho Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testProcessEcho
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
17
tests/auto/corelib/io/qprocess/testProcessEcho/main.cpp
Normal file
17
tests/auto/corelib/io/qprocess/testProcessEcho/main.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int c;
|
||||
while ((c = fgetc(stdin)) != -1) {
|
||||
if (c == '\0')
|
||||
break;
|
||||
fputc(c, stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testProcessEcho2 Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testProcessEcho2
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
20
tests/auto/corelib/io/qprocess/testProcessEcho2/main.cpp
Normal file
20
tests/auto/corelib/io/qprocess/testProcessEcho2/main.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int c;
|
||||
while ((c = fgetc(stdin)) != -1) {
|
||||
if (c == '\0')
|
||||
break;
|
||||
fputc(c, stdout);
|
||||
fputc(c, stderr);
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testProcessEcho3 Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testProcessEcho3
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
23
tests/auto/corelib/io/qprocess/testProcessEcho3/main.cpp
Normal file
23
tests/auto/corelib/io/qprocess/testProcessEcho3/main.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int c;
|
||||
for (;;) {
|
||||
c = fgetc(stdin);
|
||||
if (c == '\0')
|
||||
break;
|
||||
if (c != -1) {
|
||||
fputc(c, stdout);
|
||||
fputc(c, stderr);
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testProcessEchoGui Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testProcessEchoGui
|
||||
GUI
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main_win.cpp
|
||||
)
|
||||
target_link_libraries(testProcessEchoGui PRIVATE user32)
|
@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE /* hInstance */,
|
||||
HINSTANCE /* hPrevInstance */,
|
||||
LPSTR /* lpCmdLine */,
|
||||
int /* nCmdShow */)
|
||||
{
|
||||
|
||||
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
|
||||
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
HANDLE hStderr = GetStdHandle(STD_ERROR_HANDLE);
|
||||
|
||||
for (;;) {
|
||||
|
||||
char c = 0;
|
||||
DWORD read = 0;
|
||||
if (!ReadFile(hStdin, &c, 1, &read, 0) || read == 0 || c == 'q' || c == '\0')
|
||||
break;
|
||||
DWORD wrote = 0;
|
||||
WriteFile(hStdout, &c, 1, &wrote, 0);
|
||||
WriteFile(hStderr, &c, 1, &wrote, 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testProcessEnvironment Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testProcessEnvironment
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
@ -0,0 +1,18 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc == 1)
|
||||
return 1;
|
||||
|
||||
char *env = getenv(argv[1]);
|
||||
if (env) {
|
||||
printf("%s", env);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testProcessHang Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testProcessHang
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
32
tests/auto/corelib/io/qprocess/testProcessHang/main.cpp
Normal file
32
tests/auto/corelib/io/qprocess/testProcessHang/main.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright (C) 2016 Intel Corporation.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
|
||||
# include <windows.h>
|
||||
|
||||
void sleepForever()
|
||||
{
|
||||
::Sleep(INFINITE);
|
||||
}
|
||||
#else
|
||||
# include <unistd.h>
|
||||
|
||||
void sleepForever()
|
||||
{
|
||||
::pause();
|
||||
}
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
puts("ready.");
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "ready.\n");
|
||||
fflush(stderr);
|
||||
|
||||
// sleep forever, simulating a hung application
|
||||
sleepForever();
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testProcessNormal Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testProcessNormal
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
@ -0,0 +1,8 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testProcessOutput Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testProcessOutput
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
14
tests/auto/corelib/io/qprocess/testProcessOutput/main.cpp
Normal file
14
tests/auto/corelib/io/qprocess/testProcessOutput/main.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
for (int i=0; i<10240; i++) {
|
||||
fprintf(stdout, "%d -this is a number\n", i);
|
||||
fflush(stderr);
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
qt_internal_add_executable(nospace
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt_internal_add_executable(onespace
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
||||
set_target_properties(onespace PROPERTIES OUTPUT_NAME "one space")
|
||||
|
||||
qt_internal_add_executable(twospaces
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
||||
set_target_properties(twospaces PROPERTIES OUTPUT_NAME "two space s")
|
@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
if (i)
|
||||
printf("|");
|
||||
printf("%s", argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testSetNamedPipeHandleState Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testSetNamedPipeHandleState
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
||||
target_link_libraries(testSetNamedPipeHandleState PRIVATE kernel32.lib)
|
@ -0,0 +1,12 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
DWORD mode = PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT;
|
||||
if (SetNamedPipeHandleState(GetStdHandle(STD_INPUT_HANDLE), &mode, NULL, NULL))
|
||||
return 0;
|
||||
return GetLastError();
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testSetWorkingDirectory Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testSetWorkingDirectory
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QByteArray>
|
||||
#include <QDir>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
QByteArray currentPath = QDir::currentPath().toLocal8Bit();
|
||||
fprintf(stdout, "%s", currentPath.constData());
|
||||
app.exit();
|
||||
}
|
22
tests/auto/corelib/io/qprocess/testSoftExit/CMakeLists.txt
Normal file
22
tests/auto/corelib/io/qprocess/testSoftExit/CMakeLists.txt
Normal file
@ -0,0 +1,22 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testSoftExit Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testSoftExit
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
)
|
||||
|
||||
qt_internal_extend_target(testSoftExit CONDITION WIN32
|
||||
SOURCES
|
||||
main_win.cpp
|
||||
LIBRARIES
|
||||
user32
|
||||
)
|
||||
|
||||
qt_internal_extend_target(testSoftExit CONDITION UNIX
|
||||
SOURCES
|
||||
main_unix.cpp
|
||||
)
|
24
tests/auto/corelib/io/qprocess/testSoftExit/main_unix.cpp
Normal file
24
tests/auto/corelib/io/qprocess/testSoftExit/main_unix.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
struct sigaction noaction;
|
||||
memset(&noaction, 0, sizeof(noaction));
|
||||
noaction.sa_handler = SIG_IGN;
|
||||
::sigaction(SIGTERM, &noaction, 0);
|
||||
|
||||
printf("Ready\n");
|
||||
fflush(stdout);
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
sleep(1);
|
||||
return 0;
|
||||
}
|
20
tests/auto/corelib/io/qprocess/testSoftExit/main_win.cpp
Normal file
20
tests/auto/corelib/io/qprocess/testSoftExit/main_win.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Ready\n");
|
||||
fflush(stdout);
|
||||
|
||||
MSG msg;
|
||||
while (GetMessage(&msg, NULL, 0, 0)) {
|
||||
if (msg.message == WM_CLOSE)
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
|
||||
return int(msg.wParam);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## testSpaceInName Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(testSpaceInName
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
||||
set_property(TARGET testSpaceInName PROPERTY
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../test Space In Name")
|
18
tests/auto/corelib/io/qprocess/testSpaceInName/main.cpp
Normal file
18
tests/auto/corelib/io/qprocess/testSpaceInName/main.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int c;
|
||||
while ((c = fgetc(stdin)) != -1) {
|
||||
if (c == '\0')
|
||||
break;
|
||||
fputc(c, stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
2610
tests/auto/corelib/io/qprocess/tst_qprocess.cpp
Normal file
2610
tests/auto/corelib/io/qprocess/tst_qprocess.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user