0

Diagnostics: Remove hardcoded kCpuStress

- Currently, the CPU stress routine is always passed to
   `OnStandardRoutineResult`. This change correctly reports the
   routine type when a routine fails to start.

Bug: 1227792
Change-Id: Ifa17d5722b5b415c26b57f3967de10993bd413cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3018424
Commit-Queue: Michael Checo <michaelcheco@google.com>
Commit-Queue: Zentaro Kavanagh <zentaro@chromium.org>
Auto-Submit: Michael Checo <michaelcheco@google.com>
Reviewed-by: Zentaro Kavanagh <zentaro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#900580}
This commit is contained in:
Michael Checo
2021-07-12 19:08:52 +00:00
committed by Chromium LUCI CQ
parent 4fac1e8186
commit 3878a300b5
2 changed files with 22 additions and 1 deletions

@ -312,7 +312,7 @@ void SystemRoutineController::OnRoutineStarted(
if (response_ptr->status ==
healthd::DiagnosticRoutineStatusEnum::kFailedToStart ||
response_ptr->id == healthd::kFailedToStartId) {
OnStandardRoutineResult(mojom::RoutineType::kCpuStress,
OnStandardRoutineResult(routine_type,
TestStatusToResult(response_ptr->status));
return;
}

@ -809,6 +809,27 @@ TEST_F(SystemRoutineControllerTest, RoutineResultEmitted) {
/*expected_count=*/1);
}
TEST_F(SystemRoutineControllerTest,
RoutineFailedToStartCalledWithCorrectRoutineType) {
SetRunRoutineResponse(healthd::kFailedToStartId,
healthd::DiagnosticRoutineStatusEnum::kFailedToStart);
base::HistogramTester histogram_tester;
FakeRoutineRunner routine_runner;
system_routine_controller_->RunRoutine(
mojom::RoutineType::kCpuCache,
routine_runner.receiver.BindNewPipeAndPassRemote());
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(routine_runner.result.is_null());
VerifyRoutineResult(*routine_runner.result, mojom::RoutineType::kCpuCache,
mojom::StandardRoutineResult::kUnableToRun);
histogram_tester.ExpectUniqueSample(
"ChromeOS.DiagnosticsUi.CpuCacheResult",
mojom::StandardRoutineResult::kUnableToRun,
/*expected_count=*/1);
}
TEST_F(SystemRoutineControllerTest, MemoryRuntimeEmitted) {
// Run the CpuStress routine.
SetRunRoutineResponse(/*id=*/1,