Skip to contentSkip to conversation

tests: platforminfo: skip DBus test if hostname service isn't available

PATCH In review Frans Klaver 2 participants 3 messages Dec 1, 2022 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests: platforminfo: skip DBus test if hostname service isn't available

The dbus test is dependent on the org.freedesktop.hostname1 service being present. If that isn't there, we really can't determine whether or not the PlatformInfo code does what it's supposed to do.

So try to determine whether or not it makes sense to execute this test in the first place.

---
 src/tests/unit/platforminfo.cpp | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
src/tests/unit/platforminfo.cpp +14 -0
index 453de63..1460367 100644
@@ -45,6 +45,20 @@ TEST(PlatformInfo, DBus)
     }
 
     PlatformInfo plinfo(dbc.GetConnection());
+
+    try
+    {
+        plinfo.GetStringProperty("OperatingSystemCPEName");
+    }
+    catch (const DBusException& e)
+    {
+        const std::string what{e.what()};
+        if (what.find("was not provided by any") != std::string::npos)
+        {
+            GTEST_SKIP() << "A required service isn't available ## " + what;
+        }
+    }
+
     std::string s{plinfo.str()};
     ASSERT_TRUE(s.find("generic:") == std::string::npos)
         << "PlatformInfo D-Bus call failed";
Signature · 1 line
2.38.1
Acked-by on v1 1/1
#1 lore raw

From: David Sommerseth <[email protected]...>

Thanks a lot! This patch was a by the book in every possible way, so this was really easy to review and apply.

---------------------------------------------------------------------

Your patch has been applied

commit 1576e34a1f45133bd4c6df495eaef9387ecd1b4d master

Author: Frans Klaver
Date:   Thu, 01 Dec 2022 07:50:13 +0000

tests: platforminfo: skip DBus test if hostname service isn't available

Signed-off-by: Frans Klaver
Acked-by: David Sommerseth
Patchwork-Id: 2880
URL: https://patchwork.openvpn.net/patch/2880/

--
kind regards,

David Sommerseth

A message that is not in the archive (sent off-list or not yet received): 10afc77f.AWYAAAajRVMAAAAAAAAAASJvG10AAYCshBkAAAAAABXTlQBjiKGQ@...2677...