From b5cd988f066a732468faeff39eb4afc38cc3a45c Mon Sep 17 00:00:00 2001 From: Juha Vuolle Date: Fri, 16 Sep 2022 12:54:11 +0300 Subject: Fix failing BT LE autotest on CI & RHEL 9 It appears that with RHEL 9 on CI there is no bluez dbus. This means that the older kernel ATT interface is used instead. With that there is an error already at construction time if there is no local adapter available (QLowEnergyControllerPrivateBluez::init()) Fixes: QTBUG-106282 Change-Id: I8ecab26440a2b533c4d641c31d2345b46b95427e Reviewed-by: Ivan Solovev (cherry picked from commit 4371448c637f3059824cef22e1c98544cc0f45ed) Reviewed-by: Qt Cherry-pick Bot --- .../qlowenergycontroller/tst_qlowenergycontroller.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp index 0c7ec876..862568c4 100644 --- a/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp +++ b/tests/auto/qlowenergycontroller/tst_qlowenergycontroller.cpp @@ -209,7 +209,17 @@ void tst_QLowEnergyController::tst_emptyCtor() QSignalSpy connectedSpy(control.data(), SIGNAL(connected())); QSignalSpy stateSpy(control.data(), SIGNAL(stateChanged(QLowEnergyController::ControllerState))); QSignalSpy errorSpy(control.data(), SIGNAL(errorOccurred(QLowEnergyController::Error))); +#if QT_CONFIG(bluez) + QBluetoothLocalDevice localDevice; + // With bluez Kernel ATT interface we get the error already at construction time if the + // device does not have a bluetooth adapter + if (!isBluezDbusLE && !localDevice.isValid()) + QCOMPARE(control->error(), QLowEnergyController::InvalidBluetoothAdapterError); + else + QCOMPARE(control->error(), QLowEnergyController::NoError); +#else QCOMPARE(control->error(), QLowEnergyController::NoError); +#endif control->connectToDevice(); QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 10000); @@ -228,7 +238,15 @@ void tst_QLowEnergyController::tst_emptyCtor() QSignalSpy connectedSpy(control.data(), SIGNAL(connected())); QSignalSpy stateSpy(control.data(), SIGNAL(stateChanged(QLowEnergyController::ControllerState))); QSignalSpy errorSpy(control.data(), SIGNAL(errorOccurred(QLowEnergyController::Error))); +#if QT_CONFIG(bluez) + QBluetoothLocalDevice localDevice; + if (!isBluezDbusLE && !localDevice.isValid()) + QCOMPARE(control->error(), QLowEnergyController::InvalidBluetoothAdapterError); + else + QCOMPARE(control->error(), QLowEnergyController::NoError); +#else QCOMPARE(control->error(), QLowEnergyController::NoError); +#endif control->connectToDevice(); QTRY_VERIFY_WITH_TIMEOUT(!errorSpy.isEmpty(), 10000); -- cgit v1.2.1