Provide explicitly versioned NNAPI AIDL utils libs -- HAL. am: cb2c37f78f
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1869667 Change-Id: I6982ec9725bcd7baa42f7e42327b46b73c8c8bfb
This commit is contained in:
commit
142fc99967
16 changed files with 204 additions and 128 deletions
|
@ -49,7 +49,7 @@ cc_test {
|
|||
static_libs: [
|
||||
"android.hardware.neuralnetworks@1.0",
|
||||
"libgmock",
|
||||
"libneuralnetworks_common",
|
||||
"libneuralnetworks_common_hidl",
|
||||
"neuralnetworks_types",
|
||||
"neuralnetworks_utils_hal_common",
|
||||
"neuralnetworks_utils_hal_1_0",
|
||||
|
|
|
@ -50,7 +50,7 @@ cc_library_static {
|
|||
"libgmock",
|
||||
"libhidlmemory",
|
||||
"libneuralnetworks_generated_test_harness",
|
||||
"libneuralnetworks_utils",
|
||||
"libneuralnetworks_common_hidl",
|
||||
],
|
||||
header_libs: [
|
||||
"libneuralnetworks_headers",
|
||||
|
@ -81,7 +81,7 @@ cc_test {
|
|||
"libgmock",
|
||||
"libhidlmemory",
|
||||
"libneuralnetworks_generated_test_harness",
|
||||
"libneuralnetworks_utils",
|
||||
"libneuralnetworks_common_hidl",
|
||||
],
|
||||
whole_static_libs: [
|
||||
"neuralnetworks_generated_V1_0_example",
|
||||
|
|
|
@ -52,7 +52,7 @@ cc_test {
|
|||
"android.hardware.neuralnetworks@1.0",
|
||||
"android.hardware.neuralnetworks@1.1",
|
||||
"libgmock",
|
||||
"libneuralnetworks_common",
|
||||
"libneuralnetworks_common_hidl",
|
||||
"neuralnetworks_types",
|
||||
"neuralnetworks_utils_hal_common",
|
||||
"neuralnetworks_utils_hal_1_0",
|
||||
|
|
|
@ -48,7 +48,7 @@ cc_test {
|
|||
"libgmock",
|
||||
"libhidlmemory",
|
||||
"libneuralnetworks_generated_test_harness",
|
||||
"libneuralnetworks_utils",
|
||||
"libneuralnetworks_common_hidl",
|
||||
],
|
||||
whole_static_libs: [
|
||||
"neuralnetworks_generated_V1_0_example",
|
||||
|
|
|
@ -71,7 +71,7 @@ cc_test {
|
|||
"android.hardware.neuralnetworks@1.1",
|
||||
"android.hardware.neuralnetworks@1.2",
|
||||
"libgmock",
|
||||
"libneuralnetworks_common",
|
||||
"libneuralnetworks_common_hidl",
|
||||
"neuralnetworks_types",
|
||||
"neuralnetworks_utils_hal_common",
|
||||
"neuralnetworks_utils_hal_1_0",
|
||||
|
|
|
@ -71,7 +71,7 @@ cc_test {
|
|||
"libgmock",
|
||||
"libhidlmemory",
|
||||
"libneuralnetworks_generated_test_harness",
|
||||
"libneuralnetworks_utils",
|
||||
"libneuralnetworks_common_hidl",
|
||||
],
|
||||
whole_static_libs: [
|
||||
"neuralnetworks_generated_V1_0_example",
|
||||
|
|
|
@ -69,7 +69,7 @@ cc_test {
|
|||
"android.hardware.neuralnetworks@1.2",
|
||||
"android.hardware.neuralnetworks@1.3",
|
||||
"libgmock",
|
||||
"libneuralnetworks_common",
|
||||
"libneuralnetworks_common_hidl",
|
||||
"neuralnetworks_types",
|
||||
"neuralnetworks_utils_hal_common",
|
||||
"neuralnetworks_utils_hal_1_0",
|
||||
|
|
|
@ -66,7 +66,6 @@ cc_test {
|
|||
"VtsHalNeuralNetworksV1_0_utils",
|
||||
"VtsHalNeuralNetworksV1_2_utils",
|
||||
"VtsHalNeuralNetworksV1_3_utils",
|
||||
"android.hardware.neuralnetworks-V2-ndk",
|
||||
"android.hardware.neuralnetworks@1.0",
|
||||
"android.hardware.neuralnetworks@1.1",
|
||||
"android.hardware.neuralnetworks@1.2",
|
||||
|
@ -76,7 +75,7 @@ cc_test {
|
|||
"libgmock",
|
||||
"libhidlmemory",
|
||||
"libneuralnetworks_generated_test_harness",
|
||||
"libneuralnetworks_utils",
|
||||
"libneuralnetworks_common_hidl",
|
||||
"libsync",
|
||||
],
|
||||
whole_static_libs: [
|
||||
|
|
|
@ -23,8 +23,8 @@ package {
|
|||
default_applicable_licenses: ["hardware_interfaces_license"],
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "neuralnetworks_utils_hal_aidl",
|
||||
cc_defaults {
|
||||
name: "neuralnetworks_utils_hal_aidl_defaults",
|
||||
defaults: ["neuralnetworks_utils_defaults"],
|
||||
srcs: ["src/*"],
|
||||
local_include_dirs: ["include/nnapi/hal/aidl/"],
|
||||
|
@ -38,7 +38,6 @@ cc_library_static {
|
|||
"neuralnetworks_utils_hal_common",
|
||||
],
|
||||
shared_libs: [
|
||||
"android.hardware.neuralnetworks-V2-ndk",
|
||||
"libbinder_ndk",
|
||||
"libhidlbase",
|
||||
],
|
||||
|
@ -49,21 +48,49 @@ cc_library_static {
|
|||
},
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "neuralnetworks_utils_hal_aidl_test",
|
||||
defaults: ["neuralnetworks_utils_defaults"],
|
||||
srcs: [
|
||||
"test/*.cpp",
|
||||
cc_library_static {
|
||||
name: "neuralnetworks_utils_hal_aidl_v1",
|
||||
defaults: ["neuralnetworks_utils_hal_aidl_defaults"],
|
||||
shared_libs: [
|
||||
"android.hardware.neuralnetworks-V1-ndk",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "neuralnetworks_utils_hal_aidl_v2",
|
||||
defaults: ["neuralnetworks_utils_hal_aidl_defaults"],
|
||||
shared_libs: [
|
||||
"android.hardware.neuralnetworks-V2-ndk",
|
||||
],
|
||||
}
|
||||
|
||||
// A cc_defaults that includes the latest non-experimental AIDL utilities and other AIDL libraries
|
||||
// that are commonly used together. Modules that always depend on the latest non-experimental
|
||||
// AIDL features can include this cc_defaults to avoid managing dependency versions explicitly.
|
||||
cc_defaults {
|
||||
name: "neuralnetworks_use_latest_utils_hal_aidl",
|
||||
static_libs: [
|
||||
"android.hardware.common-V2-ndk",
|
||||
"android.hardware.graphics.common-V2-ndk",
|
||||
"android.hardware.neuralnetworks-V2-ndk",
|
||||
"neuralnetworks_utils_hal_aidl_v2",
|
||||
],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "neuralnetworks_utils_hal_aidl_test",
|
||||
defaults: [
|
||||
"neuralnetworks_use_latest_utils_hal_aidl",
|
||||
"neuralnetworks_utils_defaults",
|
||||
],
|
||||
srcs: [
|
||||
"test/*.cpp",
|
||||
],
|
||||
static_libs: [
|
||||
"libaidlcommonsupport",
|
||||
"libgmock",
|
||||
"libneuralnetworks_common",
|
||||
"neuralnetworks_types",
|
||||
"neuralnetworks_utils_hal_aidl",
|
||||
"neuralnetworks_utils_hal_common",
|
||||
],
|
||||
shared_libs: [
|
||||
|
|
|
@ -43,11 +43,12 @@ class Device final : public nn::IDevice {
|
|||
|
||||
public:
|
||||
static nn::GeneralResult<std::shared_ptr<const Device>> create(
|
||||
std::string name, std::shared_ptr<aidl_hal::IDevice> device);
|
||||
std::string name, std::shared_ptr<aidl_hal::IDevice> device, nn::Version featureLevel);
|
||||
|
||||
Device(PrivateConstructorTag tag, std::string name, std::string versionString,
|
||||
nn::DeviceType deviceType, std::vector<nn::Extension> extensions,
|
||||
nn::Capabilities capabilities, std::pair<uint32_t, uint32_t> numberOfCacheFilesNeeded,
|
||||
nn::Version featureLevel, nn::DeviceType deviceType,
|
||||
std::vector<nn::Extension> extensions, nn::Capabilities capabilities,
|
||||
std::pair<uint32_t, uint32_t> numberOfCacheFilesNeeded,
|
||||
std::shared_ptr<aidl_hal::IDevice> device, DeathHandler deathHandler);
|
||||
|
||||
const std::string& getName() const override;
|
||||
|
@ -84,6 +85,7 @@ class Device final : public nn::IDevice {
|
|||
private:
|
||||
const std::string kName;
|
||||
const std::string kVersionString;
|
||||
const nn::Version kFeatureLevel;
|
||||
const nn::DeviceType kDeviceType;
|
||||
const std::vector<nn::Extension> kExtensions;
|
||||
const nn::Capabilities kCapabilities;
|
||||
|
|
|
@ -125,7 +125,7 @@ nn::GeneralResult<std::pair<uint32_t, uint32_t>> getNumberOfCacheFilesNeededFrom
|
|||
} // namespace
|
||||
|
||||
nn::GeneralResult<std::shared_ptr<const Device>> Device::create(
|
||||
std::string name, std::shared_ptr<aidl_hal::IDevice> device) {
|
||||
std::string name, std::shared_ptr<aidl_hal::IDevice> device, nn::Version featureLevel) {
|
||||
if (name.empty()) {
|
||||
return NN_ERROR(nn::ErrorStatus::INVALID_ARGUMENT)
|
||||
<< "aidl_hal::utils::Device::create must have non-empty name";
|
||||
|
@ -143,18 +143,19 @@ nn::GeneralResult<std::shared_ptr<const Device>> Device::create(
|
|||
|
||||
auto deathHandler = NN_TRY(DeathHandler::create(device));
|
||||
return std::make_shared<const Device>(
|
||||
PrivateConstructorTag{}, std::move(name), std::move(versionString), deviceType,
|
||||
std::move(extensions), std::move(capabilities), numberOfCacheFilesNeeded,
|
||||
PrivateConstructorTag{}, std::move(name), std::move(versionString), featureLevel,
|
||||
deviceType, std::move(extensions), std::move(capabilities), numberOfCacheFilesNeeded,
|
||||
std::move(device), std::move(deathHandler));
|
||||
}
|
||||
|
||||
Device::Device(PrivateConstructorTag /*tag*/, std::string name, std::string versionString,
|
||||
nn::DeviceType deviceType, std::vector<nn::Extension> extensions,
|
||||
nn::Capabilities capabilities,
|
||||
nn::Version featureLevel, nn::DeviceType deviceType,
|
||||
std::vector<nn::Extension> extensions, nn::Capabilities capabilities,
|
||||
std::pair<uint32_t, uint32_t> numberOfCacheFilesNeeded,
|
||||
std::shared_ptr<aidl_hal::IDevice> device, DeathHandler deathHandler)
|
||||
: kName(std::move(name)),
|
||||
kVersionString(std::move(versionString)),
|
||||
kFeatureLevel(featureLevel),
|
||||
kDeviceType(deviceType),
|
||||
kExtensions(std::move(extensions)),
|
||||
kCapabilities(std::move(capabilities)),
|
||||
|
@ -171,7 +172,7 @@ const std::string& Device::getVersionString() const {
|
|||
}
|
||||
|
||||
nn::Version Device::getFeatureLevel() const {
|
||||
return nn::Version::ANDROID_S;
|
||||
return kFeatureLevel;
|
||||
}
|
||||
|
||||
nn::DeviceType Device::getType() const {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "Service.h"
|
||||
|
||||
#include <AndroidVersionUtil.h>
|
||||
#include <aidl/android/hardware/neuralnetworks/IDevice.h>
|
||||
#include <android/binder_auto_utils.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
|
@ -28,8 +29,33 @@
|
|||
#include <string>
|
||||
|
||||
#include "Device.h"
|
||||
#include "Utils.h"
|
||||
|
||||
namespace aidl::android::hardware::neuralnetworks::utils {
|
||||
namespace {
|
||||
|
||||
// Map the AIDL version of an IDevice to NNAPI canonical feature level.
|
||||
nn::GeneralResult<nn::Version> getAidlServiceFeatureLevel(IDevice* service) {
|
||||
CHECK(service != nullptr);
|
||||
int aidlVersion;
|
||||
const auto ret = service->getInterfaceVersion(&aidlVersion);
|
||||
HANDLE_ASTATUS(ret) << "getInterfaceVersion failed";
|
||||
|
||||
// For service AIDL versions greater than or equal to the AIDL library version that the runtime
|
||||
// was built against, clamp it to the runtime AIDL library version.
|
||||
aidlVersion = std::min(aidlVersion, IDevice::version);
|
||||
|
||||
// Map stable AIDL versions to canonical versions.
|
||||
switch (aidlVersion) {
|
||||
case 1:
|
||||
return nn::Version::ANDROID_S;
|
||||
case 2:
|
||||
return nn::Version::FEATURE_LEVEL_6;
|
||||
}
|
||||
return NN_ERROR() << "Unknown AIDL service version: " << aidlVersion;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
nn::GeneralResult<nn::SharedDevice> getDevice(const std::string& instanceName) {
|
||||
auto fullName = std::string(IDevice::descriptor) + "/" + instanceName;
|
||||
|
@ -55,7 +81,8 @@ nn::GeneralResult<nn::SharedDevice> getDevice(const std::string& instanceName) {
|
|||
<< " returned nullptr";
|
||||
}
|
||||
ABinderProcess_startThreadPool();
|
||||
return Device::create(instanceName, std::move(service));
|
||||
const auto featureLevel = NN_TRY(getAidlServiceFeatureLevel(service.get()));
|
||||
return Device::create(instanceName, std::move(service), featureLevel);
|
||||
};
|
||||
|
||||
return hal::utils::ResilientDevice::create(std::move(makeDevice));
|
||||
|
|
|
@ -146,28 +146,45 @@ constexpr auto makeDeadObjectFailure = [] {
|
|||
return ndk::ScopedAStatus::fromStatus(STATUS_DEAD_OBJECT);
|
||||
};
|
||||
|
||||
class DeviceTest : public ::testing::TestWithParam<nn::Version> {
|
||||
protected:
|
||||
const nn::Version kVersion = GetParam();
|
||||
};
|
||||
|
||||
std::string printDeviceTest(const testing::TestParamInfo<nn::Version>& info) {
|
||||
switch (info.param) {
|
||||
case nn::Version::ANDROID_S:
|
||||
return "v1";
|
||||
case nn::Version::FEATURE_LEVEL_6:
|
||||
return "v2";
|
||||
default:
|
||||
LOG(FATAL) << "Invalid AIDL version: " << info.param;
|
||||
return "invalid";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(DeviceTest, invalidName) {
|
||||
TEST_P(DeviceTest, invalidName) {
|
||||
// run test
|
||||
const auto device = MockDevice::create();
|
||||
const auto result = Device::create(kInvalidName, device);
|
||||
const auto result = Device::create(kInvalidName, device, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, invalidDevice) {
|
||||
TEST_P(DeviceTest, invalidDevice) {
|
||||
// run test
|
||||
const auto result = Device::create(kName, kInvalidDevice);
|
||||
const auto result = Device::create(kName, kInvalidDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getVersionStringError) {
|
||||
TEST_P(DeviceTest, getVersionStringError) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getVersionString(_))
|
||||
|
@ -175,14 +192,14 @@ TEST(DeviceTest, getVersionStringError) {
|
|||
.WillOnce(InvokeWithoutArgs(makeGeneralFailure));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getVersionStringTransportFailure) {
|
||||
TEST_P(DeviceTest, getVersionStringTransportFailure) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getVersionString(_))
|
||||
|
@ -190,14 +207,14 @@ TEST(DeviceTest, getVersionStringTransportFailure) {
|
|||
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getVersionStringDeadObject) {
|
||||
TEST_P(DeviceTest, getVersionStringDeadObject) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getVersionString(_))
|
||||
|
@ -205,27 +222,27 @@ TEST(DeviceTest, getVersionStringDeadObject) {
|
|||
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getTypeError) {
|
||||
TEST_P(DeviceTest, getTypeError) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getType(_)).Times(1).WillOnce(InvokeWithoutArgs(makeGeneralFailure));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getTypeTransportFailure) {
|
||||
TEST_P(DeviceTest, getTypeTransportFailure) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getType(_))
|
||||
|
@ -233,14 +250,14 @@ TEST(DeviceTest, getTypeTransportFailure) {
|
|||
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getTypeDeadObject) {
|
||||
TEST_P(DeviceTest, getTypeDeadObject) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getType(_))
|
||||
|
@ -248,14 +265,14 @@ TEST(DeviceTest, getTypeDeadObject) {
|
|||
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getSupportedExtensionsError) {
|
||||
TEST_P(DeviceTest, getSupportedExtensionsError) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getSupportedExtensions(_))
|
||||
|
@ -263,14 +280,14 @@ TEST(DeviceTest, getSupportedExtensionsError) {
|
|||
.WillOnce(InvokeWithoutArgs(makeGeneralFailure));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getSupportedExtensionsTransportFailure) {
|
||||
TEST_P(DeviceTest, getSupportedExtensionsTransportFailure) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getSupportedExtensions(_))
|
||||
|
@ -278,14 +295,14 @@ TEST(DeviceTest, getSupportedExtensionsTransportFailure) {
|
|||
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getSupportedExtensionsDeadObject) {
|
||||
TEST_P(DeviceTest, getSupportedExtensionsDeadObject) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getSupportedExtensions(_))
|
||||
|
@ -293,20 +310,20 @@ TEST(DeviceTest, getSupportedExtensionsDeadObject) {
|
|||
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getNumberOfCacheFilesNeeded) {
|
||||
TEST_P(DeviceTest, getNumberOfCacheFilesNeeded) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)).Times(1);
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_TRUE(result.has_value());
|
||||
|
@ -315,7 +332,7 @@ TEST(DeviceTest, getNumberOfCacheFilesNeeded) {
|
|||
EXPECT_EQ(result.value()->getNumberOfCacheFilesNeeded(), kNumberOfCacheFilesPair);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getNumberOfCacheFilesNeededError) {
|
||||
TEST_P(DeviceTest, getNumberOfCacheFilesNeededError) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_))
|
||||
|
@ -323,14 +340,14 @@ TEST(DeviceTest, getNumberOfCacheFilesNeededError) {
|
|||
.WillOnce(InvokeWithoutArgs(makeGeneralFailure));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, dataCacheFilesExceedsSpecifiedMax) {
|
||||
TEST_P(DeviceTest, dataCacheFilesExceedsSpecifiedMax) {
|
||||
// setup test
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_))
|
||||
|
@ -341,14 +358,14 @@ TEST(DeviceTest, dataCacheFilesExceedsSpecifiedMax) {
|
|||
InvokeWithoutArgs(makeStatusOk)));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, modelCacheFilesExceedsSpecifiedMax) {
|
||||
TEST_P(DeviceTest, modelCacheFilesExceedsSpecifiedMax) {
|
||||
// setup test
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_))
|
||||
|
@ -359,14 +376,14 @@ TEST(DeviceTest, modelCacheFilesExceedsSpecifiedMax) {
|
|||
InvokeWithoutArgs(makeStatusOk)));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getNumberOfCacheFilesNeededTransportFailure) {
|
||||
TEST_P(DeviceTest, getNumberOfCacheFilesNeededTransportFailure) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_))
|
||||
|
@ -374,14 +391,14 @@ TEST(DeviceTest, getNumberOfCacheFilesNeededTransportFailure) {
|
|||
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getNumberOfCacheFilesNeededDeadObject) {
|
||||
TEST_P(DeviceTest, getNumberOfCacheFilesNeededDeadObject) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_))
|
||||
|
@ -389,14 +406,14 @@ TEST(DeviceTest, getNumberOfCacheFilesNeededDeadObject) {
|
|||
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getCapabilitiesError) {
|
||||
TEST_P(DeviceTest, getCapabilitiesError) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getCapabilities(_))
|
||||
|
@ -404,14 +421,14 @@ TEST(DeviceTest, getCapabilitiesError) {
|
|||
.WillOnce(InvokeWithoutArgs(makeGeneralFailure));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getCapabilitiesTransportFailure) {
|
||||
TEST_P(DeviceTest, getCapabilitiesTransportFailure) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getCapabilities(_))
|
||||
|
@ -419,14 +436,14 @@ TEST(DeviceTest, getCapabilitiesTransportFailure) {
|
|||
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getCapabilitiesDeadObject) {
|
||||
TEST_P(DeviceTest, getCapabilitiesDeadObject) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getCapabilities(_))
|
||||
|
@ -434,17 +451,17 @@ TEST(DeviceTest, getCapabilitiesDeadObject) {
|
|||
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
|
||||
|
||||
// run test
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
|
||||
// verify result
|
||||
ASSERT_FALSE(result.has_value());
|
||||
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getName) {
|
||||
TEST_P(DeviceTest, getName) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
|
||||
// run test
|
||||
const auto& name = device->getName();
|
||||
|
@ -453,19 +470,19 @@ TEST(DeviceTest, getName) {
|
|||
EXPECT_EQ(name, kName);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getFeatureLevel) {
|
||||
TEST_P(DeviceTest, getFeatureLevel) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
|
||||
// run test
|
||||
const auto featureLevel = device->getFeatureLevel();
|
||||
|
||||
// verify result
|
||||
EXPECT_EQ(featureLevel, nn::Version::ANDROID_S);
|
||||
EXPECT_EQ(featureLevel, kVersion);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getCachedData) {
|
||||
TEST_P(DeviceTest, getCachedData) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
EXPECT_CALL(*mockDevice, getVersionString(_)).Times(1);
|
||||
|
@ -474,7 +491,7 @@ TEST(DeviceTest, getCachedData) {
|
|||
EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)).Times(1);
|
||||
EXPECT_CALL(*mockDevice, getCapabilities(_)).Times(1);
|
||||
|
||||
const auto result = Device::create(kName, mockDevice);
|
||||
const auto result = Device::create(kName, mockDevice, kVersion);
|
||||
ASSERT_TRUE(result.has_value())
|
||||
<< "Failed with " << result.error().code << ": " << result.error().message;
|
||||
const auto& device = result.value();
|
||||
|
@ -487,10 +504,10 @@ TEST(DeviceTest, getCachedData) {
|
|||
EXPECT_EQ(device->getCapabilities(), device->getCapabilities());
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getSupportedOperations) {
|
||||
TEST_P(DeviceTest, getSupportedOperations) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, getSupportedOperations(_, _))
|
||||
.Times(1)
|
||||
.WillOnce(DoAll(
|
||||
|
@ -508,10 +525,10 @@ TEST(DeviceTest, getSupportedOperations) {
|
|||
EXPECT_THAT(supportedOperations, Each(testing::IsTrue()));
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getSupportedOperationsError) {
|
||||
TEST_P(DeviceTest, getSupportedOperationsError) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, getSupportedOperations(_, _))
|
||||
.Times(1)
|
||||
.WillOnce(InvokeWithoutArgs(makeGeneralFailure));
|
||||
|
@ -524,10 +541,10 @@ TEST(DeviceTest, getSupportedOperationsError) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getSupportedOperationsTransportFailure) {
|
||||
TEST_P(DeviceTest, getSupportedOperationsTransportFailure) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, getSupportedOperations(_, _))
|
||||
.Times(1)
|
||||
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
|
||||
|
@ -540,10 +557,10 @@ TEST(DeviceTest, getSupportedOperationsTransportFailure) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, getSupportedOperationsDeadObject) {
|
||||
TEST_P(DeviceTest, getSupportedOperationsDeadObject) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, getSupportedOperations(_, _))
|
||||
.Times(1)
|
||||
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
|
||||
|
@ -556,10 +573,10 @@ TEST(DeviceTest, getSupportedOperationsDeadObject) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, prepareModel) {
|
||||
TEST_P(DeviceTest, prepareModel) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
const auto mockPreparedModel = MockPreparedModel::create();
|
||||
EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _))
|
||||
.Times(1)
|
||||
|
@ -576,10 +593,10 @@ TEST(DeviceTest, prepareModel) {
|
|||
EXPECT_NE(result.value(), nullptr);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, prepareModelLaunchError) {
|
||||
TEST_P(DeviceTest, prepareModelLaunchError) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(Invoke(makePreparedModelReturn(ErrorStatus::GENERAL_FAILURE,
|
||||
|
@ -594,10 +611,10 @@ TEST(DeviceTest, prepareModelLaunchError) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, prepareModelReturnError) {
|
||||
TEST_P(DeviceTest, prepareModelReturnError) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(Invoke(makePreparedModelReturn(ErrorStatus::NONE,
|
||||
|
@ -612,10 +629,10 @@ TEST(DeviceTest, prepareModelReturnError) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, prepareModelNullptrError) {
|
||||
TEST_P(DeviceTest, prepareModelNullptrError) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(
|
||||
|
@ -630,10 +647,10 @@ TEST(DeviceTest, prepareModelNullptrError) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, prepareModelTransportFailure) {
|
||||
TEST_P(DeviceTest, prepareModelTransportFailure) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
|
||||
|
@ -647,10 +664,10 @@ TEST(DeviceTest, prepareModelTransportFailure) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, prepareModelDeadObject) {
|
||||
TEST_P(DeviceTest, prepareModelDeadObject) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
|
||||
|
@ -664,10 +681,10 @@ TEST(DeviceTest, prepareModelDeadObject) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, prepareModelAsyncCrash) {
|
||||
TEST_P(DeviceTest, prepareModelAsyncCrash) {
|
||||
// setup test
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
const auto ret = [&device]() {
|
||||
DeathMonitor::serviceDied(device->getDeathMonitor());
|
||||
return ndk::ScopedAStatus::ok();
|
||||
|
@ -685,10 +702,10 @@ TEST(DeviceTest, prepareModelAsyncCrash) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, prepareModelFromCache) {
|
||||
TEST_P(DeviceTest, prepareModelFromCache) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
const auto mockPreparedModel = MockPreparedModel::create();
|
||||
EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _))
|
||||
.Times(1)
|
||||
|
@ -704,10 +721,10 @@ TEST(DeviceTest, prepareModelFromCache) {
|
|||
EXPECT_NE(result.value(), nullptr);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, prepareModelFromCacheLaunchError) {
|
||||
TEST_P(DeviceTest, prepareModelFromCacheLaunchError) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(Invoke(makePreparedModelFromCacheReturn(
|
||||
|
@ -721,10 +738,10 @@ TEST(DeviceTest, prepareModelFromCacheLaunchError) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, prepareModelFromCacheReturnError) {
|
||||
TEST_P(DeviceTest, prepareModelFromCacheReturnError) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(Invoke(makePreparedModelFromCacheReturn(
|
||||
|
@ -738,10 +755,10 @@ TEST(DeviceTest, prepareModelFromCacheReturnError) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, prepareModelFromCacheNullptrError) {
|
||||
TEST_P(DeviceTest, prepareModelFromCacheNullptrError) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(Invoke(makePreparedModelFromCacheReturn(ErrorStatus::NONE, ErrorStatus::NONE,
|
||||
|
@ -755,10 +772,10 @@ TEST(DeviceTest, prepareModelFromCacheNullptrError) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, prepareModelFromCacheTransportFailure) {
|
||||
TEST_P(DeviceTest, prepareModelFromCacheTransportFailure) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
|
||||
|
@ -771,10 +788,10 @@ TEST(DeviceTest, prepareModelFromCacheTransportFailure) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, prepareModelFromCacheDeadObject) {
|
||||
TEST_P(DeviceTest, prepareModelFromCacheDeadObject) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
|
||||
|
@ -787,10 +804,10 @@ TEST(DeviceTest, prepareModelFromCacheDeadObject) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, prepareModelFromCacheAsyncCrash) {
|
||||
TEST_P(DeviceTest, prepareModelFromCacheAsyncCrash) {
|
||||
// setup test
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
const auto ret = [&device]() {
|
||||
DeathMonitor::serviceDied(device->getDeathMonitor());
|
||||
return ndk::ScopedAStatus::ok();
|
||||
|
@ -807,10 +824,10 @@ TEST(DeviceTest, prepareModelFromCacheAsyncCrash) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, allocate) {
|
||||
TEST_P(DeviceTest, allocate) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
const auto mockBuffer = DeviceBuffer{.buffer = MockBuffer::create(), .token = 1};
|
||||
EXPECT_CALL(*mockDevice, allocate(_, _, _, _, _))
|
||||
.Times(1)
|
||||
|
@ -825,10 +842,10 @@ TEST(DeviceTest, allocate) {
|
|||
EXPECT_NE(result.value(), nullptr);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, allocateError) {
|
||||
TEST_P(DeviceTest, allocateError) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, allocate(_, _, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(InvokeWithoutArgs(makeGeneralFailure));
|
||||
|
@ -841,10 +858,10 @@ TEST(DeviceTest, allocateError) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, allocateTransportFailure) {
|
||||
TEST_P(DeviceTest, allocateTransportFailure) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, allocate(_, _, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
|
||||
|
@ -857,10 +874,10 @@ TEST(DeviceTest, allocateTransportFailure) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
|
||||
}
|
||||
|
||||
TEST(DeviceTest, allocateDeadObject) {
|
||||
TEST_P(DeviceTest, allocateDeadObject) {
|
||||
// setup call
|
||||
const auto mockDevice = createMockDevice();
|
||||
const auto device = Device::create(kName, mockDevice).value();
|
||||
const auto device = Device::create(kName, mockDevice, kVersion).value();
|
||||
EXPECT_CALL(*mockDevice, allocate(_, _, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
|
||||
|
@ -873,4 +890,8 @@ TEST(DeviceTest, allocateDeadObject) {
|
|||
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(TestDevice, DeviceTest,
|
||||
::testing::Values(nn::Version::ANDROID_S, nn::Version::FEATURE_LEVEL_6),
|
||||
printDeviceTest);
|
||||
|
||||
} // namespace aidl::android::hardware::neuralnetworks::utils
|
||||
|
|
|
@ -26,6 +26,7 @@ package {
|
|||
cc_test {
|
||||
name: "VtsHalNeuralnetworksTargetTest",
|
||||
defaults: [
|
||||
"neuralnetworks_use_latest_utils_hal_aidl",
|
||||
"neuralnetworks_vts_functional_defaults",
|
||||
"use_libaidlvintf_gtest_helper_static",
|
||||
],
|
||||
|
@ -51,16 +52,14 @@ cc_test {
|
|||
static_libs: [
|
||||
"android.hardware.common-V2-ndk",
|
||||
"android.hardware.graphics.common-V2-ndk",
|
||||
"android.hardware.neuralnetworks-V2-ndk",
|
||||
"android.hidl.allocator@1.0",
|
||||
"android.hidl.memory@1.0",
|
||||
"libaidlcommonsupport",
|
||||
"libgmock",
|
||||
"libhidlmemory",
|
||||
"libneuralnetworks_common",
|
||||
"libneuralnetworks_generated_test_harness",
|
||||
"libneuralnetworks_utils",
|
||||
"libsync",
|
||||
"neuralnetworks_utils_hal_aidl",
|
||||
],
|
||||
whole_static_libs: [
|
||||
"neuralnetworks_generated_V1_0_example",
|
||||
|
|
|
@ -35,7 +35,6 @@ cc_library_static {
|
|||
"neuralnetworks_types",
|
||||
],
|
||||
shared_libs: [
|
||||
"android.hardware.neuralnetworks-V2-ndk",
|
||||
"libhidlbase",
|
||||
"libbinder_ndk",
|
||||
],
|
||||
|
@ -53,7 +52,7 @@ cc_test {
|
|||
static_libs: [
|
||||
"android.hardware.neuralnetworks@1.0",
|
||||
"libgmock",
|
||||
"libneuralnetworks_common",
|
||||
"libneuralnetworks_common_hidl",
|
||||
"neuralnetworks_types",
|
||||
"neuralnetworks_utils_hal_common",
|
||||
],
|
||||
|
|
|
@ -25,7 +25,10 @@ package {
|
|||
|
||||
cc_library_static {
|
||||
name: "neuralnetworks_utils_hal_service",
|
||||
defaults: ["neuralnetworks_utils_defaults"],
|
||||
defaults: [
|
||||
"neuralnetworks_use_latest_utils_hal_aidl",
|
||||
"neuralnetworks_utils_defaults",
|
||||
],
|
||||
srcs: ["src/*"],
|
||||
local_include_dirs: ["include/nnapi/hal"],
|
||||
export_include_dirs: ["include"],
|
||||
|
@ -35,11 +38,9 @@ cc_library_static {
|
|||
"neuralnetworks_utils_hal_1_1",
|
||||
"neuralnetworks_utils_hal_1_2",
|
||||
"neuralnetworks_utils_hal_1_3",
|
||||
"neuralnetworks_utils_hal_aidl",
|
||||
"neuralnetworks_utils_hal_common",
|
||||
],
|
||||
shared_libs: [
|
||||
"android.hardware.neuralnetworks-V2-ndk",
|
||||
"android.hardware.neuralnetworks@1.0",
|
||||
"android.hardware.neuralnetworks@1.1",
|
||||
"android.hardware.neuralnetworks@1.2",
|
||||
|
|
Loading…
Reference in a new issue