summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConnor O'Brien2016-11-30 13:10:59 -0600
committerConnor O'Brien2016-12-07 21:04:58 -0600
commit100b491d2dea9734e4512371e720262e5cf9694b (patch)
treeb660977ada811356244c0fed227decd7b607fe5f /boot/1.0/vts
parent50dec2faa4eacb23399ac80b91405ed2ae190214 (diff)
downloadplatform-hardware-interfaces-100b491d2dea9734e4512371e720262e5cf9694b.tar.gz
platform-hardware-interfaces-100b491d2dea9734e4512371e720262e5cf9694b.tar.xz
platform-hardware-interfaces-100b491d2dea9734e4512371e720262e5cf9694b.zip
Boot HAL target-side test
Test: make vts; vts-tradefed run -m HalBootHidlTargetTest Bug: 32022514 Change-Id: I65606790cc3b2f93d6706b70fad21c172635e0c7 Signed-off-by: Connor O'Brien <connoro@google.com>
Diffstat (limited to 'boot/1.0/vts')
-rw-r--r--boot/1.0/vts/Android.bp3
-rw-r--r--boot/1.0/vts/Android.mk2
-rw-r--r--boot/1.0/vts/functional/Android.bp40
-rw-r--r--boot/1.0/vts/functional/Android.mk19
-rw-r--r--boot/1.0/vts/functional/boot_hidl_hal_test.cpp171
-rw-r--r--boot/1.0/vts/functional/vts/Android.mk19
-rw-r--r--boot/1.0/vts/functional/vts/testcases/Android.mk19
-rw-r--r--boot/1.0/vts/functional/vts/testcases/hal/Android.mk19
-rw-r--r--boot/1.0/vts/functional/vts/testcases/hal/boot/Android.mk19
-rw-r--r--boot/1.0/vts/functional/vts/testcases/hal/boot/hidl/Android.mk19
-rw-r--r--boot/1.0/vts/functional/vts/testcases/hal/boot/hidl/target/Android.mk25
-rw-r--r--boot/1.0/vts/functional/vts/testcases/hal/boot/hidl/target/AndroidTest.xml30
12 files changed, 385 insertions, 0 deletions
diff --git a/boot/1.0/vts/Android.bp b/boot/1.0/vts/Android.bp
new file mode 100644
index 00000000..7aef46b3
--- /dev/null
+++ b/boot/1.0/vts/Android.bp
@@ -0,0 +1,3 @@
1subdirs = [
2 "*"
3]
diff --git a/boot/1.0/vts/Android.mk b/boot/1.0/vts/Android.mk
index 8a56b274..9b30ef13 100644
--- a/boot/1.0/vts/Android.mk
+++ b/boot/1.0/vts/Android.mk
@@ -77,3 +77,5 @@ LOCAL_SHARED_LIBRARIES := \
77LOCAL_PROTOC_OPTIMIZE_TYPE := full 77LOCAL_PROTOC_OPTIMIZE_TYPE := full
78 78
79include $(BUILD_SHARED_LIBRARY) 79include $(BUILD_SHARED_LIBRARY)
80
81include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/boot/1.0/vts/functional/Android.bp b/boot/1.0/vts/functional/Android.bp
new file mode 100644
index 00000000..714a18b6
--- /dev/null
+++ b/boot/1.0/vts/functional/Android.bp
@@ -0,0 +1,40 @@
1//
2// Copyright (C) 2016 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_test {
18 name: "boot_hidl_hal_test",
19 gtest: true,
20 srcs: ["boot_hidl_hal_test.cpp"],
21 shared_libs: [
22 "libbase",
23 "liblog",
24 "libcutils",
25 "libhidlbase",
26 "libhwbinder",
27 "libnativehelper",
28 "libutils",
29 "android.hardware.boot@1.0",
30 ],
31 static_libs: ["libgtest"],
32 cflags: [
33 "--coverage",
34 "-O0",
35 "-g",
36 ],
37 ldflags: [
38 "--coverage"
39 ]
40}
diff --git a/boot/1.0/vts/functional/Android.mk b/boot/1.0/vts/functional/Android.mk
new file mode 100644
index 00000000..f9e32763
--- /dev/null
+++ b/boot/1.0/vts/functional/Android.mk
@@ -0,0 +1,19 @@
1#
2# Copyright (C) 2016 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17LOCAL_PATH := $(call my-dir)
18
19include $(call all-subdir-makefiles)
diff --git a/boot/1.0/vts/functional/boot_hidl_hal_test.cpp b/boot/1.0/vts/functional/boot_hidl_hal_test.cpp
new file mode 100644
index 00000000..7b002b9d
--- /dev/null
+++ b/boot/1.0/vts/functional/boot_hidl_hal_test.cpp
@@ -0,0 +1,171 @@
1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "boot_hidl_hal_test"
18#include <android-base/logging.h>
19
20#include <cutils/properties.h>
21
22#include <android/hardware/boot/1.0/IBootControl.h>
23
24#include <gtest/gtest.h>
25
26using ::android::hardware::boot::V1_0::IBootControl;
27using ::android::hardware::boot::V1_0::CommandResult;
28using ::android::hardware::boot::V1_0::BoolResult;
29using ::android::hardware::boot::V1_0::Slot;
30using ::android::hardware::hidl_string;
31using ::android::hardware::Return;
32using ::android::sp;
33
34// The main test class for the Boot HIDL HAL.
35class BootHidlTest : public ::testing::Test {
36 public:
37 virtual void SetUp() override {
38 // TODO(b/33385836) Delete copied code
39 bool getStub = false;
40 char getsubProperty[PROPERTY_VALUE_MAX];
41 if (property_get("vts.hidl.get_stub", getsubProperty, "") > 0) {
42 if (!strcmp(getsubProperty, "true") || !strcmp(getsubProperty, "True") ||
43 !strcmp(getsubProperty, "1")) {
44 getStub = true;
45 }
46 }
47 boot = IBootControl::getService("bootctrl", getStub);
48 ASSERT_NE(boot, nullptr);
49 ASSERT_EQ(!getStub, boot->isRemote());
50 }
51
52 virtual void TearDown() override {}
53
54 sp<IBootControl> boot;
55};
56
57auto generate_callback(CommandResult *dest) {
58 return [=](CommandResult cr) { *dest = cr; };
59}
60
61// Sanity check Boot::getNumberSlots().
62TEST_F(BootHidlTest, GetNumberSlots) {
63 uint32_t slots = boot->getNumberSlots();
64 EXPECT_LE((uint32_t)2, slots);
65}
66
67// Sanity check Boot::getCurrentSlot().
68TEST_F(BootHidlTest, GetCurrentSlot) {
69 Slot curSlot = boot->getCurrentSlot();
70 uint32_t slots = boot->getNumberSlots();
71 EXPECT_LT(curSlot, slots);
72}
73
74// Sanity check Boot::markBootSuccessful().
75TEST_F(BootHidlTest, MarkBootSuccessful) {
76 CommandResult cr;
77 Return<void> result = boot->markBootSuccessful(generate_callback(&cr));
78 ASSERT_TRUE(result.getStatus().isOk());
79 if (cr.success) {
80 Slot curSlot = boot->getCurrentSlot();
81 BoolResult ret = boot->isSlotMarkedSuccessful(curSlot);
82 EXPECT_EQ(BoolResult::TRUE, ret);
83 }
84}
85
86// Sanity check Boot::setActiveBootSlot() on good and bad inputs.
87TEST_F(BootHidlTest, SetActiveBootSlot) {
88 for (Slot s = 0; s < 2; s++) {
89 CommandResult cr;
90 Return<void> result = boot->setActiveBootSlot(s, generate_callback(&cr));
91 EXPECT_TRUE(result.getStatus().isOk());
92 }
93 {
94 CommandResult cr;
95 uint32_t slots = boot->getNumberSlots();
96 Return<void> result =
97 boot->setActiveBootSlot(slots, generate_callback(&cr));
98 ASSERT_TRUE(result.getStatus().isOk());
99 EXPECT_EQ(false, cr.success);
100 }
101}
102
103// Sanity check Boot::setSlotAsUnbootable() on good and bad inputs.
104TEST_F(BootHidlTest, SetSlotAsUnbootable) {
105 {
106 CommandResult cr;
107 Slot curSlot = boot->getCurrentSlot();
108 Slot otherSlot = curSlot ? 0 : 1;
109 Return<void> result =
110 boot->setSlotAsUnbootable(otherSlot, generate_callback(&cr));
111 EXPECT_TRUE(result.getStatus().isOk());
112 if (cr.success) {
113 EXPECT_EQ(BoolResult::FALSE, boot->isSlotBootable(otherSlot));
114 boot->setActiveBootSlot(otherSlot, generate_callback(&cr));
115 EXPECT_TRUE(cr.success);
116 }
117 }
118 {
119 CommandResult cr;
120 uint32_t slots = boot->getNumberSlots();
121 Return<void> result =
122 boot->setSlotAsUnbootable(slots, generate_callback(&cr));
123 EXPECT_TRUE(result.getStatus().isOk());
124 EXPECT_EQ(false, cr.success);
125 }
126}
127
128// Sanity check Boot::isSlotBootable() on good and bad inputs.
129TEST_F(BootHidlTest, IsSlotBootable) {
130 for (Slot s = 0; s < 2; s++) {
131 EXPECT_NE(BoolResult::INVALID_SLOT, boot->isSlotBootable(s));
132 }
133 uint32_t slots = boot->getNumberSlots();
134 EXPECT_EQ(BoolResult::INVALID_SLOT, boot->isSlotBootable(slots));
135}
136
137// Sanity check Boot::isSlotMarkedSuccessful() on good and bad inputs.
138TEST_F(BootHidlTest, IsSlotMarkedSuccessful) {
139 for (Slot s = 0; s < 2; s++) {
140 EXPECT_NE(BoolResult::INVALID_SLOT, boot->isSlotMarkedSuccessful(s));
141 }
142 uint32_t slots = boot->getNumberSlots();
143 EXPECT_EQ(BoolResult::INVALID_SLOT, boot->isSlotMarkedSuccessful(slots));
144}
145
146// Sanity check Boot::getSuffix() on good and bad inputs.
147TEST_F(BootHidlTest, GetSuffix) {
148 const char *suffixPtr;
149 auto cb = [&](hidl_string suffix) { suffixPtr = suffix.c_str(); };
150 for (Slot i = 0; i < 2; i++) {
151 CommandResult cr;
152 Return<void> result = boot->getSuffix(i, cb);
153 EXPECT_TRUE(result.getStatus().isOk());
154 char correctSuffix[3];
155 snprintf(correctSuffix, sizeof(correctSuffix), "_%c", 'a' + i);
156 ASSERT_EQ(0, strcmp(suffixPtr, correctSuffix));
157 }
158 {
159 char emptySuffix[] = "";
160 Return<void> result = boot->getSuffix(boot->getNumberSlots(), cb);
161 EXPECT_TRUE(result.getStatus().isOk());
162 ASSERT_EQ(0, strcmp(emptySuffix, suffixPtr));
163 }
164}
165
166int main(int argc, char **argv) {
167 ::testing::InitGoogleTest(&argc, argv);
168 int status = RUN_ALL_TESTS();
169 LOG(INFO) << "Test result = " << status;
170 return status;
171}
diff --git a/boot/1.0/vts/functional/vts/Android.mk b/boot/1.0/vts/functional/vts/Android.mk
new file mode 100644
index 00000000..f9e32763
--- /dev/null
+++ b/boot/1.0/vts/functional/vts/Android.mk
@@ -0,0 +1,19 @@
1#
2# Copyright (C) 2016 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17LOCAL_PATH := $(call my-dir)
18
19include $(call all-subdir-makefiles)
diff --git a/boot/1.0/vts/functional/vts/testcases/Android.mk b/boot/1.0/vts/functional/vts/testcases/Android.mk
new file mode 100644
index 00000000..f9e32763
--- /dev/null
+++ b/boot/1.0/vts/functional/vts/testcases/Android.mk
@@ -0,0 +1,19 @@
1#
2# Copyright (C) 2016 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17LOCAL_PATH := $(call my-dir)
18
19include $(call all-subdir-makefiles)
diff --git a/boot/1.0/vts/functional/vts/testcases/hal/Android.mk b/boot/1.0/vts/functional/vts/testcases/hal/Android.mk
new file mode 100644
index 00000000..f9e32763
--- /dev/null
+++ b/boot/1.0/vts/functional/vts/testcases/hal/Android.mk
@@ -0,0 +1,19 @@
1#
2# Copyright (C) 2016 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17LOCAL_PATH := $(call my-dir)
18
19include $(call all-subdir-makefiles)
diff --git a/boot/1.0/vts/functional/vts/testcases/hal/boot/Android.mk b/boot/1.0/vts/functional/vts/testcases/hal/boot/Android.mk
new file mode 100644
index 00000000..f9e32763
--- /dev/null
+++ b/boot/1.0/vts/functional/vts/testcases/hal/boot/Android.mk
@@ -0,0 +1,19 @@
1#
2# Copyright (C) 2016 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17LOCAL_PATH := $(call my-dir)
18
19include $(call all-subdir-makefiles)
diff --git a/boot/1.0/vts/functional/vts/testcases/hal/boot/hidl/Android.mk b/boot/1.0/vts/functional/vts/testcases/hal/boot/hidl/Android.mk
new file mode 100644
index 00000000..f9e32763
--- /dev/null
+++ b/boot/1.0/vts/functional/vts/testcases/hal/boot/hidl/Android.mk
@@ -0,0 +1,19 @@
1#
2# Copyright (C) 2016 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17LOCAL_PATH := $(call my-dir)
18
19include $(call all-subdir-makefiles)
diff --git a/boot/1.0/vts/functional/vts/testcases/hal/boot/hidl/target/Android.mk b/boot/1.0/vts/functional/vts/testcases/hal/boot/hidl/target/Android.mk
new file mode 100644
index 00000000..844b93b5
--- /dev/null
+++ b/boot/1.0/vts/functional/vts/testcases/hal/boot/hidl/target/Android.mk
@@ -0,0 +1,25 @@
1#
2# Copyright (C) 2016 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17LOCAL_PATH := $(call my-dir)
18
19include $(call all-subdir-makefiles)
20
21include $(CLEAR_VARS)
22
23LOCAL_MODULE := HalBootHidlTargetTest
24VTS_CONFIG_SRC_DIR := testcases/hal/boot/hidl/target
25include test/vts/tools/build/Android.host_config.mk
diff --git a/boot/1.0/vts/functional/vts/testcases/hal/boot/hidl/target/AndroidTest.xml b/boot/1.0/vts/functional/vts/testcases/hal/boot/hidl/target/AndroidTest.xml
new file mode 100644
index 00000000..6c7809c9
--- /dev/null
+++ b/boot/1.0/vts/functional/vts/testcases/hal/boot/hidl/target/AndroidTest.xml
@@ -0,0 +1,30 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright (C) 2016 The Android Open Source Project
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15-->
16<configuration description="Config for VTS Boot HIDL HAL's target-side test cases">
17 <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
18 <option name="push-group" value="HidlHalTest.push" />
19 </target_preparer>
20 <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
21 <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
22 <option name="test-module-name" value="HalBootHidlTargetTest"/>
23 <option name="binary-test-sources" value="
24 _32bit::DATA/nativetest/boot_hidl_hal_test/boot_hidl_hal_test,
25 _64bit::DATA/nativetest64/boot_hidl_hal_test/boot_hidl_hal_test,
26 "/>
27 <option name="binary-test-type" value="gtest" />
28 <option name="test-timeout" value="1m" />
29 </test>
30</configuration>