Home | History | Annotate | Download | only in testability_checker
      1 /*
      2  * Copyright (C) 2017 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 #include "VtsTestabilityChecker.h"
     17 
     18 #include <gmock/gmock.h>
     19 #include <gtest/gtest.h>
     20 
     21 #include <vintf/CompatibilityMatrix.h>
     22 #include <vintf/HalManifest.h>
     23 #include <vintf/parse_xml.h>
     24 
     25 using namespace testing;
     26 
     27 using android::hidl::base::V1_0::IBase;
     28 using android::hidl::manager::V1_0::IServiceManager;
     29 using android::hidl::manager::V1_0::IServiceNotification;
     30 using android::hardware::hidl_array;
     31 using android::hardware::hidl_death_recipient;
     32 using android::hardware::hidl_handle;
     33 using android::hardware::hidl_string;
     34 using android::hardware::hidl_vec;
     35 using android::vintf::Arch;
     36 using android::vintf::CompatibilityMatrix;
     37 using android::vintf::HalManifest;
     38 using android::vintf::ManifestHal;
     39 using android::vintf::MatrixHal;
     40 using android::vintf::Version;
     41 using android::vintf::XmlConverter;
     42 using android::vintf::gCompatibilityMatrixConverter;
     43 using android::vintf::gHalManifestConverter;
     44 using std::set;
     45 using std::string;
     46 
     47 namespace android {
     48 namespace vts {
     49 
     50 class MockServiceManager : public IServiceManager {
     51  public:
     52   template <typename T>
     53   using R = ::android::hardware::Return<T>;
     54   using String = const hidl_string &;
     55   ~MockServiceManager() = default;
     56 
     57 #define MOCK_METHOD_CB(name) \
     58   MOCK_METHOD1(name, R<void>(IServiceManager::name##_cb))
     59 
     60   MOCK_METHOD2(get, R<sp<IBase>>(String, String));
     61   MOCK_METHOD2(add, R<bool>(String, const sp<IBase> &));
     62   MOCK_METHOD2(getTransport, R<IServiceManager::Transport>(String, String));
     63   MOCK_METHOD_CB(list);
     64   MOCK_METHOD2(listByInterface, R<void>(String, listByInterface_cb));
     65   MOCK_METHOD3(registerForNotifications,
     66                R<bool>(String, String, const sp<IServiceNotification> &));
     67   MOCK_METHOD_CB(debugDump);
     68   MOCK_METHOD2(registerPassthroughClient, R<void>(String, String));
     69   MOCK_METHOD_CB(interfaceChain);
     70   MOCK_METHOD2(debug,
     71                R<void>(const hidl_handle &, const hidl_vec<hidl_string> &));
     72   MOCK_METHOD_CB(interfaceDescriptor);
     73   MOCK_METHOD_CB(getHashChain);
     74   MOCK_METHOD0(setHalInstrumentation, R<void>());
     75   MOCK_METHOD2(linkToDeath,
     76                R<bool>(const sp<hidl_death_recipient> &, uint64_t));
     77   MOCK_METHOD0(ping, R<void>());
     78   MOCK_METHOD_CB(getDebugInfo);
     79   MOCK_METHOD0(notifySyspropsChanged, R<void>());
     80   MOCK_METHOD1(unlinkToDeath, R<bool>(const sp<hidl_death_recipient> &));
     81 };
     82 
     83 class VtsTestabilityCheckerTest : public ::testing::Test {
     84  public:
     85   virtual void SetUp() override {
     86     test_cm_ = testFrameworkCompMatrix();
     87     test_fm_ = testFrameworkManfiest();
     88     test_vm_ = testDeviceManifest();
     89     sm_ = new NiceMock<MockServiceManager>();
     90     checker_.reset(
     91         new VtsTestabilityChecker(&test_cm_, &test_fm_, &test_vm_, sm_));
     92   }
     93   virtual void TearDown() override {}
     94 
     95   HalManifest testDeviceManifest() {
     96     HalManifest vm;
     97     string xml =
     98         "<manifest version=\"1.0\" type=\"framework\">\n"
     99         "    <hal format=\"hidl\">\n"
    100         "        <name>android.hardware.audio</name>\n"
    101         "        <transport arch=\"32\">passthrough</transport>\n"
    102         "        <version>2.0</version>\n"
    103         "        <interface>\n"
    104         "            <name>IAudio</name>\n"
    105         "            <instance>default</instance>\n"
    106         "        </interface>\n"
    107         "    </hal>\n"
    108         "    <hal format=\"hidl\">\n"
    109         "        <name>android.hardware.camera</name>\n"
    110         "        <transport>hwbinder</transport>\n"
    111         "        <version>1.2</version>\n"
    112         "        <version>2.5</version>\n"
    113         "        <interface>\n"
    114         "            <name>ICamera</name>\n"
    115         "            <instance>legacy/0</instance>\n"
    116         "        </interface>\n"
    117         "        <interface>\n"
    118         "            <name>IBetterCamera</name>\n"
    119         "            <instance>camera</instance>\n"
    120         "            <instance>default</instance>\n"
    121         "        </interface>\n"
    122         "    </hal>\n"
    123         "    <hal format=\"hidl\">\n"
    124         "        <name>android.hardware.drm</name>\n"
    125         "        <transport>hwbinder</transport>\n"
    126         "        <version>2.0</version>\n"
    127         "        <interface>\n"
    128         "            <name>IDrm</name>\n"
    129         "            <instance>default</instance>\n"
    130         "        </interface>\n"
    131         "    </hal>\n"
    132         "    <hal format=\"hidl\">\n"
    133         "        <name>android.hardware.nfc</name>\n"
    134         "        <transport>hwbinder</transport>\n"
    135         "        <version>1.0</version>\n"
    136         "        <interface>\n"
    137         "            <name>INfc</name>\n"
    138         "            <instance>default</instance>\n"
    139         "        </interface>\n"
    140         "    </hal>\n"
    141         "    <hal format=\"hidl\">\n"
    142         "        <name>android.hardware.renderscript</name>\n"
    143         "        <transport arch=\"32+64\">passthrough</transport>\n"
    144         "        <version>1.0</version>\n"
    145         "        <interface>\n"
    146         "            <name>IRenderscript</name>\n"
    147         "            <instance>default</instance>\n"
    148         "        </interface>\n"
    149         "    </hal>\n"
    150         "    <hal format=\"hidl\">\n"
    151         "        <name>android.hardware.vibrator</name>\n"
    152         "        <transport>hwbinder</transport>\n"
    153         "        <version>1.0</version>\n"
    154         "        <interface>\n"
    155         "            <name>IVibrator</name>\n"
    156         "            <instance>default</instance>\n"
    157         "        </interface>\n"
    158         "    </hal>\n"
    159         "</manifest>\n";
    160     gHalManifestConverter(&vm, xml);
    161     return vm;
    162   }
    163 
    164   HalManifest testFrameworkManfiest() {
    165     HalManifest fm;
    166     string xml =
    167         "<manifest version=\"1.0\" type=\"framework\">\n"
    168         "    <hal format=\"hidl\">\n"
    169         "        <name>android.hardware.nfc</name>\n"
    170         "        <transport>hwbinder</transport>\n"
    171         "        <version>1.0</version>\n"
    172         "        <interface>\n"
    173         "            <name>INfc</name>\n"
    174         "            <instance>default</instance>\n"
    175         "            <instance>fnfc</instance>\n"
    176         "        </interface>\n"
    177         "    </hal>\n"
    178         "</manifest>\n";
    179     gHalManifestConverter(&fm, xml);
    180     return fm;
    181   }
    182 
    183   CompatibilityMatrix testFrameworkCompMatrix() {
    184     CompatibilityMatrix cm;
    185     string xml =
    186         "<compatibility-matrix version=\"1.0\" type=\"framework\">\n"
    187         "    <hal format=\"native\" optional=\"true\">\n"
    188         "        <name>android.hardware.audio</name>\n"
    189         "        <version>2.0-1</version>\n"
    190         "        <interface>\n"
    191         "            <name>IAudio</name>\n"
    192         "            <instance>default</instance>\n"
    193         "        </interface>\n"
    194         "    </hal>\n"
    195         "    <hal format=\"native\" optional=\"true\">\n"
    196         "        <name>android.hardware.camera</name>\n"
    197         "        <version>2.2-3</version>\n"
    198         "        <version>4.5-6</version>\n"
    199         "        <interface>\n"
    200         "            <name>ICamera</name>\n"
    201         "            <instance>default</instance>\n"
    202         "        </interface>\n"
    203         "        <interface>\n"
    204         "            <name>IBetterCamera</name>\n"
    205         "            <instance>camera</instance>\n"
    206         "        </interface>\n"
    207         "    </hal>\n"
    208         "    <hal format=\"native\" optional=\"false\">\n"
    209         "        <name>android.hardware.drm</name>\n"
    210         "        <version>1.0-1</version>\n"
    211         "        <interface>\n"
    212         "            <name>IDrm</name>\n"
    213         "            <instance>default</instance>\n"
    214         "            <instance>drm</instance>\n"
    215         "        </interface>\n"
    216         "        <interface>\n"
    217         "            <name>IDrmTest</name>\n"
    218         "            <instance>default</instance>\n"
    219         "        </interface>\n"
    220         "    </hal>\n"
    221         "    <hal format=\"native\" optional=\"false\">\n"
    222         "        <name>android.hardware.light</name>\n"
    223         "        <version>2.0-1</version>\n"
    224         "        <interface>\n"
    225         "            <name>ILight</name>\n"
    226         "            <instance>default</instance>\n"
    227         "        </interface>\n"
    228         "    </hal>\n"
    229         "    <hal format=\"native\" optional=\"true\">\n"
    230         "        <name>android.hardware.nfc</name>\n"
    231         "        <version>1.0-2</version>\n"
    232         "        <interface>\n"
    233         "            <name>INfc</name>\n"
    234         "            <instance>default</instance>\n"
    235         "            <instance>nfc</instance>\n"
    236         "        </interface>\n"
    237         "        <interface>\n"
    238         "            <name>INfcTest</name>\n"
    239         "            <instance>default</instance>\n"
    240         "        </interface>\n"
    241         "    </hal>\n"
    242         "    <hal format=\"native\" optional=\"true\">\n"
    243         "        <name>android.hardware.radio</name>\n"
    244         "        <version>1.0-1</version>\n"
    245         "        <interface>\n"
    246         "            <name>IRadio</name>\n"
    247         "            <instance>default</instance>\n"
    248         "        </interface>\n"
    249         "    </hal>\n"
    250         "    <hal format=\"native\" optional=\"false\">\n"
    251         "        <name>android.hardware.vibrator</name>\n"
    252         "        <version>2.0</version>\n"
    253         "        <interface>\n"
    254         "            <name>IVibrator</name>\n"
    255         "            <instance>default</instance>\n"
    256         "        </interface>\n"
    257         "    </hal>\n"
    258         "</compatibility-matrix>\n";
    259     gCompatibilityMatrixConverter(&cm, xml);
    260     return cm;
    261   }
    262 
    263  protected:
    264   CompatibilityMatrix test_cm_;
    265   HalManifest test_fm_;
    266   HalManifest test_vm_;
    267   sp<MockServiceManager> sm_;
    268   std::unique_ptr<VtsTestabilityChecker> checker_;
    269 };
    270 
    271 TEST_F(VtsTestabilityCheckerTest, CheckComplianceTest) {
    272   set<string> instances;
    273   // Check non-existent hal.
    274   EXPECT_FALSE(checker_->CheckHalForComplianceTest(
    275       "nonexistent", {1, 0}, "None", Arch::ARCH_32, &instances));
    276   EXPECT_TRUE(instances.empty());
    277   // Check hal with unsupported version by vendor.
    278   EXPECT_FALSE(checker_->CheckHalForComplianceTest(
    279       "android.hardware.nfc", {2, 0}, "INfc", Arch::ARCH_32, &instances));
    280   EXPECT_TRUE(instances.empty());
    281   // Check hal with unsupported interface by vendor.
    282   EXPECT_FALSE(checker_->CheckHalForComplianceTest(
    283       "android.hardware.nfc", {1, 0}, "INfcTest", Arch::ARCH_32, &instances));
    284   EXPECT_TRUE(instances.empty());
    285   // Check hal with unsupported arch by vendor.
    286   EXPECT_FALSE(checker_->CheckHalForComplianceTest(
    287       "android.hardware.audio", {1, 0}, "IAudio", Arch::ARCH_64, &instances));
    288   EXPECT_TRUE(instances.empty());
    289   // Check hal claimed by framework but not supported by vendor (error case).
    290   EXPECT_FALSE(checker_->CheckHalForComplianceTest(
    291       "android.hardware.light", {2, 0}, "ILight", Arch::ARCH_32, &instances));
    292   EXPECT_TRUE(instances.empty());
    293   // Check hal interface claimed by framework but not supported by vendor (error
    294   // case).
    295   EXPECT_FALSE(checker_->CheckHalForComplianceTest(
    296       "android.hardware.drm", {1, 0}, "IDrmTest", Arch::ARCH_32, &instances));
    297   EXPECT_TRUE(instances.empty());
    298 
    299   // Check hal claimed by framework and supported by vendor.
    300   instances.clear();
    301   EXPECT_TRUE(checker_->CheckHalForComplianceTest("android.hardware.vibrator",
    302                                                   {1, 0}, "IVibrator",
    303                                                   Arch::ARCH_32, &instances));
    304   EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
    305 
    306   // Check hal not claimed by framework but supported by vendor.
    307   instances.clear();
    308   EXPECT_TRUE(checker_->CheckHalForComplianceTest(
    309       "android.hardware.renderscript", {1, 0}, "IRenderscript", Arch::ARCH_32,
    310       &instances));
    311   EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
    312 
    313   // Check hal with version not claimed by framework by supported by vendor.
    314   instances.clear();
    315   EXPECT_TRUE(checker_->CheckHalForComplianceTest("android.hardware.vibrator",
    316                                                   {1, 0}, "IVibrator",
    317                                                   Arch::ARCH_32, &instances));
    318   EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
    319 
    320   // Check hal with instance not claimed by framework but supported by vendor.
    321   instances.clear();
    322   EXPECT_TRUE(checker_->CheckHalForComplianceTest(
    323       "android.hardware.camera", {2, 2}, "ICamera", Arch::ARCH_32, &instances));
    324   EXPECT_THAT(instances, ContainerEq(set<string>({"legacy/0"})));
    325 
    326   // Check hal with additional vendor instance not claimed by framework.
    327   instances.clear();
    328   EXPECT_TRUE(checker_->CheckHalForComplianceTest("android.hardware.camera",
    329                                                   {1, 2}, "IBetterCamera",
    330                                                   Arch::ARCH_32, &instances));
    331   EXPECT_THAT(instances, ContainerEq(set<string>({"default", "camera"})));
    332 
    333   // Check hal supported by both framework and vendor.
    334   instances.clear();
    335   EXPECT_TRUE(checker_->CheckHalForComplianceTest(
    336       "android.hardware.nfc", {1, 0}, "INfc", Arch::ARCH_32, &instances));
    337   EXPECT_THAT(instances, ContainerEq(set<string>({"default", "fnfc"})));
    338 
    339   // Check hal instance claimed by framework but not supported by vendor.
    340   instances.clear();
    341   EXPECT_TRUE(checker_->CheckHalForComplianceTest(
    342       "android.hardware.drm", {2, 0}, "IDrm", Arch::ARCH_32, &instances));
    343   EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
    344 
    345   // Check an optional hal with empty interface (legacy input).
    346   instances.clear();
    347   EXPECT_TRUE(checker_->CheckHalForComplianceTest(
    348       "android.hardware.vibrator", {1, 0}, "" /*interface*/, Arch::ARCH_EMPTY,
    349       &instances));
    350   EXPECT_TRUE(instances.empty());
    351 }
    352 
    353 TEST_F(VtsTestabilityCheckerTest, CheckNonComplianceTest) {
    354   set<string> instances;
    355   ON_CALL(*sm_, listByInterface(_, _))
    356       .WillByDefault(
    357           Invoke([](hidl_string str, IServiceManager::listByInterface_cb cb) {
    358             if (str == "android.hardware.foo (at) 1.0::IFoo") {
    359               cb({"default", "footest"});
    360             } else if (str == "android.hardware.nfc (at) 3.0::INfc") {
    361               cb({"default"});
    362             } else if (str == "android.hardware.drm (at) 2.0::IDrm") {
    363               cb({"drmtest"});
    364             }
    365             return hardware::Void();
    366           }));
    367 
    368   ON_CALL(*sm_, list(_)).WillByDefault(Invoke([](IServiceManager::list_cb cb) {
    369     cb({"android.hardware.foo (at) 1.0::IFoo/default",
    370         "android.hardware.foo (at) 1.0::IFoo/footest",
    371         "android.hardware.nfc (at) 3.0::INfc/default",
    372         "android.hardware.drm (at) 2.0::IDrm/drmtest"});
    373     return hardware::Void();
    374   }));
    375 
    376   // Check non-existent hal.
    377   EXPECT_FALSE(checker_->CheckHalForNonComplianceTest(
    378       "non-existent", {1, 0}, "None", Arch::ARCH_32, &instances));
    379   EXPECT_TRUE(instances.empty());
    380   // Check hal with unsupported version by vendor.
    381   EXPECT_FALSE(checker_->CheckHalForNonComplianceTest(
    382       "android.hardware.nfc", {2, 0}, "INfc", Arch::ARCH_32, &instances));
    383   EXPECT_TRUE(instances.empty());
    384   // Check hal with unsupported interface by vendor.
    385   EXPECT_FALSE(checker_->CheckHalForNonComplianceTest(
    386       "android.hardware.nfc", {1, 0}, "INfcTest", Arch::ARCH_32, &instances));
    387   EXPECT_TRUE(instances.empty());
    388   // Check hal with unsupported arch by vendor.
    389   EXPECT_FALSE(checker_->CheckHalForNonComplianceTest(
    390       "android.hardware.audio", {1, 0}, "IAudio", Arch::ARCH_64, &instances));
    391   EXPECT_TRUE(instances.empty());
    392   // Check hal claimed by framework but not supported by vendor (error case).
    393   EXPECT_FALSE(checker_->CheckHalForNonComplianceTest(
    394       "android.hardware.light", {2, 0}, "ILight", Arch::ARCH_32, &instances));
    395   EXPECT_TRUE(instances.empty());
    396   // Check hal interface claimed by framework but not supported by vendor (error
    397   // case).
    398   EXPECT_FALSE(checker_->CheckHalForNonComplianceTest(
    399       "android.hardware.drm", {1, 0}, "IDrmTest", Arch::ARCH_32, &instances));
    400   EXPECT_TRUE(instances.empty());
    401 
    402   // Check hal claimed by framework and supported by vendor.
    403   instances.clear();
    404   EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
    405       "android.hardware.vibrator", {1, 0}, "IVibrator", Arch::ARCH_32,
    406       &instances));
    407   EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
    408 
    409   // Check hal not claimed by framework but supported by vendor.
    410   instances.clear();
    411   EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
    412       "android.hardware.renderscript", {1, 0}, "IRenderscript", Arch::ARCH_32,
    413       &instances));
    414   EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
    415 
    416   // Check hal with version not claimed by framework by supported by vendor.
    417   instances.clear();
    418   EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
    419       "android.hardware.vibrator", {1, 0}, "IVibrator", Arch::ARCH_32,
    420       &instances));
    421   EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
    422 
    423   // Check hal with instance not claimed by framework but supported by vendor.
    424   instances.clear();
    425   EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
    426       "android.hardware.camera", {2, 2}, "ICamera", Arch::ARCH_32, &instances));
    427   EXPECT_THAT(instances, ContainerEq(set<string>({"legacy/0"})));
    428 
    429   // Check hal with additional vendor instance not claimed by framework.
    430   instances.clear();
    431   EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
    432       "android.hardware.camera", {1, 2}, "IBetterCamera", Arch::ARCH_32,
    433       &instances));
    434   EXPECT_THAT(instances, ContainerEq(set<string>({"default", "camera"})));
    435 
    436   // Check hal supported by both framework and vendor.
    437   instances.clear();
    438   EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
    439       "android.hardware.nfc", {1, 0}, "INfc", Arch::ARCH_32, &instances));
    440   EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
    441 
    442   // Check an optional hal with empty interface (legacy input).
    443   instances.clear();
    444   EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
    445       "android.hardware.vibrator", {1, 0}, "" /*interface*/, Arch::ARCH_EMPTY,
    446       &instances));
    447   EXPECT_TRUE(instances.empty());
    448 
    449   // Check hal only registered with hwmanger.
    450   instances.clear();
    451   EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
    452       "android.hardware.foo", {1, 0}, "IFoo", Arch::ARCH_EMPTY, &instances));
    453   EXPECT_THAT(instances, ContainerEq(set<string>({"default", "footest"})));
    454 
    455   // Check hal with version only registered with hwmanger.
    456   instances.clear();
    457   EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
    458       "android.hardware.nfc", {3, 0}, "INfc", Arch::ARCH_EMPTY, &instances));
    459   EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
    460 
    461   // Check hal with additional instance registered with hwmanger.
    462   instances.clear();
    463   EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
    464       "android.hardware.drm", {2, 0}, "IDrm", Arch::ARCH_EMPTY, &instances));
    465   EXPECT_THAT(instances, ContainerEq(set<string>({"default", "drmtest"})));
    466 
    467   instances.clear();
    468   EXPECT_TRUE(checker_->CheckHalForNonComplianceTest(
    469       "android.hardware.foo", {1, 0}, "", Arch::ARCH_EMPTY, &instances));
    470   EXPECT_TRUE(instances.empty());
    471 }
    472 
    473 TEST_F(VtsTestabilityCheckerTest, CheckFrameworkCompatibleHalOptional) {
    474   set<string> instances;
    475   // Check non-existent hal.
    476   EXPECT_FALSE(checker_->CheckFrameworkCompatibleHal(
    477       "nonexistent", {1, 0}, "None", Arch::ARCH_EMPTY, &instances));
    478   EXPECT_TRUE(instances.empty());
    479 
    480   // Check hal not required by framework
    481   EXPECT_FALSE(checker_->CheckFrameworkCompatibleHal(
    482       "android.hardware.renderscript", {1, 0}, "IRenderscript",
    483       Arch::ARCH_EMPTY, &instances));
    484   EXPECT_TRUE(instances.empty());
    485 
    486   // Check hal with unsupported version.
    487   EXPECT_FALSE(checker_->CheckFrameworkCompatibleHal(
    488       "android.hardware.camera", {1, 0}, "ICamera", Arch::ARCH_EMPTY,
    489       &instances));
    490   EXPECT_TRUE(instances.empty());
    491 
    492   // Check hal with non-existent interface.
    493   EXPECT_FALSE(checker_->CheckFrameworkCompatibleHal(
    494       "android.hardware.camera", {1, 2}, "None", Arch::ARCH_EMPTY, &instances));
    495   EXPECT_TRUE(instances.empty());
    496 
    497   // Check an optional hal not supported by vendor.
    498   EXPECT_FALSE(checker_->CheckFrameworkCompatibleHal(
    499       "android.hardware.radio", {1, 0}, "IRadio", Arch::ARCH_EMPTY,
    500       &instances));
    501   EXPECT_TRUE(instances.empty());
    502 
    503   // Check an optional hal with version not supported by vendor.
    504   EXPECT_FALSE(checker_->CheckFrameworkCompatibleHal(
    505       "android.hardware.camera", {4, 5}, "ICamera", Arch::ARCH_EMPTY,
    506       &instances));
    507   EXPECT_TRUE(instances.empty());
    508 
    509   // Check an optional hal with interface not supported by vendor.
    510   EXPECT_FALSE(checker_->CheckFrameworkCompatibleHal(
    511       "android.hardware.nfc", {4, 5}, "INfcTest", Arch::ARCH_EMPTY,
    512       &instances));
    513   EXPECT_TRUE(instances.empty());
    514 
    515   // Check an option passthrough hal with unsupported arch.
    516   EXPECT_FALSE(checker_->CheckFrameworkCompatibleHal(
    517       "android.hardware.audio", {2, 0}, "IAudio", Arch::ARCH_64, &instances));
    518   EXPECT_TRUE(instances.empty());
    519 
    520   // Check an optional hal supported by vendor but with no compatible
    521   // instance.
    522   EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal(
    523       "android.hardware.camera", {2, 2}, "ICamera", Arch::ARCH_EMPTY,
    524       &instances));
    525   EXPECT_TRUE(instances.empty());
    526 
    527   // Check an optional hal supported by vendor.
    528   instances.clear();
    529   EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal(
    530       "android.hardware.camera", {2, 2}, "IBetterCamera", Arch::ARCH_EMPTY,
    531       &instances));
    532   EXPECT_THAT(instances, ContainerEq(set<string>({"camera"})));
    533 
    534   // Check an optional passthrough hal supported by vendor.
    535   instances.clear();
    536   EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal(
    537       "android.hardware.audio", {2, 0}, "IAudio", Arch::ARCH_32, &instances));
    538   EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
    539 
    540   // Check an optional hal with empty interface (legacy input).
    541   instances.clear();
    542   EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal(
    543       "android.hardware.camera", {2, 2}, "" /*interface*/, Arch::ARCH_EMPTY,
    544       &instances));
    545   EXPECT_TRUE(instances.empty());
    546 }
    547 
    548 TEST_F(VtsTestabilityCheckerTest, CheckFrameworkCompatibleHalRequired) {
    549   set<string> instances;
    550   // Check a required hal not supported by vendor.
    551   EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal(
    552       "android.hardware.light", {2, 0}, "ILight", Arch::ARCH_32, &instances));
    553   EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
    554 
    555   // Check a required hal with version not supported by vendor.
    556   instances.clear();
    557   EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal("android.hardware.vibrator",
    558                                                     {2, 0}, "IVibrator",
    559                                                     Arch::ARCH_32, &instances));
    560   EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
    561 
    562   // Check a required hal with interface not supported by vendor.
    563   instances.clear();
    564   EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal(
    565       "android.hardware.drm", {1, 0}, "IDrmTest", Arch::ARCH_32, &instances));
    566   EXPECT_THAT(instances, ContainerEq(set<string>({"default"})));
    567 
    568   // Check a required hal supported by vendor.
    569   instances.clear();
    570   EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal(
    571       "android.hardware.drm", {1, 0}, "IDrm", Arch::ARCH_32, &instances));
    572   EXPECT_THAT(instances, ContainerEq(set<string>({"default", "drm"})));
    573 
    574   // Check an optional hal with empty interface (legacy input).
    575   instances.clear();
    576   EXPECT_TRUE(checker_->CheckFrameworkCompatibleHal(
    577       "android.hardware.vibrator", {2, 0}, "" /*interface*/, Arch::ARCH_EMPTY,
    578       &instances));
    579   EXPECT_TRUE(instances.empty());
    580 }
    581 
    582 }  // namespace vts
    583 }  // namespace android
    584 
    585 int main(int argc, char **argv) {
    586   ::testing::InitGoogleTest(&argc, argv);
    587   return RUN_ALL_TESTS();
    588 }
    589