1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
From 495ec99b000812b000e1960a3902e092751e7356 Mon Sep 17 00:00:00 2001
From: Marius Gripsgard <marius@slipper.no>
Date: Wed, 26 Nov 2025 14:46:21 +0100
Subject: [PATCH] tests: Make tests portable to other systems than gnu/linux
---
tests/libqtdbustest/TestDBusTestRunner.cpp | 24 +++++++++----------
.../libqtdbustest/TestQProcessDBusService.cpp | 14 +++++------
tests/libqtdbustest/TestSuicidalProcess.cpp | 4 ++--
3 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/tests/libqtdbustest/TestDBusTestRunner.cpp b/tests/libqtdbustest/TestDBusTestRunner.cpp
index 8719130..d776d30 100644
--- a/tests/libqtdbustest/TestDBusTestRunner.cpp
+++ b/tests/libqtdbustest/TestDBusTestRunner.cpp
@@ -44,7 +44,7 @@ protected:
TEST_F(TestDBusTestRunner, StartsSessionService) {
QSharedPointer<QProcessDBusService> process(
new QProcessDBusService("test.session.name",
- QDBusConnection::SessionBus, "/usr/bin/python3",
+ QDBusConnection::SessionBus, "python3",
QStringList() << "-m" << "dbusmock" << "test.session.name"
<< "/test/object" << "test.Interface"));
@@ -53,20 +53,20 @@ TEST_F(TestDBusTestRunner, StartsSessionService) {
QProcess pgrep;
pgrep.start("ps",
- QStringList() << "--no-headers" << "--pid"
- << QString::number(process->processId()) << "-o" << "args");
+ QStringList() << "-p"
+ << QString::number(process->processId()) << "-o" << "args=");
pgrep.waitForFinished();
pgrep.waitForReadyRead();
- EXPECT_EQ(
- "/usr/bin/python3 -m dbusmock test.session.name /test/object test.Interface",
- QString::fromUtf8(pgrep.readAll().trimmed()).toStdString());
+ EXPECT_THAT(
+ QString::fromUtf8(pgrep.readAll().trimmed()).toStdString(),
+ HasSubstr("python3 -m dbusmock test.session.name /test/object test.Interface"));
}
TEST_F(TestDBusTestRunner, StartsSystemService) {
QSharedPointer<QProcessDBusService> process(
new QProcessDBusService("test.system.name",
- QDBusConnection::SystemBus, "/usr/bin/python3",
+ QDBusConnection::SystemBus, "python3",
QStringList() << "-m" << "dbusmock" << "-s"
<< "test.system.name" << "/test/object"
<< "test.Interface"));
@@ -76,14 +76,14 @@ TEST_F(TestDBusTestRunner, StartsSystemService) {
QProcess pgrep;
pgrep.start("ps",
- QStringList() << "--no-headers" << "--pid"
- << QString::number(process->processId()) << "-o" << "args");
+ QStringList() << "-p"
+ << QString::number(process->processId()) << "-o" << "args=");
pgrep.waitForFinished();
pgrep.waitForReadyRead();
- EXPECT_EQ(
- "/usr/bin/python3 -m dbusmock -s test.system.name /test/object test.Interface",
- QString::fromUtf8(pgrep.readAll().trimmed()).toStdString());
+ EXPECT_THAT(
+ QString::fromUtf8(pgrep.readAll().trimmed()).toStdString(),
+ HasSubstr("python3 -m dbusmock -s test.system.name /test/object test.Interface"));
}
TEST_F(TestDBusTestRunner, SetsEnvironmentVariables) {
diff --git a/tests/libqtdbustest/TestQProcessDBusService.cpp b/tests/libqtdbustest/TestQProcessDBusService.cpp
index 8a91e59..8561693 100644
--- a/tests/libqtdbustest/TestQProcessDBusService.cpp
+++ b/tests/libqtdbustest/TestQProcessDBusService.cpp
@@ -45,7 +45,7 @@ protected:
TEST_F(TestQProcessDBusService, WaitsForServiceAppeared) {
QProcessDBusService process("test.name", QDBusConnection::SessionBus,
- "/usr/bin/python3",
+ "python3",
QStringList() << "-m" << "dbusmock" << "test.name" << "/test/object"
<< "test.Interface");
@@ -53,19 +53,19 @@ TEST_F(TestQProcessDBusService, WaitsForServiceAppeared) {
QProcess pgrep;
pgrep.start("ps",
- QStringList() << "--no-headers" << "--pid"
- << QString::number(process.processId()) << "-o" << "args");
+ QStringList() << "-p"
+ << QString::number(process.processId()) << "-o" << "args=");
pgrep.waitForFinished();
pgrep.waitForReadyRead();
- EXPECT_EQ(
- "/usr/bin/python3 -m dbusmock test.name /test/object test.Interface",
- QString::fromUtf8(pgrep.readAll().trimmed()).toStdString());
+ EXPECT_THAT(
+ QString::fromUtf8(pgrep.readAll().trimmed()).toStdString(),
+ HasSubstr("python3 -m dbusmock test.name /test/object test.Interface"));
}
TEST_F(TestQProcessDBusService, ThrowsErrorForFailToStart) {
QProcessDBusService process("test.name", QDBusConnection::SessionBus,
- "/usr/bin/python3",
+ "python3",
QStringList() << "-m" << "dbusmock" << "not.test.name"
<< "/test/object" << "test.Interface");
diff --git a/tests/libqtdbustest/TestSuicidalProcess.cpp b/tests/libqtdbustest/TestSuicidalProcess.cpp
index 1e4a67e..1653868 100644
--- a/tests/libqtdbustest/TestSuicidalProcess.cpp
+++ b/tests/libqtdbustest/TestSuicidalProcess.cpp
@@ -46,8 +46,8 @@ TEST_F(TestSuicidalProcess, BehavesLikeNormalQProcess) {
QProcess pgrep;
pgrep.start("ps",
- QStringList() << "--no-headers" << "--pid"
- << QString::number(process.processId()) << "-o" << "args");
+ QStringList() << "-p"
+ << QString::number(process.processId()) << "-o" << "args=");
pgrep.waitForFinished();
pgrep.waitForReadyRead();
--
2.51.0
|