Commit 4a8cd049 authored by Yusuke Sato's avatar Yusuke Sato Committed by Commit Bot

arcvm: Add more unittest to ArcVmClientAdapterTest

The new test verifies that StartMini() succeeds even when stopping
arcvm-server-proxy job fails.

BUG=None
TEST=try

Change-Id: Iadb8c421b31299cf904978b7e487599969a4c11b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2083406Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Yusuke Sato <yusukes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746210}
parent 2b949a8a
......@@ -155,7 +155,7 @@ class ArcVmClientAdapterTest : public testing::Test,
GetTestConciergeClient()->set_start_vm_response(start_vm_response);
// Reset to the original behavior.
RemoveUpstartStartJobFailure();
RemoveUpstartStartStopJobFailures();
}
void TearDown() override {
......@@ -270,10 +270,22 @@ class ArcVmClientAdapterTest : public testing::Test,
}));
}
void RemoveUpstartStartJobFailure() {
void InjectUpstartStopJobFailure(const std::string& job_name_to_fail) {
auto* upstart_client = chromeos::FakeUpstartClient::Get();
upstart_client->set_stop_job_cb(base::BindLambdaForTesting(
[job_name_to_fail](const std::string& job_name,
const std::vector<std::string>& env) {
// Return success unless |job_name| is |job_name_to_fail|.
return job_name != job_name_to_fail;
}));
}
void RemoveUpstartStartStopJobFailures() {
auto* upstart_client = chromeos::FakeUpstartClient::Get();
upstart_client->set_start_job_cb(
chromeos::FakeUpstartClient::StartStopJobCallback());
upstart_client->set_stop_job_cb(
chromeos::FakeUpstartClient::StartStopJobCallback());
}
void RecreateRunLoop() { run_loop_ = std::make_unique<base::RunLoop>(); }
......@@ -337,6 +349,17 @@ TEST_F(ArcVmClientAdapterTest, StartMiniArc) {
EXPECT_FALSE(GetTestConciergeClient()->start_arc_vm_called());
}
// Tests that StartMiniArc() still succeeds even when Upstart fails to stop
// the job.
TEST_F(ArcVmClientAdapterTest, StartMiniArc_StopJobFail) {
// Inject failure to FakeUpstartClient.
InjectUpstartStopJobFailure(kArcVmServerProxyJobName);
StartMiniArc();
// Confirm that no VM is started. ARCVM doesn't support mini ARC yet.
EXPECT_FALSE(GetTestConciergeClient()->start_arc_vm_called());
}
// Tests that StartMiniArc() fails when Upstart fails to start the job.
TEST_F(ArcVmClientAdapterTest, StartMiniArc_Fail) {
// Inject failure to FakeUpstartClient.
......
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