Revert "Provide explicitly versioned NNAPI AIDL utils libs -- HAL." am: c42a934ea8 am: 542eaadcc2 am: c1701d8849

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1870083

Change-Id: I5ca60945d9caecb5b2d239a9762d698ec38c8a2b
This commit is contained in:
Michael Butler 2021-10-26 05:22:49 +00:00 committed by Automerger Merge Worker
commit 2483116704
16 changed files with 127 additions and 203 deletions

View file

@ -49,7 +49,7 @@ cc_test {
static_libs: [ static_libs: [
"android.hardware.neuralnetworks@1.0", "android.hardware.neuralnetworks@1.0",
"libgmock", "libgmock",
"libneuralnetworks_common_hidl", "libneuralnetworks_common",
"neuralnetworks_types", "neuralnetworks_types",
"neuralnetworks_utils_hal_common", "neuralnetworks_utils_hal_common",
"neuralnetworks_utils_hal_1_0", "neuralnetworks_utils_hal_1_0",

View file

@ -50,7 +50,7 @@ cc_library_static {
"libgmock", "libgmock",
"libhidlmemory", "libhidlmemory",
"libneuralnetworks_generated_test_harness", "libneuralnetworks_generated_test_harness",
"libneuralnetworks_common_hidl", "libneuralnetworks_utils",
], ],
header_libs: [ header_libs: [
"libneuralnetworks_headers", "libneuralnetworks_headers",
@ -81,7 +81,7 @@ cc_test {
"libgmock", "libgmock",
"libhidlmemory", "libhidlmemory",
"libneuralnetworks_generated_test_harness", "libneuralnetworks_generated_test_harness",
"libneuralnetworks_common_hidl", "libneuralnetworks_utils",
], ],
whole_static_libs: [ whole_static_libs: [
"neuralnetworks_generated_V1_0_example", "neuralnetworks_generated_V1_0_example",

View file

@ -52,7 +52,7 @@ cc_test {
"android.hardware.neuralnetworks@1.0", "android.hardware.neuralnetworks@1.0",
"android.hardware.neuralnetworks@1.1", "android.hardware.neuralnetworks@1.1",
"libgmock", "libgmock",
"libneuralnetworks_common_hidl", "libneuralnetworks_common",
"neuralnetworks_types", "neuralnetworks_types",
"neuralnetworks_utils_hal_common", "neuralnetworks_utils_hal_common",
"neuralnetworks_utils_hal_1_0", "neuralnetworks_utils_hal_1_0",

View file

@ -48,7 +48,7 @@ cc_test {
"libgmock", "libgmock",
"libhidlmemory", "libhidlmemory",
"libneuralnetworks_generated_test_harness", "libneuralnetworks_generated_test_harness",
"libneuralnetworks_common_hidl", "libneuralnetworks_utils",
], ],
whole_static_libs: [ whole_static_libs: [
"neuralnetworks_generated_V1_0_example", "neuralnetworks_generated_V1_0_example",

View file

@ -71,7 +71,7 @@ cc_test {
"android.hardware.neuralnetworks@1.1", "android.hardware.neuralnetworks@1.1",
"android.hardware.neuralnetworks@1.2", "android.hardware.neuralnetworks@1.2",
"libgmock", "libgmock",
"libneuralnetworks_common_hidl", "libneuralnetworks_common",
"neuralnetworks_types", "neuralnetworks_types",
"neuralnetworks_utils_hal_common", "neuralnetworks_utils_hal_common",
"neuralnetworks_utils_hal_1_0", "neuralnetworks_utils_hal_1_0",

View file

@ -71,7 +71,7 @@ cc_test {
"libgmock", "libgmock",
"libhidlmemory", "libhidlmemory",
"libneuralnetworks_generated_test_harness", "libneuralnetworks_generated_test_harness",
"libneuralnetworks_common_hidl", "libneuralnetworks_utils",
], ],
whole_static_libs: [ whole_static_libs: [
"neuralnetworks_generated_V1_0_example", "neuralnetworks_generated_V1_0_example",

View file

@ -69,7 +69,7 @@ cc_test {
"android.hardware.neuralnetworks@1.2", "android.hardware.neuralnetworks@1.2",
"android.hardware.neuralnetworks@1.3", "android.hardware.neuralnetworks@1.3",
"libgmock", "libgmock",
"libneuralnetworks_common_hidl", "libneuralnetworks_common",
"neuralnetworks_types", "neuralnetworks_types",
"neuralnetworks_utils_hal_common", "neuralnetworks_utils_hal_common",
"neuralnetworks_utils_hal_1_0", "neuralnetworks_utils_hal_1_0",

View file

@ -66,6 +66,7 @@ cc_test {
"VtsHalNeuralNetworksV1_0_utils", "VtsHalNeuralNetworksV1_0_utils",
"VtsHalNeuralNetworksV1_2_utils", "VtsHalNeuralNetworksV1_2_utils",
"VtsHalNeuralNetworksV1_3_utils", "VtsHalNeuralNetworksV1_3_utils",
"android.hardware.neuralnetworks-V2-ndk",
"android.hardware.neuralnetworks@1.0", "android.hardware.neuralnetworks@1.0",
"android.hardware.neuralnetworks@1.1", "android.hardware.neuralnetworks@1.1",
"android.hardware.neuralnetworks@1.2", "android.hardware.neuralnetworks@1.2",
@ -75,7 +76,7 @@ cc_test {
"libgmock", "libgmock",
"libhidlmemory", "libhidlmemory",
"libneuralnetworks_generated_test_harness", "libneuralnetworks_generated_test_harness",
"libneuralnetworks_common_hidl", "libneuralnetworks_utils",
"libsync", "libsync",
], ],
whole_static_libs: [ whole_static_libs: [

View file

@ -23,8 +23,8 @@ package {
default_applicable_licenses: ["hardware_interfaces_license"], default_applicable_licenses: ["hardware_interfaces_license"],
} }
cc_defaults { cc_library_static {
name: "neuralnetworks_utils_hal_aidl_defaults", name: "neuralnetworks_utils_hal_aidl",
defaults: ["neuralnetworks_utils_defaults"], defaults: ["neuralnetworks_utils_defaults"],
srcs: ["src/*"], srcs: ["src/*"],
local_include_dirs: ["include/nnapi/hal/aidl/"], local_include_dirs: ["include/nnapi/hal/aidl/"],
@ -38,6 +38,7 @@ cc_defaults {
"neuralnetworks_utils_hal_common", "neuralnetworks_utils_hal_common",
], ],
shared_libs: [ shared_libs: [
"android.hardware.neuralnetworks-V2-ndk",
"libbinder_ndk", "libbinder_ndk",
"libhidlbase", "libhidlbase",
], ],
@ -48,49 +49,21 @@ cc_defaults {
}, },
} }
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 { cc_test {
name: "neuralnetworks_utils_hal_aidl_test", name: "neuralnetworks_utils_hal_aidl_test",
defaults: [ defaults: ["neuralnetworks_utils_defaults"],
"neuralnetworks_use_latest_utils_hal_aidl",
"neuralnetworks_utils_defaults",
],
srcs: [ srcs: [
"test/*.cpp", "test/*.cpp",
], ],
static_libs: [ static_libs: [
"android.hardware.common-V2-ndk",
"android.hardware.graphics.common-V2-ndk",
"android.hardware.neuralnetworks-V2-ndk",
"libaidlcommonsupport", "libaidlcommonsupport",
"libgmock", "libgmock",
"libneuralnetworks_common", "libneuralnetworks_common",
"neuralnetworks_types", "neuralnetworks_types",
"neuralnetworks_utils_hal_aidl",
"neuralnetworks_utils_hal_common", "neuralnetworks_utils_hal_common",
], ],
shared_libs: [ shared_libs: [

View file

@ -43,12 +43,11 @@ class Device final : public nn::IDevice {
public: public:
static nn::GeneralResult<std::shared_ptr<const Device>> create( static nn::GeneralResult<std::shared_ptr<const Device>> create(
std::string name, std::shared_ptr<aidl_hal::IDevice> device, nn::Version featureLevel); std::string name, std::shared_ptr<aidl_hal::IDevice> device);
Device(PrivateConstructorTag tag, std::string name, std::string versionString, Device(PrivateConstructorTag tag, std::string name, std::string versionString,
nn::Version featureLevel, nn::DeviceType deviceType, nn::DeviceType deviceType, std::vector<nn::Extension> extensions,
std::vector<nn::Extension> extensions, nn::Capabilities capabilities, nn::Capabilities capabilities, std::pair<uint32_t, uint32_t> numberOfCacheFilesNeeded,
std::pair<uint32_t, uint32_t> numberOfCacheFilesNeeded,
std::shared_ptr<aidl_hal::IDevice> device, DeathHandler deathHandler); std::shared_ptr<aidl_hal::IDevice> device, DeathHandler deathHandler);
const std::string& getName() const override; const std::string& getName() const override;
@ -85,7 +84,6 @@ class Device final : public nn::IDevice {
private: private:
const std::string kName; const std::string kName;
const std::string kVersionString; const std::string kVersionString;
const nn::Version kFeatureLevel;
const nn::DeviceType kDeviceType; const nn::DeviceType kDeviceType;
const std::vector<nn::Extension> kExtensions; const std::vector<nn::Extension> kExtensions;
const nn::Capabilities kCapabilities; const nn::Capabilities kCapabilities;

View file

@ -125,7 +125,7 @@ nn::GeneralResult<std::pair<uint32_t, uint32_t>> getNumberOfCacheFilesNeededFrom
} // namespace } // namespace
nn::GeneralResult<std::shared_ptr<const Device>> Device::create( nn::GeneralResult<std::shared_ptr<const Device>> Device::create(
std::string name, std::shared_ptr<aidl_hal::IDevice> device, nn::Version featureLevel) { std::string name, std::shared_ptr<aidl_hal::IDevice> device) {
if (name.empty()) { if (name.empty()) {
return NN_ERROR(nn::ErrorStatus::INVALID_ARGUMENT) return NN_ERROR(nn::ErrorStatus::INVALID_ARGUMENT)
<< "aidl_hal::utils::Device::create must have non-empty name"; << "aidl_hal::utils::Device::create must have non-empty name";
@ -143,19 +143,18 @@ nn::GeneralResult<std::shared_ptr<const Device>> Device::create(
auto deathHandler = NN_TRY(DeathHandler::create(device)); auto deathHandler = NN_TRY(DeathHandler::create(device));
return std::make_shared<const Device>( return std::make_shared<const Device>(
PrivateConstructorTag{}, std::move(name), std::move(versionString), featureLevel, PrivateConstructorTag{}, std::move(name), std::move(versionString), deviceType,
deviceType, std::move(extensions), std::move(capabilities), numberOfCacheFilesNeeded, std::move(extensions), std::move(capabilities), numberOfCacheFilesNeeded,
std::move(device), std::move(deathHandler)); std::move(device), std::move(deathHandler));
} }
Device::Device(PrivateConstructorTag /*tag*/, std::string name, std::string versionString, Device::Device(PrivateConstructorTag /*tag*/, std::string name, std::string versionString,
nn::Version featureLevel, nn::DeviceType deviceType, nn::DeviceType deviceType, std::vector<nn::Extension> extensions,
std::vector<nn::Extension> extensions, nn::Capabilities capabilities, nn::Capabilities capabilities,
std::pair<uint32_t, uint32_t> numberOfCacheFilesNeeded, std::pair<uint32_t, uint32_t> numberOfCacheFilesNeeded,
std::shared_ptr<aidl_hal::IDevice> device, DeathHandler deathHandler) std::shared_ptr<aidl_hal::IDevice> device, DeathHandler deathHandler)
: kName(std::move(name)), : kName(std::move(name)),
kVersionString(std::move(versionString)), kVersionString(std::move(versionString)),
kFeatureLevel(featureLevel),
kDeviceType(deviceType), kDeviceType(deviceType),
kExtensions(std::move(extensions)), kExtensions(std::move(extensions)),
kCapabilities(std::move(capabilities)), kCapabilities(std::move(capabilities)),
@ -172,7 +171,7 @@ const std::string& Device::getVersionString() const {
} }
nn::Version Device::getFeatureLevel() const { nn::Version Device::getFeatureLevel() const {
return kFeatureLevel; return nn::Version::ANDROID_S;
} }
nn::DeviceType Device::getType() const { nn::DeviceType Device::getType() const {

View file

@ -17,7 +17,6 @@
#include "Service.h" #include "Service.h"
#include <AndroidVersionUtil.h> #include <AndroidVersionUtil.h>
#include <aidl/android/hardware/neuralnetworks/IDevice.h>
#include <android/binder_auto_utils.h> #include <android/binder_auto_utils.h>
#include <android/binder_manager.h> #include <android/binder_manager.h>
#include <android/binder_process.h> #include <android/binder_process.h>
@ -29,33 +28,8 @@
#include <string> #include <string>
#include "Device.h" #include "Device.h"
#include "Utils.h"
namespace aidl::android::hardware::neuralnetworks::utils { 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) { nn::GeneralResult<nn::SharedDevice> getDevice(const std::string& instanceName) {
auto fullName = std::string(IDevice::descriptor) + "/" + instanceName; auto fullName = std::string(IDevice::descriptor) + "/" + instanceName;
@ -81,8 +55,7 @@ nn::GeneralResult<nn::SharedDevice> getDevice(const std::string& instanceName) {
<< " returned nullptr"; << " returned nullptr";
} }
ABinderProcess_startThreadPool(); ABinderProcess_startThreadPool();
const auto featureLevel = NN_TRY(getAidlServiceFeatureLevel(service.get())); return Device::create(instanceName, std::move(service));
return Device::create(instanceName, std::move(service), featureLevel);
}; };
return hal::utils::ResilientDevice::create(std::move(makeDevice)); return hal::utils::ResilientDevice::create(std::move(makeDevice));

View file

@ -146,45 +146,28 @@ constexpr auto makeDeadObjectFailure = [] {
return ndk::ScopedAStatus::fromStatus(STATUS_DEAD_OBJECT); 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 } // namespace
TEST_P(DeviceTest, invalidName) { TEST(DeviceTest, invalidName) {
// run test // run test
const auto device = MockDevice::create(); const auto device = MockDevice::create();
const auto result = Device::create(kInvalidName, device, kVersion); const auto result = Device::create(kInvalidName, device);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::INVALID_ARGUMENT); EXPECT_EQ(result.error().code, nn::ErrorStatus::INVALID_ARGUMENT);
} }
TEST_P(DeviceTest, invalidDevice) { TEST(DeviceTest, invalidDevice) {
// run test // run test
const auto result = Device::create(kName, kInvalidDevice, kVersion); const auto result = Device::create(kName, kInvalidDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::INVALID_ARGUMENT); EXPECT_EQ(result.error().code, nn::ErrorStatus::INVALID_ARGUMENT);
} }
TEST_P(DeviceTest, getVersionStringError) { TEST(DeviceTest, getVersionStringError) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getVersionString(_)) EXPECT_CALL(*mockDevice, getVersionString(_))
@ -192,14 +175,14 @@ TEST_P(DeviceTest, getVersionStringError) {
.WillOnce(InvokeWithoutArgs(makeGeneralFailure)); .WillOnce(InvokeWithoutArgs(makeGeneralFailure));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, getVersionStringTransportFailure) { TEST(DeviceTest, getVersionStringTransportFailure) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getVersionString(_)) EXPECT_CALL(*mockDevice, getVersionString(_))
@ -207,14 +190,14 @@ TEST_P(DeviceTest, getVersionStringTransportFailure) {
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, getVersionStringDeadObject) { TEST(DeviceTest, getVersionStringDeadObject) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getVersionString(_)) EXPECT_CALL(*mockDevice, getVersionString(_))
@ -222,27 +205,27 @@ TEST_P(DeviceTest, getVersionStringDeadObject) {
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
} }
TEST_P(DeviceTest, getTypeError) { TEST(DeviceTest, getTypeError) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getType(_)).Times(1).WillOnce(InvokeWithoutArgs(makeGeneralFailure)); EXPECT_CALL(*mockDevice, getType(_)).Times(1).WillOnce(InvokeWithoutArgs(makeGeneralFailure));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, getTypeTransportFailure) { TEST(DeviceTest, getTypeTransportFailure) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getType(_)) EXPECT_CALL(*mockDevice, getType(_))
@ -250,14 +233,14 @@ TEST_P(DeviceTest, getTypeTransportFailure) {
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, getTypeDeadObject) { TEST(DeviceTest, getTypeDeadObject) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getType(_)) EXPECT_CALL(*mockDevice, getType(_))
@ -265,14 +248,14 @@ TEST_P(DeviceTest, getTypeDeadObject) {
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
} }
TEST_P(DeviceTest, getSupportedExtensionsError) { TEST(DeviceTest, getSupportedExtensionsError) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getSupportedExtensions(_)) EXPECT_CALL(*mockDevice, getSupportedExtensions(_))
@ -280,14 +263,14 @@ TEST_P(DeviceTest, getSupportedExtensionsError) {
.WillOnce(InvokeWithoutArgs(makeGeneralFailure)); .WillOnce(InvokeWithoutArgs(makeGeneralFailure));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, getSupportedExtensionsTransportFailure) { TEST(DeviceTest, getSupportedExtensionsTransportFailure) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getSupportedExtensions(_)) EXPECT_CALL(*mockDevice, getSupportedExtensions(_))
@ -295,14 +278,14 @@ TEST_P(DeviceTest, getSupportedExtensionsTransportFailure) {
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, getSupportedExtensionsDeadObject) { TEST(DeviceTest, getSupportedExtensionsDeadObject) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getSupportedExtensions(_)) EXPECT_CALL(*mockDevice, getSupportedExtensions(_))
@ -310,20 +293,20 @@ TEST_P(DeviceTest, getSupportedExtensionsDeadObject) {
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
} }
TEST_P(DeviceTest, getNumberOfCacheFilesNeeded) { TEST(DeviceTest, getNumberOfCacheFilesNeeded) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)).Times(1); EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)).Times(1);
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_TRUE(result.has_value()); ASSERT_TRUE(result.has_value());
@ -332,7 +315,7 @@ TEST_P(DeviceTest, getNumberOfCacheFilesNeeded) {
EXPECT_EQ(result.value()->getNumberOfCacheFilesNeeded(), kNumberOfCacheFilesPair); EXPECT_EQ(result.value()->getNumberOfCacheFilesNeeded(), kNumberOfCacheFilesPair);
} }
TEST_P(DeviceTest, getNumberOfCacheFilesNeededError) { TEST(DeviceTest, getNumberOfCacheFilesNeededError) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)) EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_))
@ -340,14 +323,14 @@ TEST_P(DeviceTest, getNumberOfCacheFilesNeededError) {
.WillOnce(InvokeWithoutArgs(makeGeneralFailure)); .WillOnce(InvokeWithoutArgs(makeGeneralFailure));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, dataCacheFilesExceedsSpecifiedMax) { TEST(DeviceTest, dataCacheFilesExceedsSpecifiedMax) {
// setup test // setup test
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)) EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_))
@ -358,14 +341,14 @@ TEST_P(DeviceTest, dataCacheFilesExceedsSpecifiedMax) {
InvokeWithoutArgs(makeStatusOk))); InvokeWithoutArgs(makeStatusOk)));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, modelCacheFilesExceedsSpecifiedMax) { TEST(DeviceTest, modelCacheFilesExceedsSpecifiedMax) {
// setup test // setup test
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)) EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_))
@ -376,14 +359,14 @@ TEST_P(DeviceTest, modelCacheFilesExceedsSpecifiedMax) {
InvokeWithoutArgs(makeStatusOk))); InvokeWithoutArgs(makeStatusOk)));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, getNumberOfCacheFilesNeededTransportFailure) { TEST(DeviceTest, getNumberOfCacheFilesNeededTransportFailure) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)) EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_))
@ -391,14 +374,14 @@ TEST_P(DeviceTest, getNumberOfCacheFilesNeededTransportFailure) {
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, getNumberOfCacheFilesNeededDeadObject) { TEST(DeviceTest, getNumberOfCacheFilesNeededDeadObject) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)) EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_))
@ -406,14 +389,14 @@ TEST_P(DeviceTest, getNumberOfCacheFilesNeededDeadObject) {
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
} }
TEST_P(DeviceTest, getCapabilitiesError) { TEST(DeviceTest, getCapabilitiesError) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getCapabilities(_)) EXPECT_CALL(*mockDevice, getCapabilities(_))
@ -421,14 +404,14 @@ TEST_P(DeviceTest, getCapabilitiesError) {
.WillOnce(InvokeWithoutArgs(makeGeneralFailure)); .WillOnce(InvokeWithoutArgs(makeGeneralFailure));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, getCapabilitiesTransportFailure) { TEST(DeviceTest, getCapabilitiesTransportFailure) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getCapabilities(_)) EXPECT_CALL(*mockDevice, getCapabilities(_))
@ -436,14 +419,14 @@ TEST_P(DeviceTest, getCapabilitiesTransportFailure) {
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, getCapabilitiesDeadObject) { TEST(DeviceTest, getCapabilitiesDeadObject) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getCapabilities(_)) EXPECT_CALL(*mockDevice, getCapabilities(_))
@ -451,17 +434,17 @@ TEST_P(DeviceTest, getCapabilitiesDeadObject) {
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
// run test // run test
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
// verify result // verify result
ASSERT_FALSE(result.has_value()); ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
} }
TEST_P(DeviceTest, getName) { TEST(DeviceTest, getName) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
// run test // run test
const auto& name = device->getName(); const auto& name = device->getName();
@ -470,19 +453,19 @@ TEST_P(DeviceTest, getName) {
EXPECT_EQ(name, kName); EXPECT_EQ(name, kName);
} }
TEST_P(DeviceTest, getFeatureLevel) { TEST(DeviceTest, getFeatureLevel) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
// run test // run test
const auto featureLevel = device->getFeatureLevel(); const auto featureLevel = device->getFeatureLevel();
// verify result // verify result
EXPECT_EQ(featureLevel, kVersion); EXPECT_EQ(featureLevel, nn::Version::ANDROID_S);
} }
TEST_P(DeviceTest, getCachedData) { TEST(DeviceTest, getCachedData) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
EXPECT_CALL(*mockDevice, getVersionString(_)).Times(1); EXPECT_CALL(*mockDevice, getVersionString(_)).Times(1);
@ -491,7 +474,7 @@ TEST_P(DeviceTest, getCachedData) {
EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)).Times(1); EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)).Times(1);
EXPECT_CALL(*mockDevice, getCapabilities(_)).Times(1); EXPECT_CALL(*mockDevice, getCapabilities(_)).Times(1);
const auto result = Device::create(kName, mockDevice, kVersion); const auto result = Device::create(kName, mockDevice);
ASSERT_TRUE(result.has_value()) ASSERT_TRUE(result.has_value())
<< "Failed with " << result.error().code << ": " << result.error().message; << "Failed with " << result.error().code << ": " << result.error().message;
const auto& device = result.value(); const auto& device = result.value();
@ -504,10 +487,10 @@ TEST_P(DeviceTest, getCachedData) {
EXPECT_EQ(device->getCapabilities(), device->getCapabilities()); EXPECT_EQ(device->getCapabilities(), device->getCapabilities());
} }
TEST_P(DeviceTest, getSupportedOperations) { TEST(DeviceTest, getSupportedOperations) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, getSupportedOperations(_, _)) EXPECT_CALL(*mockDevice, getSupportedOperations(_, _))
.Times(1) .Times(1)
.WillOnce(DoAll( .WillOnce(DoAll(
@ -525,10 +508,10 @@ TEST_P(DeviceTest, getSupportedOperations) {
EXPECT_THAT(supportedOperations, Each(testing::IsTrue())); EXPECT_THAT(supportedOperations, Each(testing::IsTrue()));
} }
TEST_P(DeviceTest, getSupportedOperationsError) { TEST(DeviceTest, getSupportedOperationsError) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, getSupportedOperations(_, _)) EXPECT_CALL(*mockDevice, getSupportedOperations(_, _))
.Times(1) .Times(1)
.WillOnce(InvokeWithoutArgs(makeGeneralFailure)); .WillOnce(InvokeWithoutArgs(makeGeneralFailure));
@ -541,10 +524,10 @@ TEST_P(DeviceTest, getSupportedOperationsError) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, getSupportedOperationsTransportFailure) { TEST(DeviceTest, getSupportedOperationsTransportFailure) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, getSupportedOperations(_, _)) EXPECT_CALL(*mockDevice, getSupportedOperations(_, _))
.Times(1) .Times(1)
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
@ -557,10 +540,10 @@ TEST_P(DeviceTest, getSupportedOperationsTransportFailure) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, getSupportedOperationsDeadObject) { TEST(DeviceTest, getSupportedOperationsDeadObject) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, getSupportedOperations(_, _)) EXPECT_CALL(*mockDevice, getSupportedOperations(_, _))
.Times(1) .Times(1)
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
@ -573,10 +556,10 @@ TEST_P(DeviceTest, getSupportedOperationsDeadObject) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
} }
TEST_P(DeviceTest, prepareModel) { TEST(DeviceTest, prepareModel) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
const auto mockPreparedModel = MockPreparedModel::create(); const auto mockPreparedModel = MockPreparedModel::create();
EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _)) EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _))
.Times(1) .Times(1)
@ -593,10 +576,10 @@ TEST_P(DeviceTest, prepareModel) {
EXPECT_NE(result.value(), nullptr); EXPECT_NE(result.value(), nullptr);
} }
TEST_P(DeviceTest, prepareModelLaunchError) { TEST(DeviceTest, prepareModelLaunchError) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _)) EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _))
.Times(1) .Times(1)
.WillOnce(Invoke(makePreparedModelReturn(ErrorStatus::GENERAL_FAILURE, .WillOnce(Invoke(makePreparedModelReturn(ErrorStatus::GENERAL_FAILURE,
@ -611,10 +594,10 @@ TEST_P(DeviceTest, prepareModelLaunchError) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, prepareModelReturnError) { TEST(DeviceTest, prepareModelReturnError) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _)) EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _))
.Times(1) .Times(1)
.WillOnce(Invoke(makePreparedModelReturn(ErrorStatus::NONE, .WillOnce(Invoke(makePreparedModelReturn(ErrorStatus::NONE,
@ -629,10 +612,10 @@ TEST_P(DeviceTest, prepareModelReturnError) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, prepareModelNullptrError) { TEST(DeviceTest, prepareModelNullptrError) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _)) EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _))
.Times(1) .Times(1)
.WillOnce( .WillOnce(
@ -647,10 +630,10 @@ TEST_P(DeviceTest, prepareModelNullptrError) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, prepareModelTransportFailure) { TEST(DeviceTest, prepareModelTransportFailure) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _)) EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _))
.Times(1) .Times(1)
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
@ -664,10 +647,10 @@ TEST_P(DeviceTest, prepareModelTransportFailure) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, prepareModelDeadObject) { TEST(DeviceTest, prepareModelDeadObject) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _)) EXPECT_CALL(*mockDevice, prepareModel(_, _, _, _, _, _, _, _))
.Times(1) .Times(1)
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
@ -681,10 +664,10 @@ TEST_P(DeviceTest, prepareModelDeadObject) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
} }
TEST_P(DeviceTest, prepareModelAsyncCrash) { TEST(DeviceTest, prepareModelAsyncCrash) {
// setup test // setup test
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
const auto ret = [&device]() { const auto ret = [&device]() {
DeathMonitor::serviceDied(device->getDeathMonitor()); DeathMonitor::serviceDied(device->getDeathMonitor());
return ndk::ScopedAStatus::ok(); return ndk::ScopedAStatus::ok();
@ -702,10 +685,10 @@ TEST_P(DeviceTest, prepareModelAsyncCrash) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
} }
TEST_P(DeviceTest, prepareModelFromCache) { TEST(DeviceTest, prepareModelFromCache) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
const auto mockPreparedModel = MockPreparedModel::create(); const auto mockPreparedModel = MockPreparedModel::create();
EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _)) EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _))
.Times(1) .Times(1)
@ -721,10 +704,10 @@ TEST_P(DeviceTest, prepareModelFromCache) {
EXPECT_NE(result.value(), nullptr); EXPECT_NE(result.value(), nullptr);
} }
TEST_P(DeviceTest, prepareModelFromCacheLaunchError) { TEST(DeviceTest, prepareModelFromCacheLaunchError) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _)) EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _))
.Times(1) .Times(1)
.WillOnce(Invoke(makePreparedModelFromCacheReturn( .WillOnce(Invoke(makePreparedModelFromCacheReturn(
@ -738,10 +721,10 @@ TEST_P(DeviceTest, prepareModelFromCacheLaunchError) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, prepareModelFromCacheReturnError) { TEST(DeviceTest, prepareModelFromCacheReturnError) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _)) EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _))
.Times(1) .Times(1)
.WillOnce(Invoke(makePreparedModelFromCacheReturn( .WillOnce(Invoke(makePreparedModelFromCacheReturn(
@ -755,10 +738,10 @@ TEST_P(DeviceTest, prepareModelFromCacheReturnError) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, prepareModelFromCacheNullptrError) { TEST(DeviceTest, prepareModelFromCacheNullptrError) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _)) EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _))
.Times(1) .Times(1)
.WillOnce(Invoke(makePreparedModelFromCacheReturn(ErrorStatus::NONE, ErrorStatus::NONE, .WillOnce(Invoke(makePreparedModelFromCacheReturn(ErrorStatus::NONE, ErrorStatus::NONE,
@ -772,10 +755,10 @@ TEST_P(DeviceTest, prepareModelFromCacheNullptrError) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, prepareModelFromCacheTransportFailure) { TEST(DeviceTest, prepareModelFromCacheTransportFailure) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _)) EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _))
.Times(1) .Times(1)
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
@ -788,10 +771,10 @@ TEST_P(DeviceTest, prepareModelFromCacheTransportFailure) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, prepareModelFromCacheDeadObject) { TEST(DeviceTest, prepareModelFromCacheDeadObject) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _)) EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _, _))
.Times(1) .Times(1)
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
@ -804,10 +787,10 @@ TEST_P(DeviceTest, prepareModelFromCacheDeadObject) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
} }
TEST_P(DeviceTest, prepareModelFromCacheAsyncCrash) { TEST(DeviceTest, prepareModelFromCacheAsyncCrash) {
// setup test // setup test
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
const auto ret = [&device]() { const auto ret = [&device]() {
DeathMonitor::serviceDied(device->getDeathMonitor()); DeathMonitor::serviceDied(device->getDeathMonitor());
return ndk::ScopedAStatus::ok(); return ndk::ScopedAStatus::ok();
@ -824,10 +807,10 @@ TEST_P(DeviceTest, prepareModelFromCacheAsyncCrash) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
} }
TEST_P(DeviceTest, allocate) { TEST(DeviceTest, allocate) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
const auto mockBuffer = DeviceBuffer{.buffer = MockBuffer::create(), .token = 1}; const auto mockBuffer = DeviceBuffer{.buffer = MockBuffer::create(), .token = 1};
EXPECT_CALL(*mockDevice, allocate(_, _, _, _, _)) EXPECT_CALL(*mockDevice, allocate(_, _, _, _, _))
.Times(1) .Times(1)
@ -842,10 +825,10 @@ TEST_P(DeviceTest, allocate) {
EXPECT_NE(result.value(), nullptr); EXPECT_NE(result.value(), nullptr);
} }
TEST_P(DeviceTest, allocateError) { TEST(DeviceTest, allocateError) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, allocate(_, _, _, _, _)) EXPECT_CALL(*mockDevice, allocate(_, _, _, _, _))
.Times(1) .Times(1)
.WillOnce(InvokeWithoutArgs(makeGeneralFailure)); .WillOnce(InvokeWithoutArgs(makeGeneralFailure));
@ -858,10 +841,10 @@ TEST_P(DeviceTest, allocateError) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, allocateTransportFailure) { TEST(DeviceTest, allocateTransportFailure) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, allocate(_, _, _, _, _)) EXPECT_CALL(*mockDevice, allocate(_, _, _, _, _))
.Times(1) .Times(1)
.WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure)); .WillOnce(InvokeWithoutArgs(makeGeneralTransportFailure));
@ -874,10 +857,10 @@ TEST_P(DeviceTest, allocateTransportFailure) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE); EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
} }
TEST_P(DeviceTest, allocateDeadObject) { TEST(DeviceTest, allocateDeadObject) {
// setup call // setup call
const auto mockDevice = createMockDevice(); const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice, kVersion).value(); const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, allocate(_, _, _, _, _)) EXPECT_CALL(*mockDevice, allocate(_, _, _, _, _))
.Times(1) .Times(1)
.WillOnce(InvokeWithoutArgs(makeDeadObjectFailure)); .WillOnce(InvokeWithoutArgs(makeDeadObjectFailure));
@ -890,8 +873,4 @@ TEST_P(DeviceTest, allocateDeadObject) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT); 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 } // namespace aidl::android::hardware::neuralnetworks::utils

View file

@ -26,7 +26,6 @@ package {
cc_test { cc_test {
name: "VtsHalNeuralnetworksTargetTest", name: "VtsHalNeuralnetworksTargetTest",
defaults: [ defaults: [
"neuralnetworks_use_latest_utils_hal_aidl",
"neuralnetworks_vts_functional_defaults", "neuralnetworks_vts_functional_defaults",
"use_libaidlvintf_gtest_helper_static", "use_libaidlvintf_gtest_helper_static",
], ],
@ -52,14 +51,16 @@ cc_test {
static_libs: [ static_libs: [
"android.hardware.common-V2-ndk", "android.hardware.common-V2-ndk",
"android.hardware.graphics.common-V2-ndk", "android.hardware.graphics.common-V2-ndk",
"android.hardware.neuralnetworks-V2-ndk",
"android.hidl.allocator@1.0", "android.hidl.allocator@1.0",
"android.hidl.memory@1.0", "android.hidl.memory@1.0",
"libaidlcommonsupport", "libaidlcommonsupport",
"libgmock", "libgmock",
"libhidlmemory", "libhidlmemory",
"libneuralnetworks_common",
"libneuralnetworks_generated_test_harness", "libneuralnetworks_generated_test_harness",
"libneuralnetworks_utils",
"libsync", "libsync",
"neuralnetworks_utils_hal_aidl",
], ],
whole_static_libs: [ whole_static_libs: [
"neuralnetworks_generated_V1_0_example", "neuralnetworks_generated_V1_0_example",

View file

@ -35,6 +35,7 @@ cc_library_static {
"neuralnetworks_types", "neuralnetworks_types",
], ],
shared_libs: [ shared_libs: [
"android.hardware.neuralnetworks-V2-ndk",
"libhidlbase", "libhidlbase",
"libbinder_ndk", "libbinder_ndk",
], ],
@ -52,7 +53,7 @@ cc_test {
static_libs: [ static_libs: [
"android.hardware.neuralnetworks@1.0", "android.hardware.neuralnetworks@1.0",
"libgmock", "libgmock",
"libneuralnetworks_common_hidl", "libneuralnetworks_common",
"neuralnetworks_types", "neuralnetworks_types",
"neuralnetworks_utils_hal_common", "neuralnetworks_utils_hal_common",
], ],

View file

@ -25,10 +25,7 @@ package {
cc_library_static { cc_library_static {
name: "neuralnetworks_utils_hal_service", name: "neuralnetworks_utils_hal_service",
defaults: [ defaults: ["neuralnetworks_utils_defaults"],
"neuralnetworks_use_latest_utils_hal_aidl",
"neuralnetworks_utils_defaults",
],
srcs: ["src/*"], srcs: ["src/*"],
local_include_dirs: ["include/nnapi/hal"], local_include_dirs: ["include/nnapi/hal"],
export_include_dirs: ["include"], export_include_dirs: ["include"],
@ -38,9 +35,11 @@ cc_library_static {
"neuralnetworks_utils_hal_1_1", "neuralnetworks_utils_hal_1_1",
"neuralnetworks_utils_hal_1_2", "neuralnetworks_utils_hal_1_2",
"neuralnetworks_utils_hal_1_3", "neuralnetworks_utils_hal_1_3",
"neuralnetworks_utils_hal_aidl",
"neuralnetworks_utils_hal_common", "neuralnetworks_utils_hal_common",
], ],
shared_libs: [ shared_libs: [
"android.hardware.neuralnetworks-V2-ndk",
"android.hardware.neuralnetworks@1.0", "android.hardware.neuralnetworks@1.0",
"android.hardware.neuralnetworks@1.1", "android.hardware.neuralnetworks@1.1",
"android.hardware.neuralnetworks@1.2", "android.hardware.neuralnetworks@1.2",