Skip command line generator tests when crosscompiling

We store the host protoc and generator paths from crosscompiling
environment when building generator tests. The test is supposed to
run on target meanwhile, which surely will lead to an issue if
paths to the tools on target platform differ. This particulary happens
on windows arm64 machine when we copy the cross-compiled tests.

Pick-to: 6.10 6.9 6.8
Change-Id: I85971da1b429383cae0f842306629355fc5833c6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2025-07-15 17:54:48 +02:00
parent 5167422dc6
commit c91d02c007
4 changed files with 38 additions and 11 deletions

View File

@ -24,6 +24,13 @@ qt_internal_add_test(tst_qtgrpcgen
BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}"
)
qt_internal_extend_target(tst_qtgrpcgen
CONDITION
CMAKE_CROSSCOMPILING
DEFINES
CROSSCOMPILING
)
qt_add_protobuf(tst_qtgrpcgen_protobuf_common
OUTPUT_DIRECTORY
"${CMAKE_CURRENT_BINARY_DIR}/${cmake_generated_dir}/protobuf_common"

View File

@ -5,7 +5,14 @@
#include <QtProtobuf/qtprotobuftypes.h>
#include <QtCore/qprocess.h>
#if !QT_CONFIG(process) || defined(CROSSCOMPILING)
# define SKIP_COMMAND_LINE_TESTS
#endif
#if !defined(SKIP_COMMAND_LINE_TESTS)
# include <QtCore/qprocess.h>
#endif
#include <QtCore/qstring.h>
#include "protocplugintestcommon.h"
@ -14,7 +21,7 @@ using namespace Qt::StringLiterals;
using namespace ProtocPluginTest;
namespace {
#if QT_CONFIG(process)
#if !defined(SKIP_COMMAND_LINE_TESTS)
# ifndef PROTOC_EXECUTABLE
# error PROTOC_EXECUTABLE definition must be set and point to the valid protoc executable
# endif
@ -61,7 +68,7 @@ private Q_SLOTS:
void cmakeGenerated_data();
void cmakeGenerated();
#if QT_CONFIG(process)
#if !defined(SKIP_COMMAND_LINE_TESTS)
//! Test command-line call of qtgrpcgen
void cmdLineGenerated_data();
void cmdLineGenerated();
@ -101,7 +108,7 @@ void qtgrpcgenTest::cmakeGenerated()
cmakeGeneratedPath() + '/'_L1 + testName + '/'_L1 + filePath);
}
#if QT_CONFIG(process)
#if !defined(SKIP_COMMAND_LINE_TESTS)
void qtgrpcgenTest::cmdLineGenerated_data()
{
QTest::addColumn<QString>("directory");

View File

@ -24,6 +24,14 @@ qt_internal_add_test(tst_qtprotobufgen
CMAKE_GENERATED_DIR="${cmake_generated_dir}"
BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}"
)
qt_internal_extend_target(tst_qtprotobufgen
CONDITION
CMAKE_CROSSCOMPILING
DEFINES
CROSSCOMPILING
)
qt_autogen_tools_initial_setup(tst_qtprotobufgen)
set(cmake_generator_tests "")

View File

@ -6,7 +6,12 @@
#include <QtProtobuf/qtprotobuftypes.h>
#include <QtCore/qdir.h>
#if QT_CONFIG(process)
#if !QT_CONFIG(process) || defined(CROSSCOMPILING)
# define SKIP_COMMAND_LINE_TESTS
#endif
#if !defined(SKIP_COMMAND_LINE_TESTS)
# include <QtCore/qprocess.h>
#endif
#include <QtCore/qstring.h>
@ -17,7 +22,7 @@ using namespace Qt::StringLiterals;
using namespace ProtocPluginTest;
namespace {
#if QT_CONFIG(process)
#if !defined(SKIP_COMMAND_LINE_TESTS)
# ifndef PROTOC_EXECUTABLE
# error PROTOC_EXECUTABLE definition must be set and point to the valid protoc executable
# endif
@ -40,7 +45,7 @@ constexpr QLatin1StringView allow_proto3_optional;
constexpr QLatin1StringView CmdLineGeneratedDir("cmd_line_generated");
#endif // QT_CONFIG(process)
#endif // !defined(SKIP_COMMAND_LINE_TESTS)
# ifndef BINARY_DIR
# error BINARY_DIR definition must be set
@ -68,7 +73,7 @@ private Q_SLOTS:
void cmakeGenerated_data();
void cmakeGenerated();
#if QT_CONFIG(process)
#if !defined(SKIP_COMMAND_LINE_TESTS)
//! Test command-line call of qtprotobufgen
void cmdLineGenerated_data();
void cmdLineGenerated();
@ -85,7 +90,7 @@ void qtprotobufgenTest::initTestCase()
{
initPaths(BinaryDir, CMakeGeneratedDir, CmdLineGeneratedDir);
QVERIFY(!cmakeGeneratedPath().isEmpty());
#if QT_CONFIG(process)
#if !defined(SKIP_COMMAND_LINE_TESTS)
QVERIFY(!cmdLineGeneratedPath().isEmpty());
#endif
QVERIFY(protocolCompilerAvailableToRun(ProtocPath));
@ -117,7 +122,7 @@ void qtprotobufgenTest::cmakeGenerated()
cmakeGeneratedPath() + '/'_L1 + testName + '/'_L1 + filePath);
}
#if QT_CONFIG(process)
#if !defined(SKIP_COMMAND_LINE_TESTS)
void qtprotobufgenTest::cmdLineGenerated_data()
{
QTest::addColumn<QString>("directory");
@ -293,7 +298,7 @@ void qtprotobufgenTest::cmdLineMutableGetterConflicts()
QVERIFY2(process.exitCode() == 1, msgProcessFailed(process).constData());
}
#endif // QT_CONFIG(process)
#endif // !defined(SKIP_COMMAND_LINE_TESTS)
void qtprotobufgenTest::cleanupTestCase()
{