summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/vts/Android.mk35
-rw-r--r--tests/vts/AndroidTest.xml24
-rw-r--r--tests/vts/verifyDTBO.sh45
3 files changed, 104 insertions, 0 deletions
diff --git a/tests/vts/Android.mk b/tests/vts/Android.mk
new file mode 100644
index 0000000..99681b5
--- /dev/null
+++ b/tests/vts/Android.mk
@@ -0,0 +1,35 @@
+#
+# Copyright (C) 2018 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.
+#
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := verifyDTBO.sh
+LOCAL_SRC_FILES := verifyDTBO.sh
+LOCAL_MODULE_CLASS := EXECUTABLES
+LOCAL_MODULE_TAGS := optional
+LOCAL_IS_HOST_MODULE := true
+LOCAL_REQUIRED_MODULES := \
+ mkdtimg \
+ ufdt_verify_overlay_host \
+
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := VtsVerifyDTBOTest
+VTS_CONFIG_SRC_DIR := system/tools/libufdt/test/vts
+-include test/vts/tools/build/Android.host_config.mk
diff --git a/tests/vts/AndroidTest.xml b/tests/vts/AndroidTest.xml
new file mode 100644
index 0000000..6add7c5
--- /dev/null
+++ b/tests/vts/AndroidTest.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 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.
+-->
+<configuration description="Config for VTS DTBO verification">
+ <multi_target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer"/>
+ <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+ <option name="test-module-name" value="VtsVerifyDTBOTest"/>
+ <option name="binary-test-source" value="out/host/linux-x86/vts/android-vts/testcases/host/bin/verifyDTBO.sh" />
+ <option name="binary-test-type" value="host_binary_test"/>
+ <option name="test-timeout" value="1m"/>
+ </test>
+</configuration>
diff --git a/tests/vts/verifyDTBO.sh b/tests/vts/verifyDTBO.sh
new file mode 100644
index 0000000..e28ac5f
--- /dev/null
+++ b/tests/vts/verifyDTBO.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+if [ -z "${ANDROID_HOST_OUT}" ]; then
+ echo 'ANDROID_HOST_OUT not set. Please run lunch'
+ exit 1
+fi
+
+ANDROID_VTS_HOST_BIN_LOCATION=${ANDROID_HOST_OUT}/vts/android-vts/testcases/host/bin
+
+adb root
+
+tmpdir=$(mktemp -d)
+trap 'rm -rf ${tmpdir};' EXIT
+
+cd $tmpdir
+
+#find out the location to read the DTBO image from
+boot_suffix=$(adb wait-for-device shell getprop ro.boot.slot_suffix)
+dtbo_partition="/dev/block/bootdevice/by-name/dtbo"
+dtbo_path=$dtbo_partition$boot_suffix
+
+#read the dtbo image and the final device tree from device
+adb pull $dtbo_path dtbo.img > /dev/null
+adb pull /sys/firmware/fdt final_dt > /dev/null
+
+#decompile the DTBO image
+mkdtimg_path="${ANDROID_VTS_HOST_BIN_LOCATION}/mkdtimg"
+$mkdtimg_path dump dtbo.img -b dumped_dtbo > /dev/null
+
+#Get the index of the overlay applied from the kernel command line
+overlay_idx=$(adb shell cat /proc/cmdline | grep -o "androidboot.dtbo_idx=\w*" | cut -d "=" -f 2)
+
+#verify that the overlay was correctly applied
+verify_bin_path="${ANDROID_VTS_HOST_BIN_LOCATION}/ufdt_verify_overlay_host"
+$verify_bin_path final_dt dumped_dtbo.$overlay_idx
+result=$?
+
+if [[ "$result" -eq "0" ]]; then
+ echo "Overlay was verified successfully"
+else
+ echo "Incorrect overlay application"
+fi
+
+exit $result
+