diff options
-rw-r--r-- | abi/Android.bp | 32 | ||||
-rw-r--r-- | abi/KernelAbilistTest.xml | 22 | ||||
-rw-r--r-- | abi/OWNERS | 3 | ||||
-rw-r--r-- | abi/src/com/android/tests/abi/KernelAbilistTest.java | 70 | ||||
-rw-r--r-- | fuse_bpf/Android.bp | 44 | ||||
-rw-r--r-- | fuse_bpf/OWNERS | 2 | ||||
-rw-r--r-- | fuse_bpf/__init__.py | 0 | ||||
-rw-r--r-- | fuse_bpf/vts_kernel_fuse_bpf_test.py | 48 | ||||
-rw-r--r-- | fuse_bpf/vts_kernel_fuse_bpf_test.xml | 21 | ||||
-rw-r--r-- | isa/Android.bp | 41 | ||||
-rw-r--r-- | isa/vts_kernel_isa_test.cpp | 67 |
11 files changed, 350 insertions, 0 deletions
diff --git a/abi/Android.bp b/abi/Android.bp new file mode 100644 index 00000000..6b2fba03 --- /dev/null +++ b/abi/Android.bp @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 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 { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +java_test_host { + name: "KernelAbilistTest", + libs: [ + "tradefed", + "compatibility-host-util", + ], + srcs: ["src/**/*.java"], + test_suites: [ + "general-tests", + "vts", + ], + test_config: "KernelAbilistTest.xml", +} diff --git a/abi/KernelAbilistTest.xml b/abi/KernelAbilistTest.xml new file mode 100644 index 00000000..68a0864b --- /dev/null +++ b/abi/KernelAbilistTest.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2023 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="Runs KernelAbilistTest"> + <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer" /> + + <test class="com.android.tradefed.testtype.HostTest" > + <option name="jar" value="KernelAbilistTest.jar" /> + </test> +</configuration> diff --git a/abi/OWNERS b/abi/OWNERS new file mode 100644 index 00000000..82638b75 --- /dev/null +++ b/abi/OWNERS @@ -0,0 +1,3 @@ +# Bug component: 128577 +cferris@google.com +enh@google.com diff --git a/abi/src/com/android/tests/abi/KernelAbilistTest.java b/abi/src/com/android/tests/abi/KernelAbilistTest.java new file mode 100644 index 00000000..8fba83d1 --- /dev/null +++ b/abi/src/com/android/tests/abi/KernelAbilistTest.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2023 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 com.android.tests.abi; + +import static org.junit.Assert.assertTrue; + +import android.platform.test.annotations.RequiresDevice; +import com.android.compatibility.common.util.VsrTest; +import com.android.tradefed.device.ITestDevice; +import com.android.tradefed.testtype.DeviceJUnit4ClassRunner; +import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(DeviceJUnit4ClassRunner.class) +public class KernelAbilistTest extends BaseHostJUnit4Test { + @VsrTest(requirements = {"VSR-3.12-002"}) + @RequiresDevice + @Test + public void testAbilist() throws Exception { + String abi = getProp("ro.product.cpu.abi"); + if (!abi.startsWith("arm")) { + // Only Arm currently has 64-bit-only cores. + return; + } + + // ro.vendor.api_level is the VSR requirement API level + // calculated from ro.product.first_api_level, ro.board.api_level, + // and ro.board.first_api_level. + int api_level = Integer.parseInt(getProp("ro.vendor.api_level")); + if (api_level < 34) { + // Only chipsets that first shipped with API level 34 or later are affected. + return; + } + + // Verify at least one 64 bit ABI is supported. + String abilist64 = getProp("ro.product.cpu.abilist"); + assertTrue("VSR-3.12: must support at least one 64 bit ABI", !abilist64.isEmpty()); + + // Verify no 32 bit ABIs are supported. + String abilist32 = getProp("ro.product.cpu.abilist32"); + assertTrue("VSR-3.12: must not support any 32 bit ABIs; found \"" + abilist32 + "\"", + abilist32.isEmpty()); + + // Verify the full supported ABI list is the same as the 64 bit ABI list. + String abilist = getProp("ro.product.cpu.abilist64"); + assertTrue("VSR-3.12: supported ABIs must be the 64-bit ABIs; supported ABIs=\"" + abilist + + "\", 64 bit ABIs=\"" + abilist64 + "\"", + abilist.equals(abilist64)); + } + + private String getProp(String name) throws Exception { + String result = getDevice().getProperty(name); + return result != null ? result : ""; + } +} diff --git a/fuse_bpf/Android.bp b/fuse_bpf/Android.bp new file mode 100644 index 00000000..95e35a95 --- /dev/null +++ b/fuse_bpf/Android.bp @@ -0,0 +1,44 @@ +// +// Copyright (C) 2022 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 { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +python_test_host { + name: "vts_kernel_fuse_bpf_test", + main: "vts_kernel_fuse_bpf_test.py", + srcs: [ + "vts_kernel_fuse_bpf_test.py", + ], + libs: [ + "vndk_utils", + "vts_kernel_utils", + "vts_vndk_utils", + ], + test_suites: [ + "vts", + ], + test_options: { + unit_test: false, + }, + test_config: "vts_kernel_fuse_bpf_test.xml", + version: { + py3: { + embedded_launcher: true, + } + } +} diff --git a/fuse_bpf/OWNERS b/fuse_bpf/OWNERS new file mode 100644 index 00000000..c1577658 --- /dev/null +++ b/fuse_bpf/OWNERS @@ -0,0 +1,2 @@ +# Bug component: 325626 +paullawrence@google.com diff --git a/fuse_bpf/__init__.py b/fuse_bpf/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/fuse_bpf/__init__.py diff --git a/fuse_bpf/vts_kernel_fuse_bpf_test.py b/fuse_bpf/vts_kernel_fuse_bpf_test.py new file mode 100644 index 00000000..0f6a911b --- /dev/null +++ b/fuse_bpf/vts_kernel_fuse_bpf_test.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright (C) 2022 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. +# + +import os +import time +import unittest + +from vts.testcases.kernel.utils import adb +from vts.testcases.vndk import utils + +class VtsKernelFuseBpfTest(unittest.TestCase): + + def setUp(self): + serial_number = os.environ.get("ANDROID_SERIAL") + self.assertTrue(serial_number, "$ANDROID_SERIAL is empty.") + self.dut = utils.AndroidDevice(serial_number) + self.adb = adb.ADB(serial_number) + + def testFuseBpfEnabled(self): + out_api, err, return_code = self.dut.Execute("getprop ro.vendor.api_level") + first_api_level = 0 + try: + first_api_level = int(out_api) + except: + pass + out_running, err, return_code = self.dut.Execute("getprop ro.fuse.bpf.is_running") + self.assertTrue(first_api_level < 34 or out_running.strip() == "true", + "fuse-bpf is disabled") + + +if __name__ == "__main__": + # Setting verbosity is required to generate output that the TradeFed test + # runner can parse. + unittest.main(verbosity=3) diff --git a/fuse_bpf/vts_kernel_fuse_bpf_test.xml b/fuse_bpf/vts_kernel_fuse_bpf_test.xml new file mode 100644 index 00000000..810b38d3 --- /dev/null +++ b/fuse_bpf/vts_kernel_fuse_bpf_test.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2022 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 to run vts_kernel_fuse_bpf_test unittests"> + <test class="com.android.tradefed.testtype.python.PythonBinaryHostTest" > + <option name="par-file-name" value="vts_kernel_fuse_bpf_test" /> + <option name="test-timeout" value="10m" /> + </test> +</configuration> diff --git a/isa/Android.bp b/isa/Android.bp new file mode 100644 index 00000000..4750a6e1 --- /dev/null +++ b/isa/Android.bp @@ -0,0 +1,41 @@ +// Copyright (C) 2023 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 { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +cc_test { + name: "vts_kernel_isa_test", + srcs: ["vts_kernel_isa_test.cpp"], + defaults: [ + "libvintf_static_user_defaults", + ], + cflags: [ + "-Wall", + "-Werror", + ], + shared_libs: [ + "libbase", + ], + static_libs: [ + "libvintf", + ], + test_suites: [ + "general-tests", + "vts", + ], + require_root: true, + auto_gen_config: true, +} diff --git a/isa/vts_kernel_isa_test.cpp b/isa/vts_kernel_isa_test.cpp new file mode 100644 index 00000000..8db2ff73 --- /dev/null +++ b/isa/vts_kernel_isa_test.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2023 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. + */ + +#include <android/api-level.h> +#include <android-base/properties.h> +#include <gtest/gtest.h> +#include <vintf/VintfObject.h> + +using android::vintf::VintfObject; +using android::vintf::RuntimeInfo; + +std::optional<std::string> get_config( + const std::map<std::string, std::string>& configs, const std::string& key) { + auto it = configs.find(key); + if (it == configs.end()) { + return std::nullopt; + } + return it->second; +} + +/* + * Tests that the kernel in use is meant to run on CPUs that support a + * 64-bit Instruction Set Architecture (ISA). + */ +TEST(KernelISATest, KernelUses64BitISA) { + /* + * ro.vendor.api_level is the VSR API level, which is calculated + * as: + * + * vendor.api_level = min(ro.product.first_api_level, ro.board.[first_]api_level) + * + * If ro.board.api_level is defined, it is used for the comparison instead + * of ro.board.first_api_level. + */ + int vendor_api_level = android::base::GetIntProperty("ro.vendor.api_level", + -1); + + /* + * Ensure that we run this test for devices launching with Android 14+, but not + * devices that are upgrading to Android 14+. + */ + if (vendor_api_level < __ANDROID_API_U__) + GTEST_SKIP() << "Exempt from KernelUses64BitISATest: ro.vendor.api_level (" + << vendor_api_level << ") < " << __ANDROID_API_U__; + + std::shared_ptr<const RuntimeInfo> runtime_info = VintfObject::GetRuntimeInfo(); + ASSERT_NE(nullptr, runtime_info); + + const auto& configs = runtime_info->kernelConfigs(); + ASSERT_EQ(get_config(configs, "CONFIG_64BIT"), "y") << "VSR-3.12: Devices " + << "launching with Android 14+ " + << "must support 64-bit ABIs and " + << "thus must use a 64-bit kernel."; +} |