Fix autotest public API compilation for INTEGRITY

- getgid/getpwuid are not supported
- process should be used with config check

Task-number: QTBUG-96176
Pick-to: 6.2
Change-Id: Ib6854772bcf52f3533cb722f963426717926258b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Tatiana Borisova 2021-10-01 11:02:36 +03:00
parent 071ebc9eee
commit 144f3fe5a3
2 changed files with 12 additions and 4 deletions

View File

@ -45,7 +45,7 @@
#include <pwd.h> #include <pwd.h>
#endif #endif
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_ANDROID) #if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) && !defined(Q_OS_ANDROID)
#define Q_XDG_PLATFORM #define Q_XDG_PLATFORM
#endif #endif
@ -468,7 +468,9 @@ void tst_qstandardpaths::testRuntimeDirectory()
#endif #endif
} }
#ifdef Q_XDG_PLATFORM // INTEGRITY PJF System doesn't support user ID related APIs. getpwuid is not defined.
// testCustomRuntimeDirectory_data test will always FAIL for INTEGRITY.
#if defined(Q_XDG_PLATFORM) && !defined(Q_OS_INTEGRITY)
static QString fallbackXdgRuntimeDir() static QString fallbackXdgRuntimeDir()
{ {
static QString username = [] { static QString username = [] {
@ -491,7 +493,7 @@ static QString fallbackXdgRuntimeDir()
{ {
qunsetenv("XDG_RUNTIME_DIR"); qunsetenv("XDG_RUNTIME_DIR");
#ifdef Q_XDG_PLATFORM #ifdef Q_XDG_PLATFORM
#ifndef Q_OS_WASM #if !defined(Q_OS_WASM) && !defined(Q_OS_INTEGRITY)
QTest::ignoreMessage(QtWarningMsg, QTest::ignoreMessage(QtWarningMsg,
qPrintable("QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '" qPrintable("QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '"
+ fallbackXdgRuntimeDir() + '\'')); + fallbackXdgRuntimeDir() + '\''));
@ -501,7 +503,9 @@ static QString fallbackXdgRuntimeDir()
void tst_qstandardpaths::testCustomRuntimeDirectory_data() void tst_qstandardpaths::testCustomRuntimeDirectory_data()
{ {
#if defined(Q_XDG_PLATFORM) #ifdef Q_OS_INTEGRITY
QSKIP("Test requires getgid/getpwuid API that are not available on INTEGRITY");
#elif defined(Q_XDG_PLATFORM)
QTest::addColumn<RuntimeDirSetup>("setup"); QTest::addColumn<RuntimeDirSetup>("setup");
auto addRow = [](const char *name, RuntimeDirSetup f) { auto addRow = [](const char *name, RuntimeDirSetup f) {
QTest::newRow(name) << f; QTest::newRow(name) << f;

View File

@ -32,7 +32,9 @@
#include <QPainter> #include <QPainter>
#include <QPdfWriter> #include <QPdfWriter>
#include <QTemporaryFile> #include <QTemporaryFile>
#if QT_CONFIG(process)
#include <QProcess> #include <QProcess>
#endif
#ifndef QT_NO_OPENGL #ifndef QT_NO_OPENGL
#include <QOpenGLFramebufferObjectFormat> #include <QOpenGLFramebufferObjectFormat>
@ -421,6 +423,7 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co
rendered = fbo.toImage().convertToFormat(format); rendered = fbo.toImage().convertToFormat(format);
#endif #endif
} else if (engine == Pdf) { } else if (engine == Pdf) {
#if QT_CONFIG(process)
QString tempStem(QDir::tempPath() + QLatin1String("/lancelot_XXXXXX_") + qpsFile.chopped(4)); QString tempStem(QDir::tempPath() + QLatin1String("/lancelot_XXXXXX_") + qpsFile.chopped(4));
QTemporaryFile pdfFile(tempStem + QLatin1String(".pdf")); QTemporaryFile pdfFile(tempStem + QLatin1String(".pdf"));
@ -442,6 +445,7 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co
proc.waitForFinished(2 * 60 * 1000); // May need some time proc.waitForFinished(2 * 60 * 1000); // May need some time
rendered = QImage(pngFile.fileName()); rendered = QImage(pngFile.fileName());
#endif
} }
QBASELINE_TEST(rendered); QBASELINE_TEST(rendered);