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

Commit c5699bca authored by Michael Butler's avatar Michael Butler Committed by Automerger Merge Worker
Browse files

Merge "Make VtsHalNeuralnetworksTargetTest run on the host" am: 8f255182 am: ca13a2b7

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

Change-Id: I7b5b16726fadee33cd83520fe001b925e1cc22ab
parents 1a2c9ab2 ca13a2b7
Loading
Loading
Loading
Loading
+30 −8
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ cc_test {
        "neuralnetworks_vts_functional_defaults",
        "use_libaidlvintf_gtest_helper_static",
    ],
    host_supported: true,
    srcs: [
        "BasicTests.cpp",
        "Callbacks.cpp",
@@ -46,18 +47,11 @@ cc_test {
    ],
    shared_libs: [
        "libbinder_ndk",
        "libnativewindow",
        "libvndksupport",
    ],
    static_libs: [
        "android.hidl.allocator@1.0",
        "android.hidl.memory@1.0",
        "libaidlcommonsupport",
        "libgmock",
        "libhidlmemory",
        "libneuralnetworks_common",
        "libneuralnetworks_generated_test_harness",
        "libsync",
    ],
    whole_static_libs: [
        "neuralnetworks_generated_AIDL_V3_example",
@@ -73,6 +67,34 @@ cc_test {
    ],
    test_suites: [
        "general-tests",
    ],
    target: {
        android: {
            shared_libs: [
                "libnativewindow",
                "libvndksupport",
            ],
            static_libs: [
                "libsync",
            ],
            test_suites: [
                "vts",
            ],
            test_config: "AndroidTestDevice.xml",
        },
        host: {
            shared_libs: [
                "libtextclassifier_hash",
            ],
            static_libs: [
                "neuralnetworks_canonical_sample_driver",
                "neuralnetworks_utils_hal_adapter_aidl",
            ],
            exclude_static_libs: [
                "VtsHalHidlTestUtils",
                "libaidlvintf_gtest_helper",
            ],
            test_config: "AndroidTestHost.xml",
        },
    },
}
+22 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2022 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<configuration description="Runs VtsHalNeuralnetworksTargetTest.">
    <test class="com.android.tradefed.testtype.HostGTest" >
        <option name="module-name" value="VtsHalNeuralnetworksTargetTest" />
        <option name="native-test-timeout" value="15m" />
    </test>
</configuration>
+4 −2
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@
#include <fcntl.h>
#include <ftw.h>
#include <gtest/gtest.h>
#include <hidlmemory/mapping.h>
#include <unistd.h>

#include <cstdio>
@@ -34,7 +33,6 @@

#include "Callbacks.h"
#include "GeneratedTestHarness.h"
#include "MemoryUtils.h"
#include "TestHarness.h"
#include "Utils.h"
#include "VtsHalNeuralnetworks.h"
@@ -229,7 +227,11 @@ class CompilationCachingTestBase : public testing::Test {

        // Create cache directory. The cache directory and a temporary cache file is always created
        // to test the behavior of prepareModelFromCache, even when caching is not supported.
#ifdef __ANDROID__
        char cacheDirTemp[] = "/data/local/tmp/TestCompilationCachingXXXXXX";
#else   // __ANDROID__
        char cacheDirTemp[] = "/tmp/TestCompilationCachingXXXXXX";
#endif  // __ANDROID__
        char* cacheDir = mkdtemp(cacheDirTemp);
        ASSERT_NE(cacheDir, nullptr);
        mCacheDir = cacheDir;
+13 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
#include <aidl/android/hardware/neuralnetworks/RequestMemoryPool.h>
#include <android-base/logging.h>
#include <android/binder_auto_utils.h>
#include <android/sync.h>
#include <gtest/gtest.h>

#include <algorithm>
@@ -30,7 +29,6 @@
#include <numeric>
#include <vector>

#include <MemoryUtils.h>
#include <android/binder_status.h>
#include <nnapi/Result.h>
#include <nnapi/SharedMemory.h>
@@ -43,6 +41,10 @@
#include "Utils.h"
#include "VtsHalNeuralnetworks.h"

#ifdef __ANDROID__
#include <android/sync.h>
#endif  // __ANDROID__

namespace aidl::android::hardware::neuralnetworks::vts::functional {

namespace nn = ::android::nn;
@@ -281,10 +283,14 @@ void copyTestBuffers(const std::vector<const TestBuffer*>& buffers, uint8_t* out
}  // namespace

void waitForSyncFence(int syncFd) {
    constexpr int kInfiniteTimeout = -1;
    ASSERT_GT(syncFd, 0);
#ifdef __ANDROID__
    constexpr int kInfiniteTimeout = -1;
    int r = sync_wait(syncFd, kInfiniteTimeout);
    ASSERT_GE(r, 0);
#else   // __ANDROID__
    LOG(FATAL) << "waitForSyncFence not supported on host";
#endif  // __ANDROID__
}

Model createModel(const TestModel& testModel) {
@@ -895,7 +901,11 @@ void EvaluatePreparedModel(const std::shared_ptr<IDevice>& device,
            outputTypesList = {OutputType::FULLY_SPECIFIED};
            measureTimingList = {false};
            executorList = {Executor::SYNC, Executor::BURST, Executor::FENCED};
#ifdef __ANDROID__
            memoryTypeList = {MemoryType::BLOB_AHWB, MemoryType::DEVICE};
#else   // __ANDROID__
            memoryTypeList = {MemoryType::DEVICE};  // BLOB_AHWB is not supported on the host.
#endif  // __ANDROID__
        } break;
        case TestKind::FENCED_COMPUTE: {
            outputTypesList = {OutputType::FULLY_SPECIFIED};
Loading