Skip to content

Commit 7533fa2

Browse files
committed
Add a powerwash e2etest
Bug: b/360440269 Test: cd e2etests && bazel test cvd/cvd_powerwash_tests/...
1 parent 637afa6 commit 7533fa2

File tree

3 files changed

+122
-0
lines changed

3 files changed

+122
-0
lines changed

e2etests/cvd/common/common.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,21 @@ func (tc *TestContext) StopCVD() error {
252252
return nil
253253
}
254254

255+
// Performs `cvd powerwash`.
256+
func (tc *TestContext) CVDPowerwash() error {
257+
tempdirEnv := map[string]string{
258+
"HOME": tc.tempdir,
259+
}
260+
261+
createCmd := []string{"cvd", "powerwash"};
262+
if _, err := tc.RunCmdWithEnv(createCmd, tempdirEnv); err != nil {
263+
log.Printf("Failed to powerwash instance(s): %w", err)
264+
return err
265+
}
266+
267+
return nil
268+
}
269+
255270
// Common parameters for `cvd load`.
256271
type LoadArgs struct {
257272
LoadConfig string
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright (C) 2026 The Android Open Source Project
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
load("@rules_go//go:def.bzl", "go_test")
16+
17+
go_test(
18+
name = "cvd_powerwash_tests",
19+
size = "large",
20+
srcs = ["main_test.go"],
21+
tags = [
22+
"exclusive",
23+
"external",
24+
"no-sandbox",
25+
"supports-graceful-termination",
26+
],
27+
deps = [
28+
"//cvd/common",
29+
],
30+
)
31+
32+
go_test(
33+
name = "cvd_powerwash_tests_additional_substitution",
34+
size = "large",
35+
srcs = ["main_test.go"],
36+
data = ["//:debian_substitution_marker"],
37+
env = {"LOCAL_DEBIAN_SUBSTITUTION_MARKER_FILE": "$(rlocationpath //:debian_substitution_marker)"},
38+
tags = [
39+
"exclusive",
40+
"external",
41+
"no-sandbox",
42+
"supports-graceful-termination",
43+
],
44+
deps = [
45+
"//cvd/common",
46+
],
47+
)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright (C) 2026 The Android Open Source Project
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package main
16+
17+
import (
18+
"fmt"
19+
"testing"
20+
21+
"github.com/google/android-cuttlefish/e2etests/cvd/common"
22+
)
23+
24+
func TestCvdPowerwash(t *testing.T) {
25+
testcases := []struct {
26+
branch string
27+
target string
28+
}{
29+
{
30+
branch: "aosp-android-latest-release",
31+
target: "aosp_cf_x86_64_only_phone-userdebug",
32+
},
33+
}
34+
c := e2etests.TestContext{}
35+
for _, tc := range testcases {
36+
t.Run(fmt.Sprintf("BUILD=%s/%s", tc.branch, tc.target), func(t *testing.T) {
37+
c.SetUp(t)
38+
defer c.TearDown()
39+
40+
if err := c.CVDFetch(e2etests.FetchArgs{
41+
DefaultBuildBranch: tc.branch,
42+
DefaultBuildTarget: tc.target,
43+
}); err != nil {
44+
t.Fatal(err)
45+
}
46+
47+
if err := c.CVDCreate(e2etests.CreateArgs{}); err != nil {
48+
t.Fatal(err)
49+
}
50+
51+
if err := c.CVDPowerwash(); err != nil {
52+
t.Fatal(err)
53+
}
54+
55+
if err := c.RunAdbWaitForDevice(); err != nil {
56+
t.Fatalf("failed to wait for device to connect to adb: %w", err)
57+
}
58+
})
59+
}
60+
}

0 commit comments

Comments
 (0)