summaryrefslogtreecommitdiff
path: root/neuralnetworks/aidl/utils/test/DeviceTest.cpp
diff options
context:
space:
mode:
authorLev Proleev <levp@google.com>2021-06-28 13:10:54 +0100
committerLev Proleev <levp@google.com>2021-06-28 16:11:43 +0100
commita31aff1aceee1551c7568a44481edfbc94576538 (patch)
treefd754cc9832256c2b04670d5a8769a5244236f0d /neuralnetworks/aidl/utils/test/DeviceTest.cpp
parent2e749339455083665428a0d91e350be7ad73c446 (diff)
Fix ordering of cache files requirements from device
Data and model numbers were switched in the AIDL implementation of canonical Device. Bug: 190757709 Test: neuralnetworks_utils_hal_aidl_test Change-Id: I0d95b2d436994ffc877a4e02eb31f449b983e61e Merged-In: I0d95b2d436994ffc877a4e02eb31f449b983e61e (cherry picked from commit 3fd4ec47060c3e55de54bcb6678160fb5bdd01e4)
Diffstat (limited to 'neuralnetworks/aidl/utils/test/DeviceTest.cpp')
-rw-r--r--neuralnetworks/aidl/utils/test/DeviceTest.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/neuralnetworks/aidl/utils/test/DeviceTest.cpp b/neuralnetworks/aidl/utils/test/DeviceTest.cpp
index e53b0a8df9..f121acaf7b 100644
--- a/neuralnetworks/aidl/utils/test/DeviceTest.cpp
+++ b/neuralnetworks/aidl/utils/test/DeviceTest.cpp
@@ -58,7 +58,7 @@ const std::string kInvalidName = "";
const std::shared_ptr<BnDevice> kInvalidDevice;
constexpr PerformanceInfo kNoPerformanceInfo = {.execTime = std::numeric_limits<float>::max(),
.powerUsage = std::numeric_limits<float>::max()};
-constexpr NumberOfCacheFiles kNumberOfCacheFiles = {.numModelCache = nn::kMaxNumberOfCacheFiles,
+constexpr NumberOfCacheFiles kNumberOfCacheFiles = {.numModelCache = nn::kMaxNumberOfCacheFiles - 1,
.numDataCache = nn::kMaxNumberOfCacheFiles};
constexpr auto makeStatusOk = [] { return ndk::ScopedAStatus::ok(); };
@@ -300,6 +300,21 @@ TEST(DeviceTest, getSupportedExtensionsDeadObject) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::DEAD_OBJECT);
}
+TEST(DeviceTest, getNumberOfCacheFilesNeeded) {
+ // setup call
+ const auto mockDevice = createMockDevice();
+ EXPECT_CALL(*mockDevice, getNumberOfCacheFilesNeeded(_)).Times(1);
+
+ // run test
+ const auto result = Device::create(kName, mockDevice);
+
+ // verify result
+ ASSERT_TRUE(result.has_value());
+ constexpr auto kNumberOfCacheFilesPair = std::make_pair<uint32_t, uint32_t>(
+ kNumberOfCacheFiles.numModelCache, kNumberOfCacheFiles.numDataCache);
+ EXPECT_EQ(result.value()->getNumberOfCacheFilesNeeded(), kNumberOfCacheFilesPair);
+}
+
TEST(DeviceTest, getNumberOfCacheFilesNeededError) {
// setup call
const auto mockDevice = createMockDevice();