Merge "Remove utils/native/testability_checker"
diff --git a/utils/native/testability_checker/Android.bp b/utils/native/testability_checker/Android.bp
deleted file mode 100644
index 5a721ff..0000000
--- a/utils/native/testability_checker/Android.bp
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-// Copyright (C) 2017 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_defaults {
- name: "VtsTestabilityCheckerDefaults",
- shared_libs: [
- "libbase",
- "libcutils",
- "libhidlbase",
- "liblog",
- "libselinux",
- "libtinyxml2",
- "libutils",
- "libz",
- ],
- static_libs: [
- "libvintf",
- "libhidl-gen-utils",
- ],
- cflags: [
- "-Wall",
- "-Werror",
- ],
-}
-
-cc_library {
- name: "libvts_testability_checker",
- defaults : ["VtsTestabilityCheckerDefaults"],
- srcs: ["VtsTestabilityChecker.cpp"],
-}
-
-cc_test {
- name: "libvts_testability_checker_test",
- defaults : ["VtsTestabilityCheckerDefaults"],
- srcs: ["VtsTestabilityCheckerTest.cpp"],
-
- static_libs: [
- "libgmock",
- "libvts_testability_checker",
- ],
-}
-
-cc_binary {
- name: "vts_testability_checker",
- defaults : ["VtsTestabilityCheckerDefaults"],
- srcs: ["VtsTestabilityCheckerMain.cpp"],
- multilib: {
- lib64: {
- suffix: "64",
- },
- lib32: {
- suffix: "32",
- },
- },
- compile_multilib: "both",
- static_libs: [
- "libhidl-gen-utils",
- "libjsoncpp",
- "libvts_testability_checker",
- ],
-}
diff --git a/utils/native/testability_checker/VtsTestabilityChecker.cpp b/utils/native/testability_checker/VtsTestabilityChecker.cpp
deleted file mode 100644
index b667c5f..0000000
--- a/utils/native/testability_checker/VtsTestabilityChecker.cpp
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-#define LOG_TAG "VtsTestabilityChecker"
-
-#include "VtsTestabilityChecker.h"
-
-#include <algorithm>
-#include <iostream>
-#include <set>
-
-#include <android-base/strings.h>
-#include <vintf/parse_string.h>
-
-using android::base::Join;
-using android::vintf::Arch;
-using android::vintf::CompatibilityMatrix;
-using android::vintf::gArchStrings;
-using android::vintf::HalManifest;
-using android::vintf::ManifestHal;
-using android::vintf::ManifestInstance;
-using android::vintf::MatrixHal;
-using android::vintf::MatrixInstance;
-using android::vintf::toFQNameString;
-using android::vintf::Transport;
-using android::vintf::Version;
-using android::vintf::operator<<;
-using std::set;
-using std::string;
-using std::vector;
-
-namespace android {
-namespace vts {
-
-bool VtsTestabilityChecker::CheckHalForComplianceTest(
- const string& hal_package_name, const Version& hal_version,
- const string& hal_interface_name, const Arch& arch,
- set<string>* instances) {
- CHECK(instances) << "instances set should not be NULL.";
- set<string> famework_hal_instances;
- set<string> vendor_hal_instances;
- bool check_framework_hal = CheckFrameworkManifestHal(
- hal_package_name, hal_version, hal_interface_name, arch,
- &famework_hal_instances);
- bool check_vendor_hal =
- CheckVendorManifestHal(hal_package_name, hal_version, hal_interface_name,
- arch, &vendor_hal_instances);
- set_union(famework_hal_instances.begin(), famework_hal_instances.end(),
- vendor_hal_instances.begin(), vendor_hal_instances.end(),
- std::inserter(*instances, instances->begin()));
- return check_framework_hal || check_vendor_hal;
-}
-
-bool VtsTestabilityChecker::CheckHalForNonComplianceTest(
- const string& hal_package_name, const Version& hal_version,
- const string& hal_interface_name, const Arch& arch,
- set<string>* instances) {
- CHECK(instances) << "instances set should not be NULL.";
- set<string> vendor_hal_instances;
- set<string> test_hal_instances;
- bool check_vendor_hal =
- CheckVendorManifestHal(hal_package_name, hal_version, hal_interface_name,
- arch, &vendor_hal_instances);
-
- bool check_test_hal = CheckTestHalWithHwManager(
- hal_package_name, hal_version, hal_interface_name, &test_hal_instances);
-
- set_union(vendor_hal_instances.begin(), vendor_hal_instances.end(),
- test_hal_instances.begin(), test_hal_instances.end(),
- std::inserter(*instances, instances->begin()));
- return check_vendor_hal || check_test_hal;
-}
-
-vector<const ManifestInstance*> VtsTestabilityChecker::FindInstance(
- const vector<ManifestInstance>& manifest_instances,
- const MatrixInstance& matrix_instance) {
- vector<const ManifestInstance*> ret;
- for (const auto& e : manifest_instances) {
- if (matrix_instance.matchInstance(e.instance())) {
- ret.push_back(&e);
- }
- }
- return ret;
-}
-
-vector<const ManifestInstance*> VtsTestabilityChecker::FindInterface(
- const vector<ManifestInstance>& manifest_instances,
- const MatrixInstance& matrix_instance) {
- vector<const ManifestInstance*> ret;
- for (const auto& e : manifest_instances) {
- if (e.interface() == matrix_instance.interface()) {
- ret.push_back(&e);
- }
- }
- return ret;
-}
-
-bool VtsTestabilityChecker::CheckFrameworkCompatibleHal(
- const string& hal_package_name, const Version& hal_version,
- const string& hal_interface_name, const Arch& arch,
- set<string>* instances) {
- CHECK(instances) << "instances set should not be NULL.";
-
- auto matrix_instances = framework_comp_matrix_->getHidlFqInstances(
- hal_package_name, hal_version, hal_interface_name);
- auto manifest_instances = device_hal_manifest_->getHidlFqInstances(
- hal_package_name, hal_version, hal_interface_name);
-
- bool testable = false;
-
- for (const auto& matrix_instance : matrix_instances) {
- const auto& matched_instances =
- FindInstance(manifest_instances, matrix_instance);
- if (!matrix_instance.optional() && matched_instances.empty()) {
- // In matrix but not in manifest.
- // The test should still run, but expect the test
- // to fail (due to incompatible vendor and framework HAL).
- LOG(ERROR) << "Compatibility error. Hal " << hal_package_name
- << " is required by framework but not supported by vendor";
- if (!hal_interface_name.empty()) {
- if (!matrix_instance.isRegex()) {
- instances->insert(matrix_instance.exactInstance());
- } else {
- LOG(ERROR) << "Ignore regex-instance '"
- << matrix_instance.regexPattern();
- }
- }
- testable |= true;
- continue;
- }
-
- if (hal_interface_name.empty()) {
- testable |= !matched_instances.empty();
- continue;
- }
-
- auto get_testable_instances =
- [&](const vector<const vintf::ManifestInstance*>& manifest_instances) {
- vector<string> ret;
- for (const auto& manifest_instance : manifest_instances) {
- if ((manifest_instance->transport() == Transport::PASSTHROUGH &&
- CheckPassthroughManifestArch(manifest_instance->arch(),
- arch)) ||
- manifest_instance->transport() == Transport::HWBINDER) {
- ret.push_back(manifest_instance->instance());
- }
- }
- return ret;
- };
-
- auto testable_instances = get_testable_instances(matched_instances);
- if (!testable_instances.empty()) {
- instances->insert(testable_instances.begin(), testable_instances.end());
- testable |= true;
- continue;
- }
-
- // Special case: if a.h.foo@1.0::IFoo/default is in matrix but /custom
- // is in manifest, the interface is still testable, but /default should
- // not be added to instances.
- const auto& matched_interface_instances =
- FindInterface(manifest_instances, matrix_instance);
- auto testable_interfaces =
- get_testable_instances(matched_interface_instances);
- if (!testable_interfaces.empty()) {
- testable |= true;
- continue;
- }
- }
- if (instances->empty()) {
- LOG(ERROR) << "Hal "
- << toFQNameString(hal_package_name, hal_version,
- hal_interface_name)
- << " has no testable instance";
- }
- return testable;
-}
-
-bool VtsTestabilityChecker::CheckPassthroughManifestArch(
- const Arch& manifest_arch, const Arch& arch) {
- switch (arch) {
- case Arch::ARCH_32: {
- if (android::vintf::has32(manifest_arch)) {
- return true;
- }
- break;
- }
- case Arch::ARCH_64: {
- if (android::vintf::has64(manifest_arch)) {
- return true;
- }
- break;
- }
- default: {
- LOG(ERROR) << "Unexpected arch to check: " << arch;
- break;
- }
- }
- return false;
-}
-
-bool VtsTestabilityChecker::CheckFrameworkManifestHal(
- const string& hal_package_name, const Version& hal_version,
- const string& hal_interface_name, const Arch& arch,
- set<string>* instances) {
- return CheckManifestHal(framework_hal_manifest_, hal_package_name,
- hal_version, hal_interface_name, arch, instances);
-}
-
-bool VtsTestabilityChecker::CheckVendorManifestHal(
- const string& hal_package_name, const Version& hal_version,
- const string& hal_interface_name, const Arch& arch,
- set<string>* instances) {
- return CheckManifestHal(device_hal_manifest_, hal_package_name, hal_version,
- hal_interface_name, arch, instances);
-}
-
-bool VtsTestabilityChecker::CheckManifestHal(const HalManifest* hal_manifest,
- const string& hal_package_name,
- const Version& hal_version,
- const string& hal_interface_name,
- const Arch& arch,
- set<string>* instances) {
- CHECK(instances) << "instances set should not be NULL.";
-
- const auto& manifest_instances = hal_manifest->getHidlFqInstances(
- hal_package_name, hal_version, hal_interface_name);
-
- const auto& fq_instance_name =
- toFQNameString(hal_package_name, hal_version, hal_interface_name);
-
- if (manifest_instances.empty()) {
- LOG(DEBUG) << "Does not find instances for " << fq_instance_name
- << " in manifest file";
- return false;
- }
-
- bool testable = false;
- for (const auto& manifest_instance : manifest_instances) {
- if (manifest_instance.transport() == Transport::PASSTHROUGH &&
- !CheckPassthroughManifestArch(manifest_instance.arch(), arch)) {
- LOG(DEBUG) << "Manifest HAL " << fq_instance_name
- << " is passthrough and does not support arch " << arch;
- continue; // skip this instance
- }
- if (!hal_interface_name.empty()) {
- instances->insert(manifest_instance.instance());
- }
- testable = true;
- }
- return testable;
-}
-
-bool VtsTestabilityChecker::CheckTestHalWithHwManager(
- const string& hal_package_name, const Version& hal_version,
- const string& hal_interface_name, set<string>* instances) {
- CHECK(instances) << "instances set should not be NULL.";
-
- string fqName =
- toFQNameString(hal_package_name, hal_version, hal_interface_name);
- bool registered = false;
- hardware::Return<void> res;
- if (!hal_interface_name.empty()) {
- res = sm_->listByInterface(fqName, [&](const auto& registered_instances) {
- for (const string& instance : registered_instances) {
- registered = true;
- instances->insert(instance);
- }
- });
- } else { // handle legacy data without interface info.
- res = sm_->list([&](const auto& services) {
- for (const string& service : services) {
- if (service.find(fqName) == 0) {
- registered = true;
- break;
- }
- }
- });
- }
- if (!res.isOk()) {
- LOG(ERROR) << "failed to check services: " << res.description();
- return false;
- }
- return registered;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/utils/native/testability_checker/VtsTestabilityChecker.h b/utils/native/testability_checker/VtsTestabilityChecker.h
deleted file mode 100644
index a7ebb83..0000000
--- a/utils/native/testability_checker/VtsTestabilityChecker.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#ifndef UTILS_NATIVE_TESTABILITY_CHECKER_H_
-#define UTILS_NATIVE_TESTABILITY_CHECKER_H_
-
-#include <set>
-
-#include <android-base/logging.h>
-#include <android/hidl/manager/1.0/IServiceManager.h>
-#include <vintf/CompatibilityMatrix.h>
-#include <vintf/HalManifest.h>
-
-using android::hidl::manager::V1_0::IServiceManager;
-using android::vintf::Arch;
-using android::vintf::CompatibilityMatrix;
-using android::vintf::HalManifest;
-using android::vintf::ManifestHal;
-using android::vintf::MatrixHal;
-using android::vintf::Version;
-using std::set;
-using std::string;
-using std::vector;
-
-namespace android {
-namespace vts {
-
-// Library class to decide whether to run a test against given hal based on
-// the system compatibility matrix and device manifest files. Also collect the
-// instance names for testing if the decision is true.
-class VtsTestabilityChecker {
- public:
- VtsTestabilityChecker(const CompatibilityMatrix* framework_comp_matrix,
- const HalManifest* framework_hal_manifest,
- const HalManifest* device_hal_manifest,
- sp<IServiceManager> sm)
- : framework_comp_matrix_(framework_comp_matrix),
- framework_hal_manifest_(framework_hal_manifest),
- device_hal_manifest_(device_hal_manifest),
- sm_(sm) {
- CHECK(framework_comp_matrix_) << "framework_comp_matrix null.";
- CHECK(framework_hal_manifest_) << "framework_hal_manifest null.";
- CHECK(device_hal_manifest_) << "device_hal_manifest null.";
- };
-
- // Check whether we should run a compliance test against the given hal with
- // the package name, version and interface name. Arch (32 or 64) info is
- // required if the hal is a passthrough hal.
- // Return true to indicate we should run the test, false otherwise.
- // Store the instances name to run the test, instance should be empty set if
- // we determine not to run the test (i,e. return value false).
- bool CheckHalForComplianceTest(const string& hal_package_name,
- const Version& hal_version,
- const string& hal_interface_name,
- const Arch& arch, set<string>* instances);
-
- // Check whether we should run a non-compliance test against the given hal
- // with the package name, version and interface name. Arch (32 or 64) info is
- // required if the hal is a passthrough hal.
- // Return true to indicate we should run the test, false otherwise.
- // Store the instances name to run the test, instance should be empty set if
- // we determine not to run the test (i,e. return value false).
- bool CheckHalForNonComplianceTest(const string& hal_package_name,
- const Version& hal_version,
- const string& hal_interface_name,
- const Arch& arch, set<string>* instances);
- private:
- // Internal method to check the given hal against the framework compatibility
- // matrix and device manifest.
- // If the hal is required by the framework, return true with the corresponding
- // instance names. If the hal is optional for framework, return true if vendor
- // supports the hal with the corresponding instance names, false otherwise.
- bool CheckFrameworkCompatibleHal(const string& hal_package_name,
- const Version& hal_version,
- const string& hal_interface_name,
- const Arch& arch, set<string>* instances);
-
- // Internal method to check whether the given hal is supported by vendor
- // (i.e exists in the vendor manifest file). Store the corresponding instance
- // names if supported..
- // Arch (32 or 64) info is required if the hal is a passthrough hal.
- bool CheckVendorManifestHal(const string& hal_package_name,
- const Version& hal_version,
- const string& hal_interface_name,
- const Arch& arch, set<string>* instances);
-
- // Internal method to check whether the given hal is supported by framework
- // (i.e exists in the framework manifest file). Store the corresponding
- // instance names if supported.
- // Arch (32 or 64) info is required if the hal is a passthrough hal.
- bool CheckFrameworkManifestHal(const string& hal_package_name,
- const Version& hal_version,
- const string& hal_interface_name,
- const Arch& arch, set<string>* instances);
-
- // Internal method to check whether the given hal is registered with
- // hwservicemanager. Store the corresponding instance names if registered.
- // This is used to check test hals that is not listed in manifest files.
- // Note this could not check for passthrough hals.
- bool CheckTestHalWithHwManager(const string& hal_package_name,
- const Version& hal_version,
- const string& hal_interface_name,
- set<string>* instances);
-
- // Helper method to check whether the hal_manifest support the
- // package@version::interface and arch (for passthrough hal). Store the
- // corresponding instance names if supported.
- bool CheckManifestHal(const HalManifest* hal_manifest,
- const string& hal_package_name,
- const Version& hal_version,
- const string& hal_interface_name, const Arch& arch,
- set<string>* instances);
-
- // Helper method to check whether a passthrough hal support the given arch
- // (32 or 64).
- bool CheckPassthroughManifestArch(const Arch& manifest_arch,
- const Arch& arch);
-
- // Helper method to find matching instances from a list of
- // manifest_instances.
- vector<const vintf::ManifestInstance*> FindInstance(
- const vector<vintf::ManifestInstance>& manifest_instances,
- const vintf::MatrixInstance& matrix_instance);
-
- // Helper method to find matching interfaces from a list of
- // manifest_instances.
- vector<const vintf::ManifestInstance*> FindInterface(
- const vector<vintf::ManifestInstance>& manifest_instances,
- const vintf::MatrixInstance& matrix_instance);
-
- const CompatibilityMatrix* framework_comp_matrix_; // Do not own.
- const HalManifest* framework_hal_manifest_; // Do not own.
- const HalManifest* device_hal_manifest_; // Do not own.
- sp<IServiceManager> sm_;
-
- friend class
- VtsTestabilityCheckerTest_CheckFrameworkCompatibleHalOptional_Test;
- friend class
- VtsTestabilityCheckerTest_CheckFrameworkCompatibleHalRequired_Test;
-};
-
-} // namespace vts
-} // namespace android
-#endif // UTILS_NATIVE_TESTABILITY_CHECKER_H_
diff --git a/utils/native/testability_checker/VtsTestabilityCheckerMain.cpp b/utils/native/testability_checker/VtsTestabilityCheckerMain.cpp
deleted file mode 100644
index c96f009..0000000
--- a/utils/native/testability_checker/VtsTestabilityCheckerMain.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2017 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 <getopt.h>
-#include <json/json.h>
-#include <iostream>
-
-#include <hidl-util/FQName.h>
-#include <hidl/ServiceManagement.h>
-#include <vintf/VintfObject.h>
-
-#include "VtsTestabilityChecker.h"
-
-using android::hidl::manager::V1_0::IServiceManager;
-using android::vintf::VintfObject;
-using std::cerr;
-using std::cout;
-using std::endl;
-
-// Example:
-// vts_testability_checker --compliance android.hardware.foo@1.0::IFoo
-// vts_testability_checker -c -b 32 android.hardware.foo@1.0::IFoo
-// vts_testability_checker android.hardware.foo@1.0
-void ShowUsage() {
- cout << "Usage: vts_hal_testability_checker [options] <hal name>\n"
- "--compliance: Whether to check for compliance test.\n"
- "--bitness: Test bitness.\n"
- "--help: Show help\n";
- exit(1);
-}
-
-const option long_opts[] = {{"help", no_argument, nullptr, 'h'},
- {"compliance", no_argument, nullptr, 'c'},
- {"bitness", required_argument, nullptr, 'b'},
- {nullptr, 0, nullptr, 0}};
-
-int main(int argc, char** argv) {
- string bitness = "32";
- bool is_compliance_test = false;
-
- while (true) {
- int opt = getopt_long(argc, argv, "hcb:", long_opts, nullptr);
- if (opt == -1) {
- break;
- }
-
- switch (opt) {
- case 'h':
- case '?':
- ShowUsage();
- return 0;
- case 'c': {
- is_compliance_test = true;
- break;
- }
- case 'b': {
- bitness = string(optarg);
- if (bitness != "32" && bitness != "64") {
- cerr << "Invalid bitness " << bitness << endl;
- return -1;
- }
- break;
- }
- default:
- cerr << "getopt_long returned unexpected value " << opt << endl;
- return -1;
- }
- }
-
- if (optind != argc - 1) {
- cerr << "Must specify the hal name (see --help)." << endl;
- return -1;
- }
-
- android::FQName hal_fq_name;
- if (!android::FQName::parse(argv[optind], &hal_fq_name)) {
- cerr << "Invalid hal name: " << argv[optind] << endl;
- return -1;
- }
-
- string hal_package_name = hal_fq_name.package();
- size_t hal_major_version = hal_fq_name.getPackageMajorVersion();
- size_t hal_minor_version = hal_fq_name.getPackageMinorVersion();
- string hal_interface_name = hal_fq_name.name();
- Version hal_version(hal_major_version, hal_minor_version);
-
- Arch arch;
- if (bitness == "32") {
- arch = Arch::ARCH_32;
- } else if (bitness == "64") {
- arch = Arch::ARCH_64;
- }
-
- auto framework_comp_matrix = VintfObject::GetFrameworkCompatibilityMatrix();
- if (!framework_comp_matrix) {
- cerr << "Failed to get framework compatibility matrix." << endl;
- return -1;
- }
-
- auto device_hal_manifest = VintfObject::GetDeviceHalManifest();
- if (!device_hal_manifest) {
- cerr << "Failed to get device manifest." << endl;
- return -1;
- }
-
- auto framework_hal_manifest = VintfObject::GetFrameworkHalManifest();
- if (!framework_hal_manifest) {
- cerr << "Failed to get framework manifest." << endl;
- return -1;
- }
-
- android::sp<IServiceManager> sm =
- ::android::hardware::defaultServiceManager();
- if (sm == nullptr) {
- cerr << "failed to get IServiceManager" << endl;
- return -1;
- }
-
- android::vts::VtsTestabilityChecker checker(framework_comp_matrix.get(),
- framework_hal_manifest.get(),
- device_hal_manifest.get(), sm);
- set<string> instances;
- bool result = false;
- if (is_compliance_test) {
- result = checker.CheckHalForComplianceTest(
- hal_package_name, hal_version, hal_interface_name, arch, &instances);
- } else {
- result = checker.CheckHalForNonComplianceTest(
- hal_package_name, hal_version, hal_interface_name, arch, &instances);
- }
-
- // Create json output.
- Json::Value root(Json::objectValue);
- root["Testable"] = Json::Value(result);
- root["instances"] = Json::Value(Json::arrayValue);
- for (const string& instance : instances) {
- root["instances"].append(instance);
- }
-
- Json::StreamWriterBuilder factory;
- std::string json_output = Json::writeString(factory, root);
-
- cout << json_output;
- return 0;
-}
diff --git a/utils/native/testability_checker/VtsTestabilityCheckerTest.cpp b/utils/native/testability_checker/VtsTestabilityCheckerTest.cpp
deleted file mode 100644
index 1a87a69..0000000
--- a/utils/native/testability_checker/VtsTestabilityCheckerTest.cpp
+++ /dev/null
@@ -1,586 +0,0 @@
-/*
- * Copyright (C) 2017 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 "VtsTestabilityChecker.h"
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-#include <vintf/CompatibilityMatrix.h>
-#include <vintf/HalManifest.h>
-#include <vintf/parse_xml.h>
-
-using namespace testing;
-
-using android::hardware::hidl_array;
-using android::hardware::hidl_death_recipient;
-using android::hardware::hidl_handle;
-using android::hardware::hidl_string;
-using android::hardware::hidl_vec;
-using android::hidl::base::V1_0::IBase;
-using android::hidl::manager::V1_0::IServiceManager;
-using android::hidl::manager::V1_0::IServiceNotification;
-using android::vintf::Arch;
-using android::vintf::CompatibilityMatrix;
-using android::vintf::fromXml;
-using android::vintf::HalManifest;
-using android::vintf::ManifestHal;
-using android::vintf::MatrixHal;
-using android::vintf::Version;
-using std::set;
-using std::string;
-
-namespace android {
-namespace vts {
-
-class MockServiceManager : public IServiceManager {
- public:
- template <typename T>
- using R = ::android::hardware::Return<T>;
- using String = const hidl_string &;
- ~MockServiceManager() = default;
-
-#define MOCK_METHOD_CB(name) \
- MOCK_METHOD1(name, R<void>(IServiceManager::name##_cb))
-
- MOCK_METHOD2(get, R<sp<IBase>>(String, String));
- MOCK_METHOD2(add, R<bool>(String, const sp<IBase> &));
- MOCK_METHOD2(getTransport, R<IServiceManager::Transport>(String, String));
- MOCK_METHOD_CB(list);
- MOCK_METHOD2(listByInterface, R<void>(String, listByInterface_cb));
- MOCK_METHOD3(registerForNotifications,
- R<bool>(String, String, const sp<IServiceNotification> &));
- MOCK_METHOD_CB(debugDump);
- MOCK_METHOD2(registerPassthroughClient, R<void>(String, String));
- MOCK_METHOD_CB(interfaceChain);
- MOCK_METHOD2(debug,
- R<void>(const hidl_handle &, const hidl_vec<hidl_string> &));
- MOCK_METHOD_CB(interfaceDescriptor);
- MOCK_METHOD_CB(getHashChain);
- MOCK_METHOD0(setHalInstrumentation, R<void>());
- MOCK_METHOD2(linkToDeath,
- R<bool>(const sp<hidl_death_recipient> &, uint64_t));
- MOCK_METHOD0(ping, R<void>());
- MOCK_METHOD_CB(getDebugInfo);
- MOCK_METHOD0(notifySyspropsChanged, R<void>());
- MOCK_METHOD1(unlinkToDeath, R<bool>(const sp<hidl_death_recipient> &));
-};
-
-class VtsTestabilityCheckerTest : public ::testing::Test {
- public:
- virtual void SetUp() override {
- test_cm_ = testFrameworkCompMatrix();
- test_fm_ = testFrameworkManfiest();
- test_vm_ = testDeviceManifest();
- sm_ = new NiceMock<MockServiceManager>();
- checker_.reset(
- new VtsTestabilityChecker(&test_cm_, &test_fm_, &test_vm_, sm_));
- }
- virtual void TearDown() override {}
-
- HalManifest testDeviceManifest() {
- HalManifest vm;
- string xml =
- "<manifest version=\"1.0\" type=\"framework\">\n"
- " <hal format=\"hidl\">\n"
- " <name>android.hardware.audio</name>\n"
- " <transport arch=\"32\">passthrough</transport>\n"
- " <version>2.0</version>\n"
- " <interface>\n"
- " <name>IAudio</name>\n"
- " <instance>default</instance>\n"
- " </interface>\n"
- " </hal>\n"
- " <hal format=\"hidl\">\n"
- " <name>android.hardware.camera</name>\n"
- " <transport>hwbinder</transport>\n"
- " <version>1.2</version>\n"
- " <version>2.5</version>\n"
- " <interface>\n"
- " <name>ICamera</name>\n"
- " <instance>legacy/0</instance>\n"
- " </interface>\n"
- " <interface>\n"
- " <name>IBetterCamera</name>\n"
- " <instance>camera</instance>\n"
- " <instance>default</instance>\n"
- " </interface>\n"
- " </hal>\n"
- " <hal format=\"hidl\">\n"
- " <name>android.hardware.drm</name>\n"
- " <transport>hwbinder</transport>\n"
- " <version>2.0</version>\n"
- " <interface>\n"
- " <name>IDrm</name>\n"
- " <instance>default</instance>\n"
- " </interface>\n"
- " </hal>\n"
- " <hal format=\"hidl\">\n"
- " <name>android.hardware.nfc</name>\n"
- " <transport>hwbinder</transport>\n"
- " <version>1.0</version>\n"
- " <interface>\n"
- " <name>INfc</name>\n"
- " <instance>default</instance>\n"
- " </interface>\n"
- " </hal>\n"
- " <hal format=\"hidl\">\n"
- " <name>android.hardware.renderscript</name>\n"
- " <transport arch=\"32+64\">passthrough</transport>\n"
- " <version>1.0</version>\n"
- " <interface>\n"
- " <name>IRenderscript</name>\n"
- " <instance>default</instance>\n"
- " </interface>\n"
- " </hal>\n"
- " <hal format=\"hidl\">\n"
- " <name>android.hardware.vibrator</name>\n"
- " <transport>hwbinder</transport>\n"
- " <version>1.0</version>\n"
- " <interface>\n"
- " <name>IVibrator</name>\n"
- " <instance>default</instance>\n"
- " </interface>\n"
- " </hal>\n"
- "</manifest>\n";
- EXPECT_TRUE(fromXml(&vm, xml));
- return vm;
- }
-
- HalManifest testFrameworkManfiest() {
- HalManifest fm;
- string xml =
- "<manifest version=\"1.0\" type=\"framework\">\n"
- " <hal format=\"hidl\">\n"
- " <name>android.hardware.nfc</name>\n"
- " <transport>hwbinder</transport>\n"
- " <version>1.0</version>\n"
- " <interface>\n"
- " <name>INfc</name>\n"
- " <instance>default</instance>\n"
- " <instance>fnfc</instance>\n"
- " </interface>\n"
- " </hal>\n"
- "</manifest>\n";
- EXPECT_TRUE(fromXml(&fm, xml));
- return fm;
- }
-
- CompatibilityMatrix testFrameworkCompMatrix() {
- CompatibilityMatrix cm;
- string xml =
- "<compatibility-matrix version=\"1.0\" type=\"framework\">\n"
- " <hal format=\"native\" optional=\"true\">\n"
- " <name>android.hardware.audio</name>\n"
- " <version>2.0-1</version>\n"
- " <interface>\n"
- " <name>IAudio</name>\n"
- " <instance>default</instance>\n"
- " </interface>\n"
- " </hal>\n"
- " <hal format=\"native\" optional=\"true\">\n"
- " <name>android.hardware.camera</name>\n"
- " <version>2.2-3</version>\n"
- " <version>4.5-6</version>\n"
- " <interface>\n"
- " <name>ICamera</name>\n"
- " <instance>default</instance>\n"
- " </interface>\n"
- " <interface>\n"
- " <name>IBetterCamera</name>\n"
- " <instance>camera</instance>\n"
- " </interface>\n"
- " </hal>\n"
- " <hal format=\"native\" optional=\"false\">\n"
- " <name>android.hardware.drm</name>\n"
- " <version>1.0-1</version>\n"
- " <interface>\n"
- " <name>IDrm</name>\n"
- " <instance>default</instance>\n"
- " <instance>drm</instance>\n"
- " </interface>\n"
- " <interface>\n"
- " <name>IDrmTest</name>\n"
- " <instance>default</instance>\n"
- " </interface>\n"
- " </hal>\n"
- " <hal format=\"native\" optional=\"false\">\n"
- " <name>android.hardware.light</name>\n"
- " <version>2.0-1</version>\n"
- " <interface>\n"
- " <name>ILight</name>\n"
- " <instance>default</instance>\n"
- " </interface>\n"
- " </hal>\n"
- " <hal format=\"native\" optional=\"true\">\n"
- " <name>android.hardware.nfc</name>\n"
- " <version>1.0-2</version>\n"
- " <interface>\n"
- " <name>INfc</name>\n"
- " <instance>default</instance>\n"
- " <instance>nfc</instance>\n"
- " </interface>\n"
- " <interface>\n"
- " <name>INfcTest</name>\n"
- " <instance>default</instance>\n"
- " </interface>\n"
- " </hal>\n"
- " <hal format=\"native\" optional=\"true\">\n"
- " <name>android.hardware.radio</name>\n"
- " <version>1.0-1</version>\n"
- " <interface>\n"
- " <name>IRadio</name>\n"
- " <instance>default</instance>\n"
- " </interface>\n"
- " </hal>\n"
- " <hal format=\"native\" optional=\"false\">\n"
- " <name>android.hardware.vibrator</name>\n"
- " <version>2.0</version>\n"
- " <interface>\n"
- " <name>IVibrator</name>\n"
- " <instance>default</instance>\n"
- " </interface>\n"
- " </hal>\n"
- "</compatibility-matrix>\n";
- EXPECT_TRUE(fromXml(&cm, xml));
- return cm;
- }
-
- protected:
- CompatibilityMatrix test_cm_;
- HalManifest test_fm_;
- HalManifest test_vm_;
- sp<MockServiceManager> sm_;
- std::unique_ptr<VtsTestabilityChecker> checker_;
-};
-
-TEST_F(VtsTestabilityCheckerTest, CheckComplianceTest) {
- set<string> instances;
- // Check non-existent hal.
- EXPECT_FALSE(checker_->CheckHalForComplianceTest(
- "nonexistent", {1, 0}, "None", Arch::ARCH_32, &instances));
- EXPECT_TRUE(instances.empty());
- // Check hal with unsupported version by vendor.
- EXPECT_FALSE(checker_->CheckHalForComplianceTest(
- "android.hardware.nfc", {2, 0}, "INfc", Arch::ARCH_32, &instances));
- EXPECT_TRUE(instances.empty());
- // Check hal with unsupported interface by vendor.
- EXPECT_FALSE(checker_->CheckHalForComplianceTest(
- "android.hardware.nfc", {1, 0}, "INfcTest", Arch::ARCH_32, &instances));
- EXPECT_TRUE(instances.empty());
- // Check hal with unsupported arch by vendor.
- EXPECT_FALSE(checker_->CheckHalForComplianceTest(
- "android.hardware.audio", {1, 0}, "IAudio", Arch::ARCH_64, &instances));
- EXPECT_TRUE(instances.empty());
- // Check hal claimed by framework but not supported by vendor (error case).
- EXPECT_FALSE(checker_->CheckHalForComplianceTest(
- "android.hardware.light", {2, 0}, "ILight", Arch::ARCH_32, &instances));
- EXPECT_TRUE(instances.empty());
- // Check hal interface claimed by framework but not supported by vendor (error
- // case).
- EXPECT_FALSE(checker_->CheckHalForComplianceTest(
- "android.hardware.drm", {1, 0}, "IDrmTest", Arch::ARCH_32, &instances));
- EXPECT_TRUE(instances.empty());
-
- // Check hal claimed by framework and supported by vendor.
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForComplianceTest("android.hardware.vibrator",
- {1, 0}, "IVibrator",
- Arch::ARCH_32, &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
-
- // Check hal not claimed by framework but supported by vendor.
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForComplianceTest(
- "android.hardware.renderscript", {1, 0}, "IRenderscript", Arch::ARCH_32,
- &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
-
- // Check hal with version not claimed by framework by supported by vendor.
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForComplianceTest("android.hardware.vibrator",
- {1, 0}, "IVibrator",
- Arch::ARCH_32, &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
-
- // Check hal with instance not claimed by framework but supported by vendor.
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForComplianceTest(
- "android.hardware.camera", {2, 2}, "ICamera", Arch::ARCH_32, &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"legacy/0"})));
-
- // Check hal with additional vendor instance not claimed by framework.
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForComplianceTest("android.hardware.camera",
- {1, 2}, "IBetterCamera",
- Arch::ARCH_32, &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default", "camera"})));
-
- // Check hal supported by both framework and vendor.
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForComplianceTest(
- "android.hardware.nfc", {1, 0}, "INfc", Arch::ARCH_32, &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default", "fnfc"})));
-
- // Check hal instance claimed by framework but not supported by vendor.
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForComplianceTest(
- "android.hardware.drm", {2, 0}, "IDrm", Arch::ARCH_32, &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
-
- // Check an optional hal with empty interface (legacy input).
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForComplianceTest(
- "android.hardware.vibrator", {1, 0}, "" /*interface*/, Arch::ARCH_EMPTY,
- &instances));
- EXPECT_TRUE(instances.empty());
-}
-
-TEST_F(VtsTestabilityCheckerTest, CheckNonComplianceTest) {
- set<string> instances;
- ON_CALL(*sm_, listByInterface(_, _))
- .WillByDefault(
- Invoke([](hidl_string str, IServiceManager::listByInterface_cb cb) {
- if (str == "android.hardware.foo@1.0::IFoo") {
- cb({"default", "footest"});
- } else if (str == "android.hardware.nfc@3.0::INfc") {
- cb({"default"});
- } else if (str == "android.hardware.drm@2.0::IDrm") {
- cb({"drmtest"});
- }
- return hardware::Void();
- }));
-
- ON_CALL(*sm_, list(_)).WillByDefault(Invoke([](IServiceManager::list_cb cb) {
- cb({"android.hardware.foo@1.0::IFoo/default",
- "android.hardware.foo@1.0::IFoo/footest",
- "android.hardware.nfc@3.0::INfc/default",
- "android.hardware.drm@2.0::IDrm/drmtest"});
- return hardware::Void();
- }));
-
- // Check non-existent hal.
- EXPECT_FALSE(checker_->CheckHalForNonComplianceTest(
- "non-existent", {1, 0}, "None", Arch::ARCH_32, &instances));
- EXPECT_TRUE(instances.empty());
- // Check hal with unsupported version by vendor.
- EXPECT_FALSE(checker_->CheckHalForNonComplianceTest(
- "android.hardware.nfc", {2, 0}, "INfc", Arch::ARCH_32, &instances));
- EXPECT_TRUE(instances.empty());
- // Check hal with unsupported interface by vendor.
- EXPECT_FALSE(checker_->CheckHalForNonComplianceTest(
- "android.hardware.nfc", {1, 0}, "INfcTest", Arch::ARCH_32, &instances));
- EXPECT_TRUE(instances.empty());
- // Check hal with unsupported arch by vendor.
- EXPECT_FALSE(checker_->CheckHalForNonComplianceTest(
- "android.hardware.audio", {1, 0}, "IAudio", Arch::ARCH_64, &instances));
- EXPECT_TRUE(instances.empty());
- // Check hal claimed by framework but not supported by vendor (error case).
- EXPECT_FALSE(checker_->CheckHalForNonComplianceTest(
- "android.hardware.light", {2, 0}, "ILight", Arch::ARCH_32, &instances));
- EXPECT_TRUE(instances.empty());
- // Check hal interface claimed by framework but not supported by vendor (error
- // case).
- EXPECT_FALSE(checker_->CheckHalForNonComplianceTest(
- "android.hardware.drm", {1, 0}, "IDrmTest", Arch::ARCH_32, &instances));
- EXPECT_TRUE(instances.empty());
-
- // Check hal claimed by framework and supported by vendor.
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
- "android.hardware.vibrator", {1, 0}, "IVibrator", Arch::ARCH_32,
- &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
-
- // Check hal not claimed by framework but supported by vendor.
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
- "android.hardware.renderscript", {1, 0}, "IRenderscript", Arch::ARCH_32,
- &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
-
- // Check hal with version not claimed by framework by supported by vendor.
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
- "android.hardware.vibrator", {1, 0}, "IVibrator", Arch::ARCH_32,
- &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
-
- // Check hal with instance not claimed by framework but supported by vendor.
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
- "android.hardware.camera", {2, 2}, "ICamera", Arch::ARCH_32, &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"legacy/0"})));
-
- // Check hal with additional vendor instance not claimed by framework.
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
- "android.hardware.camera", {1, 2}, "IBetterCamera", Arch::ARCH_32,
- &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default", "camera"})));
-
- // Check hal supported by both framework and vendor.
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
- "android.hardware.nfc", {1, 0}, "INfc", Arch::ARCH_32, &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
-
- // Check an optional hal with empty interface (legacy input).
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
- "android.hardware.vibrator", {1, 0}, "" /*interface*/, Arch::ARCH_EMPTY,
- &instances));
- EXPECT_TRUE(instances.empty());
-
- // Check hal only registered with hwmanger.
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
- "android.hardware.foo", {1, 0}, "IFoo", Arch::ARCH_EMPTY, &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default", "footest"})));
-
- // Check hal with version only registered with hwmanger.
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
- "android.hardware.nfc", {3, 0}, "INfc", Arch::ARCH_EMPTY, &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
-
- // Check hal with additional instance registered with hwmanger.
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
- "android.hardware.drm", {2, 0}, "IDrm", Arch::ARCH_EMPTY, &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default", "drmtest"})));
-
- instances.clear();
- EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
- "android.hardware.foo", {1, 0}, "", Arch::ARCH_EMPTY, &instances));
- EXPECT_TRUE(instances.empty());
-}
-
-TEST_F(VtsTestabilityCheckerTest, CheckFrameworkCompatibleHalOptional) {
- set<string> instances;
- // Check non-existent hal.
- EXPECT_FALSE(checker_->CheckFrameworkCompatibleHal(
- "nonexistent", {1, 0}, "None", Arch::ARCH_EMPTY, &instances));
- EXPECT_TRUE(instances.empty());
-
- // Check hal not required by framework
- EXPECT_FALSE(checker_->CheckFrameworkCompatibleHal(
- "android.hardware.renderscript", {1, 0}, "IRenderscript",
- Arch::ARCH_EMPTY, &instances));
- EXPECT_TRUE(instances.empty());
-
- // Check hal with unsupported version.
- EXPECT_FALSE(checker_->CheckFrameworkCompatibleHal(
- "android.hardware.camera", {1, 0}, "ICamera", Arch::ARCH_EMPTY,
- &instances));
- EXPECT_TRUE(instances.empty());
-
- // Check hal with non-existent interface.
- EXPECT_FALSE(checker_->CheckFrameworkCompatibleHal(
- "android.hardware.camera", {1, 2}, "None", Arch::ARCH_EMPTY, &instances));
- EXPECT_TRUE(instances.empty());
-
- // Check an optional hal not supported by vendor.
- EXPECT_FALSE(checker_->CheckFrameworkCompatibleHal(
- "android.hardware.radio", {1, 0}, "IRadio", Arch::ARCH_EMPTY,
- &instances));
- EXPECT_TRUE(instances.empty());
-
- // Check an optional hal with version not supported by vendor.
- EXPECT_FALSE(checker_->CheckFrameworkCompatibleHal(
- "android.hardware.camera", {4, 5}, "ICamera", Arch::ARCH_EMPTY,
- &instances));
- EXPECT_TRUE(instances.empty());
-
- // Check an optional hal with interface not supported by vendor.
- EXPECT_FALSE(checker_->CheckFrameworkCompatibleHal(
- "android.hardware.nfc", {4, 5}, "INfcTest", Arch::ARCH_EMPTY,
- &instances));
- EXPECT_TRUE(instances.empty());
-
- // Check an option passthrough hal with unsupported arch.
- EXPECT_FALSE(checker_->CheckFrameworkCompatibleHal(
- "android.hardware.audio", {2, 0}, "IAudio", Arch::ARCH_64, &instances));
- EXPECT_TRUE(instances.empty());
-
- // Check an optional hal supported by vendor but with no compatible
- // instance.
- EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal(
- "android.hardware.camera", {2, 2}, "ICamera", Arch::ARCH_EMPTY,
- &instances));
- EXPECT_TRUE(instances.empty());
-
- // Check an optional hal supported by vendor.
- instances.clear();
- EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal(
- "android.hardware.camera", {2, 2}, "IBetterCamera", Arch::ARCH_EMPTY,
- &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"camera"})));
-
- // Check an optional passthrough hal supported by vendor.
- instances.clear();
- EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal(
- "android.hardware.audio", {2, 0}, "IAudio", Arch::ARCH_32, &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
-
- // Check an optional hal with empty interface (legacy input).
- instances.clear();
- EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal(
- "android.hardware.camera", {2, 2}, "" /*interface*/, Arch::ARCH_EMPTY,
- &instances));
- EXPECT_TRUE(instances.empty());
-}
-
-TEST_F(VtsTestabilityCheckerTest, CheckFrameworkCompatibleHalRequired) {
- set<string> instances;
- // Check a required hal not supported by vendor.
- EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal(
- "android.hardware.light", {2, 0}, "ILight", Arch::ARCH_32, &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
-
- // Check a required hal with version not supported by vendor.
- instances.clear();
- EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal("android.hardware.vibrator",
- {2, 0}, "IVibrator",
- Arch::ARCH_32, &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
-
- // Check a required hal with interface not supported by vendor.
- instances.clear();
- EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal(
- "android.hardware.drm", {1, 0}, "IDrmTest", Arch::ARCH_32, &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
-
- // Check a required hal supported by vendor.
- instances.clear();
- EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal(
- "android.hardware.drm", {1, 0}, "IDrm", Arch::ARCH_32, &instances));
- EXPECT_THAT(instances, ContainerEq(set<string>({"default", "drm"})));
-
- // Check an optional hal with empty interface (legacy input).
- instances.clear();
- EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal(
- "android.hardware.vibrator", {2, 0}, "" /*interface*/, Arch::ARCH_EMPTY,
- &instances));
- EXPECT_TRUE(instances.empty());
-}
-
-} // namespace vts
-} // namespace android
-
-int main(int argc, char **argv) {
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/utils/python/hal/__init__.py b/utils/python/hal/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/hal/__init__.py
+++ /dev/null
diff --git a/utils/python/hal/hal_service_name_utils.py b/utils/python/hal/hal_service_name_utils.py
deleted file mode 100644
index 4cdd473..0000000
--- a/utils/python/hal/hal_service_name_utils.py
+++ /dev/null
@@ -1,172 +0,0 @@
-#
-# Copyright (C) 2017 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 json
-import logging
-
-from vts.runners.host import asserts
-from vts.runners.host import const
-
-VTS_TESTABILITY_CHECKER_32 = "/data/local/tmp/vts_testability_checker32"
-VTS_TESTABILITY_CHECKER_64 = "/data/local/tmp/vts_testability_checker64"
-
-
-def GetHalServiceName(shell, hal, bitness="64", run_as_compliance_test=False):
- """Determine whether to run a VTS test against a HAL and get the service
- names of the given hal if determine to run.
-
- Args:
- shell: the ShellMirrorObject to execute command on the device.
- hal: string, the FQName of a HAL service, e.g.,
- android.hardware.foo@1.0::IFoo
- bitness: string, the bitness of the test.
- run_as_compliance_test: boolean, whether it is a compliance test.
-
- Returns:
- a boolean whether to run the test against the given hal.
- a set containing all service names for the given HAL.
- """
-
- binary = VTS_TESTABILITY_CHECKER_64
- if bitness == "32":
- binary = VTS_TESTABILITY_CHECKER_32
- # Give permission to execute the binary.
- shell.Execute("chmod 755 %s" % binary)
- cmd = binary
- if run_as_compliance_test:
- cmd += " -c "
- cmd += " -b " + bitness + " " + hal
- cmd_results = shell.Execute(str(cmd))
- asserts.assertFalse(
- any(cmd_results[const.EXIT_CODE]),
- "Failed to run vts_testability_checker. ErrorCode: %s\n STDOUT: %s\n STDERR: %s\n"
- % (cmd_results[const.EXIT_CODE][0], cmd_results[const.STDOUT][0],
- cmd_results[const.STDERR][0]))
- result = json.loads(cmd_results[const.STDOUT][0])
- if str(result['Testable']).lower() == "true":
- return True, set(result['instances'])
- else:
- return False, ()
-
-
-class CombMode(object):
- """Enum for service name combination mode"""
- FULL_PERMUTATION = 0
- NAME_MATCH = 1
- NO_COMBINATION = 2
-
-
-def GetServiceInstancesCombinations(services,
- service_instances,
- mode=CombMode.FULL_PERMUTATION):
- """Create combinations of instances for all services.
-
- Args:
- services: list, all services used in the test. e.g. [s1, s2]
- service_instances: dictionary, mapping of each service and the
- corresponding service name(s).
- e.g. {"s1": ["n1"], "s2": ["n2", "n3"]}
- mode: CombMode that determines the combination strategy.
-
- Returns:
- A list of service instance combinations.
- """
- if mode == CombMode.FULL_PERMUTATION:
- return GetServiceInstancesFullCombinations(services, service_instances)
- elif mode == CombMode.NAME_MATCH:
- return GetServiceInstancesNameMatchCombinations(
- services, service_instances)
- else:
- logging.warning("Unknown comb mode, use default comb mode instead.")
- return GetServiceInstancesFullCombinations(services, service_instances)
-
-
-def GetServiceInstancesFullCombinations(services, service_instances):
- """Create all combinations of instances for all services.
-
- Create full permutation for registered service instances, e.g.
- s1 have instances (n1, n2) and s2 have instances (n3, n4), return all
- permutations of s1 and s2, i.e. (s1/n1, s2/n3), (s1/n1, s2/n4),
- (s1/n2, s2/n3) and (s1/n2, s2/n4)
-
- Args:
- services: list, all services used in the test. e.g. [s1, s2]
- service_instances: dictionary, mapping of each service and the
- corresponding service name(s).
- e.g. {"s1": ["n1"], "s2": ["n2", "n3"]}
-
- Returns:
- A list of all service instance combinations.
- e.g. [[s1/n1, s2/n2], [s1/n1, s2/n3]]
- """
- service_instance_combinations = []
- if not services or (service_instances and type(service_instances) != dict):
- return service_instance_combinations
- service = services.pop()
- pre_instance_combs = GetServiceInstancesCombinations(
- services, service_instances)
- if service not in service_instances or not service_instances[service]:
- return pre_instance_combs
- for name in service_instances[service]:
- if not pre_instance_combs:
- new_instance_comb = [service + '/' + name]
- service_instance_combinations.append(new_instance_comb)
- else:
- for instance_comb in pre_instance_combs:
- new_instance_comb = [service + '/' + name]
- new_instance_comb.extend(instance_comb)
- service_instance_combinations.append(new_instance_comb)
-
- return service_instance_combinations
-
-
-def GetServiceInstancesNameMatchCombinations(services, service_instances):
- """Create service instance combinations with same name for services.
-
- Create combinations for services with the same instance name, e.g.
- both s1 and s2 have two instances with name n1, and n2, return
- the service instance combination of s1 and s2 with same instance name,
- i.e. (s1/n1, s2/n1) and (s1/n2, s2/n2)
-
- Args:
- services: list, all services used in the test. e.g. [s1, s2]
- service_instances: dictionary, mapping of each service and the
- corresponding service name(s).
- e.g. {"s1": ["n1", "n2"], "s2": ["n1", "n2"]}
-
- Returns:
- A list of service instance combinations.
- e.g. [[s1/n1, s2/n1], [s1/n2, s2/n2]]
- """
- service_instance_combinations = []
- instance_names = set()
- for service in services:
- if service not in service_instances or not service_instances[service]:
- logging.error("Does not found instance for service: %s", service)
- return []
- if not instance_names:
- instance_names = set(service_instances[service])
- else:
- instance_names.intersection_update(set(service_instances[service]))
-
- for name in instance_names:
- instance_comb = []
- for service in services:
- new_instance = [service + '/' + name]
- instance_comb.extend(new_instance)
- service_instance_combinations.append(instance_comb)
-
- return service_instance_combinations
diff --git a/utils/python/hal/hal_service_name_utils_unittest.py b/utils/python/hal/hal_service_name_utils_unittest.py
deleted file mode 100644
index 71f017d..0000000
--- a/utils/python/hal/hal_service_name_utils_unittest.py
+++ /dev/null
@@ -1,106 +0,0 @@
-#
-# Copyright (C) 2017 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 unittest
-
-from vts.utils.python.hal import hal_service_name_utils
-
-
-class HalServiceNameUtilsUnitTest(unittest.TestCase):
- """Tests for hal hidl gtest template"""
-
- def testGetServiceInstancesFullCombinations(self):
- """Test the function to get service instance combinations"""
-
- comb1 = hal_service_name_utils.GetServiceInstancesCombinations([], {})
- self.assertEquals(0, len(comb1))
- comb2 = hal_service_name_utils.GetServiceInstancesCombinations(["s1"],
- {})
- self.assertEquals(0, len(comb2))
- comb3 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1"], {"s1": ["n1"]})
- self.assertEqual([["s1/n1"]], comb3)
- comb4 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1"], {"s1": ["n1", "n2"]})
- self.assertEqual([["s1/n1"], ["s1/n2"]], comb4)
- comb5 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1", "s2"], {"s1": ["n1", "n2"]})
- self.assertEqual([["s1/n1"], ["s1/n2"]], comb5)
- comb6 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1", "s2"], {"s1": ["n1", "n2"],
- "s2": ["n3"]})
- self.assertEqual([["s2/n3", "s1/n1"], ["s2/n3", "s1/n2"]], comb6)
- comb7 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1", "s2"], {"s1": ["n1", "n2"],
- "s2": ["n3", "n4"]})
- self.assertEqual([["s2/n3", "s1/n1"], ["s2/n3", "s1/n2"],
- ["s2/n4", "s1/n1"], ["s2/n4", "s1/n2"]], comb7)
- comb8 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1", "s2"], {"s1": ["n1", "n2"],
- "s2": []})
- self.assertEqual([["s1/n1"], ["s1/n2"]], comb8)
- comb9 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1", "s2"], {"s1": [],
- "s2": ["n1", "n2"]})
- self.assertEqual([["s2/n1"], ["s2/n2"]], comb9)
-
- def testGetServiceInstancesNameMatchCombinations(self):
- """Test the function to get service instance combinations"""
-
- mode = hal_service_name_utils.CombMode.NAME_MATCH
- comb1 = hal_service_name_utils.GetServiceInstancesCombinations([], {},
- mode)
- self.assertEquals(0, len(comb1))
- comb2 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1"], {}, mode)
- self.assertEquals(0, len(comb2))
- comb3 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1"], {"s1": ["n1"]}, mode)
- #self.assertEqual([["s1/n1"]], comb3)
- comb4 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1"], {"s1": ["n1", "n2"]}, mode)
- self.assertEqual([["s1/n1"], ["s1/n2"]], comb4)
- comb5 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1", "s2"], {"s1": ["n1", "n2"]}, mode)
- self.assertEqual(0, len(comb5))
- comb6 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1", "s2"], {"s1": ["n1", "n2"],
- "s2": ["n3"]}, mode)
- self.assertEqual(0, len(comb6))
- comb7 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1", "s2"], {"s1": ["n1", "n2"],
- "s2": ["n3", "n4"]}, mode)
- self.assertEqual(0, len(comb7))
- comb8 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1", "s2"], {"s1": ["n1", "n2"],
- "s2": []}, mode)
- self.assertEqual(0, len(comb8))
- comb9 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1", "s2"], {"s1": [],
- "s2": ["n1", "n2"]}, mode)
- self.assertEqual(0, len(comb9))
- comb10 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1", "s2"], {"s1": ["n1"],
- "s2": ["n1", "n2"]}, mode)
- self.assertEqual([["s1/n1", "s2/n1"]], comb10)
- comb11 = hal_service_name_utils.GetServiceInstancesCombinations(
- ["s1", "s2"], {"s1": ["n1", "n2"],
- "s2": ["n1", "n2"]}, mode)
- self.assertEqual([["s1/n1", "s2/n1"], ["s1/n2", "s2/n2"]], comb11)
-
-
-if __name__ == '__main__':
- unittest.main()