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

Commit c7577108 authored by Connor O'Brien's avatar Connor O'Brien
Browse files

IR HAL Target-side test



Test: make vts; vts-tradefed run -m HalIrHidlTargetTest
Change-Id: I6b750f66a0bc207056abcb493693baebc8af81a5
Signed-off-by: default avatarConnor O'Brien <connoro@google.com>
parent 5c959c69
Loading
Loading
Loading
Loading
+103 −0
Original line number Original line Diff line number Diff line
@@ -54,3 +54,106 @@ cc_library_shared {
        "android.hidl.base@1.0",
        "android.hidl.base@1.0",
    ],
    ],
}
}

genrule {
    name: "android.hardware.ir.vts.driver@1.0_genc++",
    tools: ["hidl-gen", "vtsc"],
    cmd: "$(location hidl-gen) -o $(genDir) -Lvts -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.ir@1.0 && $(location vtsc) -mDRIVER -tSOURCE -b$(genDir) android/hardware/ir/1.0/ $(genDir)/android/hardware/ir/1.0/",
    srcs: [
        "types.hal",
        "IConsumerIr.hal",
    ],
    out: [
        "android/hardware/ir/1.0/types.vts.cpp",
        "android/hardware/ir/1.0/ConsumerIr.vts.cpp",
    ],
}

genrule {
    name: "android.hardware.ir.vts.driver@1.0_genc++_headers",
    tools: ["hidl-gen", "vtsc"],
    cmd: "$(location hidl-gen) -o $(genDir) -Lvts -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.ir@1.0 && $(location vtsc) -mDRIVER -tHEADER -b$(genDir) android/hardware/ir/1.0/ $(genDir)/android/hardware/ir/1.0/",
    srcs: [
        "types.hal",
        "IConsumerIr.hal",
    ],
    out: [
        "android/hardware/ir/1.0/types.vts.h",
        "android/hardware/ir/1.0/ConsumerIr.vts.h",
    ],
}

cc_library_shared {
    name: "android.hardware.ir.vts.driver@1.0",
    generated_sources: ["android.hardware.ir.vts.driver@1.0_genc++"],
    generated_headers: ["android.hardware.ir.vts.driver@1.0_genc++_headers"],
    export_generated_headers: ["android.hardware.ir.vts.driver@1.0_genc++_headers"],
    shared_libs: [
        "libhidlbase",
        "libhidltransport",
        "libhwbinder",
        "liblog",
        "libutils",
        "libcutils",
        "libvts_common",
        "libvts_datatype",
        "libvts_measurement",
        "libvts_multidevice_proto",
        "libcamera_metadata",
        "libprotobuf-cpp-full",
        "android.hidl.base@1.0",
        "android.hardware.ir@1.0",
    ],
    export_shared_lib_headers: [
        "libhidlbase",
        "libhidltransport",
        "libhwbinder",
        "libutils",
        "android.hidl.base@1.0",
    ],
}

genrule {
    name: "android.hardware.ir@1.0-IConsumerIr-vts.profiler_genc++",
    tools: ["hidl-gen", "vtsc"],
    cmd: "$(location hidl-gen) -o $(genDir) -Lvts -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.ir@1.0 && $(location vtsc) -mPROFILER -tSOURCE -b$(genDir) android/hardware/ir/1.0/ $(genDir)/android/hardware/ir/1.0/",
    srcs: [
        "IConsumerIr.hal",
        "types.hal",
    ],
    out: [
        "android/hardware/ir/1.0/ConsumerIr.vts.cpp",
        "android/hardware/ir/1.0/types.vts.cpp",
    ],
}

genrule {
    name: "android.hardware.ir@1.0-IConsumerIr-vts.profiler_genc++_headers",
    tools: ["hidl-gen", "vtsc"],
    cmd: "$(location hidl-gen) -o $(genDir) -Lvts -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.ir@1.0 && $(location vtsc) -mPROFILER -tHEADER -b$(genDir) android/hardware/ir/1.0/ $(genDir)/android/hardware/ir/1.0/",
    srcs: [
        "IConsumerIr.hal",
        "types.hal",
    ],
    out: [
        "android/hardware/ir/1.0/ConsumerIr.vts.h",
        "android/hardware/ir/1.0/types.vts.h",
    ],
}

cc_library_shared {
    name: "android.hardware.ir@1.0-IConsumerIr-vts.profiler",
    generated_sources: ["android.hardware.ir@1.0-IConsumerIr-vts.profiler_genc++"],
    generated_headers: ["android.hardware.ir@1.0-IConsumerIr-vts.profiler_genc++_headers"],
    export_generated_headers: ["android.hardware.ir@1.0-IConsumerIr-vts.profiler_genc++_headers"],
    shared_libs: [
        "libbase",
        "libhidlbase",
        "libhidltransport",
        "libvts_profiling",
        "libvts_multidevice_proto",
        "libprotobuf-cpp-full",
        "android.hidl.base@1.0",
        "android.hardware.ir@1.0",
    ],
}

ir/1.0/vts/Android.mk

0 → 100644
+19 −0
Original line number Original line Diff line number Diff line
#
# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

LOCAL_PATH := $(call my-dir)

include $(LOCAL_PATH)/functional/vts/testcases/hal/ir/hidl/target/Android.mk
+44 −0
Original line number Original line Diff line number Diff line
component_class: HAL_HIDL
component_type_version: 1.0
component_name: "IConsumerIr"

package: "android.hardware.ir"

import: "android.hardware.ir@1.0::types"

interface: {
    api: {
        name: "transmit"
        return_type_hidl: {
            type: TYPE_SCALAR
            scalar_type: "bool_t"
        }
        arg: {
            type: TYPE_SCALAR
            scalar_type: "int32_t"
        }
        arg: {
            type: TYPE_VECTOR
            vector_value: {
                type: TYPE_SCALAR
                scalar_type: "int32_t"
            }
        }
    }

    api: {
        name: "getCarrierFreqs"
        return_type_hidl: {
            type: TYPE_SCALAR
            scalar_type: "bool_t"
        }
        return_type_hidl: {
            type: TYPE_VECTOR
            vector_value: {
                type: TYPE_STRUCT
                predefined_type: "::android::hardware::ir::V1_0::ConsumerIrFreqRange"
            }
        }
    }

}
+40 −0
Original line number Original line Diff line number Diff line
//
// Copyright (C) 2016 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.
//

cc_test {
    name: "ir_hidl_hal_test",
    gtest: true,
    srcs: ["ir_hidl_hal_test.cpp"],
    shared_libs: [
        "libbase",
        "liblog",
        "libcutils",
        "libhidlbase",
        "libhidltransport",
        "libhwbinder",
        "libutils",
        "android.hardware.ir@1.0",
    ],
    static_libs: ["libgtest"],
    cflags: [
        "--coverage",
        "-O0",
        "-g",
    ],
    ldflags: [
        "--coverage"
    ]
}
+86 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2016 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 "ir_hidl_hal_test"

#include <android-base/logging.h>

#include <android/hardware/ir/1.0/IConsumerIr.h>
#include <android/hardware/ir/1.0/types.h>

#include <gtest/gtest.h>
#include <algorithm>

using ::android::hardware::ir::V1_0::IConsumerIr;
using ::android::hardware::ir::V1_0::ConsumerIrFreqRange;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::sp;

// The main test class for IR HIDL HAL.
class ConsumerIrHidlTest : public ::testing::Test {
 public:
  virtual void SetUp() override {
    ir = IConsumerIr::getService(false);
    ASSERT_NE(ir, nullptr);
  }

  virtual void TearDown() override {}

  sp<IConsumerIr> ir;
};

// Test transmit() for the min and max frequency of every available range
TEST_F(ConsumerIrHidlTest, TransmitTest) {
  int32_t freqs;
  bool success;
  hidl_vec<ConsumerIrFreqRange> ranges;
  auto cb = [&](bool s, hidl_vec<ConsumerIrFreqRange> v) {
    ranges = v;
    success = s;
  };
  Return<void> ret = ir->getCarrierFreqs(cb);
  ASSERT_TRUE(ret.isOk());
  ASSERT_TRUE(success);

  if (ranges.size() > 0) {
    uint32_t len = 16;
    hidl_vec<int32_t> vec;
    vec.resize(len);
    std::fill(vec.begin(), vec.end(), 1);
    for (auto range = ranges.begin(); range != ranges.end(); range++) {
      EXPECT_TRUE(ir->transmit(range->min, vec));
      EXPECT_TRUE(ir->transmit(range->max, vec));
    }
  }
}

// Test transmit() when called with invalid frequencies
TEST_F(ConsumerIrHidlTest, BadFreqTest) {
  uint32_t len = 16;
  hidl_vec<int32_t> vec;
  vec.resize(len);
  std::fill(vec.begin(), vec.end(), 1);
  EXPECT_FALSE(ir->transmit(-1, vec));
  EXPECT_FALSE(ir->transmit(0, vec));
}

int main(int argc, char **argv) {
  ::testing::InitGoogleTest(&argc, argv);
  int status = RUN_ALL_TESTS();
  LOG(INFO) << "Test result = " << status;
  return status;
}
Loading