Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5dde02c7 authored by Ian Hua's avatar Ian Hua Committed by Miao Wang
Browse files

Add FL6 spec tests to AIDL VTS.

Also skip FL6 (AIDL_V2) tests for older AIDL drivers.

Cherrypicked from I689fef0945428f6548977628e3c43628dd1e5bf7

Bug: 206089870
Test: VtsHalNeuralnetworksTargetTest
Specifically, for old driver such as AIDL_V1 sample driver, it can pass
HIDL tests and skip AIDL_V2 tests. For new driver such as AIDL_V2
sample driver, it can pass all tests.

Change-Id: I689fef0945428f6548977628e3c43628dd1e5bf7
(cherry picked from commit 23d4e5e2)
parent a8cf3aef
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@
namespace aidl::android::hardware::neuralnetworks::utils {

constexpr auto kDefaultPriority = Priority::MEDIUM;
constexpr auto kVersion = nn::Version::ANDROID_S;
constexpr auto kVersion = nn::Version::FEATURE_LEVEL_6;

template <typename Type>
nn::Result<void> validate(const Type& halObject) {
+1 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ cc_test {
        "neuralnetworks_utils_hal_aidl",
    ],
    whole_static_libs: [
        "neuralnetworks_generated_AIDL_V2_example",
        "neuralnetworks_generated_V1_0_example",
        "neuralnetworks_generated_V1_1_example",
        "neuralnetworks_generated_V1_2_example",
+14 −0
Original line number Diff line number Diff line
@@ -907,6 +907,20 @@ void GeneratedTestBase::SetUp() {
    const bool deviceIsResponsive =
            ndk::ScopedAStatus::fromStatus(AIBinder_ping(kDevice->asBinder().get())).isOk();
    ASSERT_TRUE(deviceIsResponsive);
    //  TODO(b/201260787): We should require old drivers to report the model as
    //  unsupported instead of simply skipping the test.
    SkipIfDriverOlderThanTestModel();
}

void GeneratedTestBase::SkipIfDriverOlderThanTestModel() {
    int32_t deviceVersion;
    ASSERT_TRUE(kDevice->getInterfaceVersion(&deviceVersion).isOk());
    const int32_t modelVersion = kTestModel.getAidlVersionInt();
    if (deviceVersion < modelVersion) {
        GTEST_SKIP() << "Device interface version " << deviceVersion
                     << " is older than test model's minimum supported HAL version " << modelVersion
                     << ". Skipping test.";
    }
}

std::vector<NamedModel> getNamedModels(const FilterFn& filter) {
+3 −0
Original line number Diff line number Diff line
@@ -34,6 +34,9 @@ class GeneratedTestBase : public testing::TestWithParam<GeneratedTestParam> {
    void SetUp() override;
    const std::shared_ptr<IDevice> kDevice = getData(std::get<NamedDevice>(GetParam()));
    const test_helper::TestModel& kTestModel = *getData(std::get<NamedModel>(GetParam()));

  private:
    void SkipIfDriverOlderThanTestModel();
};

using FilterFn = std::function<bool(const test_helper::TestModel&)>;
+6 −0
Original line number Diff line number Diff line
@@ -1122,6 +1122,7 @@ static bool removeOperationInputSkip(const Operation& op, size_t input) {
    //   align_corners and half_pixel_centers parameters.
    // - L2_NORMALIZATION, LOCAL_RESPONSE_NORMALIZATION, SOFTMAX can have an optional axis
    //   parameter.
    // - PACK has at least 2 inputs, with the first element being INT32.
    switch (op.type) {
        case OperationType::CONCATENATION: {
            if (op.inputs.size() > 2 && input != op.inputs.size() - 1) {
@@ -1178,6 +1179,11 @@ static bool removeOperationInputSkip(const Operation& op, size_t input) {
                return true;
            }
        } break;
        case OperationType::PACK: {
            if (op.inputs.size() > 2 && input != 0) {
                return true;
            }
        } break;
        default:
            break;
    }