Commit 03c2304b authored by Kartik Hegde's avatar Kartik Hegde Committed by Commit Bot

cros_healthd: Add GatewayCanBePinged routine

Add the GatewayCanBePinged routine to the ServiceConnection.

BUG=chromium:956783
TEST=1) chromeos_unittests --gtest_filter=CrosHealthdServiceConnectionTest.*
2) Applied GatewayCanBePinged changes and successfully ran the
GatewayCanBePinged routine on a DUT (verified using cros-health-tool diag
--action=run_routine --routine=gateway_can_be_pinged).

Change-Id: I942ead41313756f84a9b717809390809f6f331f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2344648Reviewed-by: default avatarPaul Moy <pmoy@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarOleh Lamzin <lamzin@google.com>
Commit-Queue: Kartik Hegde <khegde@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816787}
parent 1e01124f
...@@ -512,6 +512,15 @@ void DeviceCommandRunRoutineJob::RunImpl(CallbackWithResult succeeded_callback, ...@@ -512,6 +512,15 @@ void DeviceCommandRunRoutineJob::RunImpl(CallbackWithResult succeeded_callback,
std::move(failed_callback))); std::move(failed_callback)));
break; break;
} }
case chromeos::cros_healthd::mojom::DiagnosticRoutineEnum::
kGatewayCanBePinged: {
chromeos::cros_healthd::ServiceConnection::GetInstance()
->RunGatewayCanBePingedRoutine(base::BindOnce(
&DeviceCommandRunRoutineJob::OnCrosHealthdResponseReceived,
weak_ptr_factory_.GetWeakPtr(), std::move(succeeded_callback),
std::move(failed_callback)));
break;
}
} }
} }
......
...@@ -217,6 +217,11 @@ void FakeCrosHealthdService::RunSignalStrengthRoutine( ...@@ -217,6 +217,11 @@ void FakeCrosHealthdService::RunSignalStrengthRoutine(
std::move(callback).Run(run_routine_response_.Clone()); std::move(callback).Run(run_routine_response_.Clone());
} }
void FakeCrosHealthdService::RunGatewayCanBePingedRoutine(
RunGatewayCanBePingedRoutineCallback callback) {
std::move(callback).Run(run_routine_response_.Clone());
}
void FakeCrosHealthdService::AddBluetoothObserver( void FakeCrosHealthdService::AddBluetoothObserver(
mojom::CrosHealthdBluetoothObserverPtr observer) { mojom::CrosHealthdBluetoothObserverPtr observer) {
bluetooth_observers_.Add(observer.PassInterface()); bluetooth_observers_.Add(observer.PassInterface());
......
...@@ -102,6 +102,8 @@ class FakeCrosHealthdService final ...@@ -102,6 +102,8 @@ class FakeCrosHealthdService final
RunLanConnectivityRoutineCallback callback) override; RunLanConnectivityRoutineCallback callback) override;
void RunSignalStrengthRoutine( void RunSignalStrengthRoutine(
RunSignalStrengthRoutineCallback callback) override; RunSignalStrengthRoutineCallback callback) override;
void RunGatewayCanBePingedRoutine(
RunGatewayCanBePingedRoutineCallback callback) override;
// CrosHealthdEventService overrides: // CrosHealthdEventService overrides:
void AddBluetoothObserver( void AddBluetoothObserver(
......
...@@ -110,6 +110,9 @@ class ServiceConnectionImpl : public ServiceConnection { ...@@ -110,6 +110,9 @@ class ServiceConnectionImpl : public ServiceConnection {
void RunSignalStrengthRoutine( void RunSignalStrengthRoutine(
mojom::CrosHealthdDiagnosticsService::RunSignalStrengthRoutineCallback mojom::CrosHealthdDiagnosticsService::RunSignalStrengthRoutineCallback
callback) override; callback) override;
void RunGatewayCanBePingedRoutine(
mojom::CrosHealthdDiagnosticsService::RunGatewayCanBePingedRoutineCallback
callback) override;
void AddBluetoothObserver( void AddBluetoothObserver(
mojo::PendingRemote<mojom::CrosHealthdBluetoothObserver> pending_observer) mojo::PendingRemote<mojom::CrosHealthdBluetoothObserver> pending_observer)
override; override;
...@@ -377,6 +380,15 @@ void ServiceConnectionImpl::RunSignalStrengthRoutine( ...@@ -377,6 +380,15 @@ void ServiceConnectionImpl::RunSignalStrengthRoutine(
std::move(callback)); std::move(callback));
} }
void ServiceConnectionImpl::RunGatewayCanBePingedRoutine(
mojom::CrosHealthdDiagnosticsService::RunGatewayCanBePingedRoutineCallback
callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
BindCrosHealthdDiagnosticsServiceIfNeeded();
cros_healthd_diagnostics_service_->RunGatewayCanBePingedRoutine(
std::move(callback));
}
void ServiceConnectionImpl::AddBluetoothObserver( void ServiceConnectionImpl::AddBluetoothObserver(
mojo::PendingRemote<mojom::CrosHealthdBluetoothObserver> pending_observer) { mojo::PendingRemote<mojom::CrosHealthdBluetoothObserver> pending_observer) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......
...@@ -186,13 +186,20 @@ class ServiceConnection { ...@@ -186,13 +186,20 @@ class ServiceConnection {
mojom::CrosHealthdDiagnosticsService::RunLanConnectivityRoutineCallback mojom::CrosHealthdDiagnosticsService::RunLanConnectivityRoutineCallback
callback) = 0; callback) = 0;
// Requests that cros_healthd runs the lan connectivity routine. See // Requests that cros_healthd runs the signal strength routine. See
// src/chromeos/service/cros_healthd/public/mojom/cros_healthd.mojom for // src/chromeos/service/cros_healthd/public/mojom/cros_healthd.mojom for
// details. // details.
virtual void RunSignalStrengthRoutine( virtual void RunSignalStrengthRoutine(
mojom::CrosHealthdDiagnosticsService::RunSignalStrengthRoutineCallback mojom::CrosHealthdDiagnosticsService::RunSignalStrengthRoutineCallback
callback) = 0; callback) = 0;
// Requests that cros_healthd runs the gateway can be pinged routine. See
// src/chromeos/service/cros_healthd/public/mojom/cros_healthd.mojom for
// details.
virtual void RunGatewayCanBePingedRoutine(
mojom::CrosHealthdDiagnosticsService::RunGatewayCanBePingedRoutineCallback
callback) = 0;
// Subscribes to cros_healthd's Bluetooth-related events. See // Subscribes to cros_healthd's Bluetooth-related events. See
// src/chromeos/services/cros_healthd/public/mojom/cros_healthd.mojom for // src/chromeos/services/cros_healthd/public/mojom/cros_healthd.mojom for
// details. // details.
......
...@@ -536,8 +536,8 @@ TEST_F(CrosHealthdServiceConnectionTest, RunLanConnectivityRoutine) { ...@@ -536,8 +536,8 @@ TEST_F(CrosHealthdServiceConnectionTest, RunLanConnectivityRoutine) {
run_loop.Run(); run_loop.Run();
} }
// Test that we can run the signal strength routine.
TEST_F(CrosHealthdServiceConnectionTest, RunSignalStrengthRoutine) { TEST_F(CrosHealthdServiceConnectionTest, RunSignalStrengthRoutine) {
// Test that we can run the signal strength routine.
auto response = MakeRunRoutineResponse(); auto response = MakeRunRoutineResponse();
FakeCrosHealthdClient::Get()->SetRunRoutineResponseForTesting(response); FakeCrosHealthdClient::Get()->SetRunRoutineResponseForTesting(response);
base::RunLoop run_loop; base::RunLoop run_loop;
...@@ -549,6 +549,19 @@ TEST_F(CrosHealthdServiceConnectionTest, RunSignalStrengthRoutine) { ...@@ -549,6 +549,19 @@ TEST_F(CrosHealthdServiceConnectionTest, RunSignalStrengthRoutine) {
run_loop.Run(); run_loop.Run();
} }
// Test that we can run the gateway can be pinged routine.
TEST_F(CrosHealthdServiceConnectionTest, RunGatewayCanBePingedRoutine) {
auto response = MakeRunRoutineResponse();
FakeCrosHealthdClient::Get()->SetRunRoutineResponseForTesting(response);
base::RunLoop run_loop;
ServiceConnection::GetInstance()->RunGatewayCanBePingedRoutine(
base::BindLambdaForTesting([&](mojom::RunRoutineResponsePtr response) {
EXPECT_EQ(response, MakeRunRoutineResponse());
run_loop.Quit();
}));
run_loop.Run();
}
// Test that we can add a Bluetooth observer. // Test that we can add a Bluetooth observer.
TEST_F(CrosHealthdServiceConnectionTest, AddBluetoothObserver) { TEST_F(CrosHealthdServiceConnectionTest, AddBluetoothObserver) {
MockCrosHealthdBluetoothObserver observer; MockCrosHealthdBluetoothObserver observer;
......
...@@ -326,6 +326,16 @@ interface CrosHealthdDiagnosticsService { ...@@ -326,6 +326,16 @@ interface CrosHealthdDiagnosticsService {
// * |response| - contains a unique identifier and status for the created // * |response| - contains a unique identifier and status for the created
// routine. // routine.
RunSignalStrengthRoutine() => (RunRoutineResponse response); RunSignalStrengthRoutine() => (RunRoutineResponse response);
// Requests that the GatewayCanBePinged routine is created and started on the
// platform. This routine checks whether the gateway of connected networks is
// pingable. This routine is only available if GetAvailableRoutines returned
// kGatewayCanBePinged.
//
// The response:
// * |response| - contains a unique identifier and status for the created
// routine.
RunGatewayCanBePingedRoutine() => (RunRoutineResponse response);
}; };
// Event interface exposed by the cros_healthd daemon. // Event interface exposed by the cros_healthd daemon.
......
...@@ -33,6 +33,7 @@ enum DiagnosticRoutineEnum { ...@@ -33,6 +33,7 @@ enum DiagnosticRoutineEnum {
kMemory = 14, kMemory = 14,
kLanConnectivity = 15, kLanConnectivity = 15,
kSignalStrength = 16, kSignalStrength = 16,
kGatewayCanBePinged = 17,
}; };
// Enumeration of the possible DiskRead routine's command type // Enumeration of the possible DiskRead routine's command type
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment