Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions e2etests/cvd/cvd_powerwash_tests/common/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (C) 2026 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "common",
srcs = ["common.go"],
importpath = "github.com/google/android-cuttlefish/e2etests/cvd/cvd_powerwash_tests/common",
visibility = ["//visibility:public"],
deps = [
"//cvd/common",
],
)
49 changes: 49 additions & 0 deletions e2etests/cvd/cvd_powerwash_tests/common/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (C) 2026 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package provides common functionality for launching and interacting
// with Cuttlefish instances for tests.

package powerwash_common

import (
"fmt"

"github.com/google/android-cuttlefish/e2etests/cvd/common"
)

func VerifyPowerwash(c *e2etests.TestContext) error {
if err := c.RunAdbWaitForDevice(); err != nil {
return fmt.Errorf("failed to wait for Cuttlefish device to connect to adb: %w", err)
}

const tmpFile = "/data/local/tmp/foo"
if _, err := c.RunCmd("adb", "shell", "touch", tmpFile); err != nil {
return fmt.Errorf("failed to create %s: %w", tmpFile, err)
}

if _, err := c.RunCmd("adb", "shell", "stat", tmpFile); err != nil {
return fmt.Errorf("failed to verify %s created: %w", tmpFile, err)
}

if err := c.CVDPowerwash(); err != nil {
return fmt.Errorf("failed to run powerwash command: %w", err)
}

if _, err := c.RunCmd("adb", "shell", "stat", tmpFile); err == nil {
return fmt.Errorf("failed to powerwash, %s still exists", tmpFile)
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ go_test(
],
deps = [
"//cvd/common",
"//cvd/cvd_powerwash_tests/common",
],
)

Expand All @@ -44,5 +45,6 @@ go_test(
],
deps = [
"//cvd/common",
"//cvd/cvd_powerwash_tests/common",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,34 @@ import (
"testing"

"github.com/google/android-cuttlefish/e2etests/cvd/common"
"github.com/google/android-cuttlefish/e2etests/cvd/cvd_powerwash_tests/common"
)

func TestCvdPowerwash(t *testing.T) {
testcases := []struct {
shortName string
branch string
target string
createArgs []string
}{
{
shortName: "Aosp",
branch: "aosp-android-latest-release",
target: "aosp_cf_x86_64_only_phone-userdebug",
createArgs: []string{},
},
{
shortName: "AospGfxstreamSwangle",
branch: "aosp-android-latest-release",
target: "aosp_cf_x86_64_only_phone-userdebug",
createArgs: []string{
"--gpu_mode=gfxstream_guest_angle_host_swiftshader",
},
},
}
c := e2etests.TestContext{}
for _, tc := range testcases {
t.Run(fmt.Sprintf("BUILD=%s/%s", tc.branch, tc.target), func(t *testing.T) {
t.Run(fmt.Sprintf("BUILD=%s", tc.shortName), func(t *testing.T) {
c.SetUp(t)
defer c.TearDown()

Expand All @@ -44,30 +57,13 @@ func TestCvdPowerwash(t *testing.T) {
t.Fatal(err)
}

if err := c.CVDCreate(e2etests.CreateArgs{}); err != nil {
if err := c.CVDCreate(e2etests.CreateArgs{Args: tc.createArgs}); err != nil {
t.Fatal(err)
}

if err := c.RunAdbWaitForDevice(); err != nil {
t.Fatalf("failed to wait for Cuttlefish device to connect to adb: %w", err)
}

const tmpFile = "/data/local/tmp/foo"
if _, err := c.RunCmd("adb", "shell", "touch", tmpFile); err != nil {
t.Fatalf("failed to create %s: %w", tmpFile, err)
}

if _, err := c.RunCmd("adb", "shell", "stat", tmpFile); err != nil {
t.Fatal("failed to verify %s created: %w", err)
}

if err := c.CVDPowerwash(); err != nil {
if err := powerwash_common.VerifyPowerwash(&c); err != nil {
t.Fatal(err)
}

if _, err := c.RunCmd("adb", "shell", "stat", tmpFile); err == nil {
t.Fatal("failed to powerwash, %s still exists")
}
})
}
}
}
52 changes: 52 additions & 0 deletions e2etests/cvd/cvd_powerwash_tests/gpu/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright (C) 2026 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_go//go:def.bzl", "go_test")

go_test(
name = "cvd_powerwash_tests",
size = "large",
srcs = ["main_test.go"],
tags = [
"exclusive",
"external",
"no-sandbox",
"requires_gpu",
"supports-graceful-termination",
],
deps = [
"//cvd/common",
"//cvd/cvd_powerwash_tests/common",
],
)

go_test(
name = "cvd_powerwash_tests_additional_substitution",
size = "large",
srcs = ["main_test.go"],
data = ["//:debian_substitution_marker"],
env = {"LOCAL_DEBIAN_SUBSTITUTION_MARKER_FILE": "$(rlocationpath //:debian_substitution_marker)"},
tags = [
"exclusive",
"external",
"no-sandbox",
"requires_gpu",
"supports-graceful-termination",

],
deps = [
"//cvd/common",
"//cvd/cvd_powerwash_tests/common",
],
)
71 changes: 71 additions & 0 deletions e2etests/cvd/cvd_powerwash_tests/gpu/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright (C) 2026 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"fmt"
"testing"

"github.com/google/android-cuttlefish/e2etests/cvd/common"
"github.com/google/android-cuttlefish/e2etests/cvd/cvd_powerwash_tests/common"
)

func TestCvdPowerwash(t *testing.T) {
testcases := []struct {
shortName string
branch string
target string
createArgs []string
}{
{
shortName: "AospGfxstream",
branch: "aosp-android-latest-release",
target: "aosp_cf_x86_64_only_phone-userdebug",
createArgs: []string{
"--gpu_mode=gfxstream",
},
},
{
shortName: "AospGfxstreamAngle",
branch: "aosp-android-latest-release",
target: "aosp_cf_x86_64_only_phone-userdebug",
createArgs: []string{
"--gpu_mode=gfxstream_guest_angle",
},
},
}
c := e2etests.TestContext{}
for _, tc := range testcases {
t.Run(fmt.Sprintf("BUILD=%s", tc.shortName), func(t *testing.T) {
c.SetUp(t)
defer c.TearDown()

if err := c.CVDFetch(e2etests.FetchArgs{
DefaultBuildBranch: tc.branch,
DefaultBuildTarget: tc.target,
}); err != nil {
t.Fatal(err)
}

if err := c.CVDCreate(e2etests.CreateArgs{Args: tc.createArgs}); err != nil {
t.Fatal(err)
}

if err := powerwash_common.VerifyPowerwash(&c); err != nil {
t.Fatal(err)
}
})
}
}
Loading