From 29df40b3096284eab5d32015ea599010b4803b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8F=B6=E5=86=9B?= Date: Fri, 14 Jun 2024 10:43:11 +0800 Subject: [PATCH 1/6] =?UTF-8?q?UT=E7=94=A8=E4=BE=8B=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王叶军 --- test/unittest/common/mock_backend.h | 41 + test/unittest/components/BUILD.gn | 51 +- .../backend_manager/backend_manager_test.cpp | 72 ++ .../neural_network_core_test.cpp | 769 ++++++++++++++++++ .../neural_network_core_test.h | 52 ++ 5 files changed, 983 insertions(+), 2 deletions(-) create mode 100644 test/unittest/common/mock_backend.h create mode 100644 test/unittest/components/v1_0/backend_manager/backend_manager_test.cpp create mode 100644 test/unittest/components/v1_0/neural_network_core_test/neural_network_core_test.cpp create mode 100644 test/unittest/components/v1_0/neural_network_core_test/neural_network_core_test.h diff --git a/test/unittest/common/mock_backend.h b/test/unittest/common/mock_backend.h new file mode 100644 index 0000000..1a64a0e --- /dev/null +++ b/test/unittest/common/mock_backend.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * 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. + */ +#ifndef NEURAL_NETWORK_RUNTIME_MOCK_BACKEND_H +#define NEURAL_NETWORK_RUNTIME_MOCK_BACKEND_H + +#include + +#include +#include "backend.h" + +namespace OHOS { +namespace NeuralNetworkRuntime { +class MockBackend : public Backend { +public: + MOCK_METHOD(size_t, GetBackendID, (), (const, override)); + MOCK_METHOD(OH_NN_ReturnCode, GetBackendName, (std::string&), (const, override)); + MOCK_METHOD(OH_NN_ReturnCode, GetBackendType, (OH_NN_DeviceType&), (const, override)); + MOCK_METHOD(OH_NN_ReturnCode, GetBackendStatus, (DeviceStatus&), (const, override)); + MOCK_METHOD(Compiler*, CreateCompiler, (Compilation*), (override)); + MOCK_METHOD(OH_NN_ReturnCode, DestroyCompiler, (Compiler*), (override)); + MOCK_METHOD(Executor*, CreateExecutor, (Compilation*), (override)); + MOCK_METHOD(OH_NN_ReturnCode, DestroyExecutor, (Executor*), (override)); + MOCK_METHOD(Tensor*, CreateTensor, (TensorDesc*), (override)); + MOCK_METHOD(OH_NN_ReturnCode, DestroyTensor, (Tensor*), (override)); +}; +} // NeuralNetworkRuntime +} // OHOS + +#endif // NEURAL_NETWORK_RUNTIME_MOCK_BACKEND_H \ No newline at end of file diff --git a/test/unittest/components/BUILD.gn b/test/unittest/components/BUILD.gn index 9829dac..fe3f917 100644 --- a/test/unittest/components/BUILD.gn +++ b/test/unittest/components/BUILD.gn @@ -75,6 +75,28 @@ ohos_unittest("ExecutorV1_0Test") { ] } +ohos_unittest("BackendManagerV1_0Test") { + module_out_path = module_output_path + + sources = [ "./v1_0/backend_manager/backend_manager_test.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] +} + ohos_unittest("DeviceManagerV1_0Test") { module_out_path = module_output_path @@ -309,7 +331,7 @@ ohos_unittest("NeuralNetworkRuntimeV1_0Test") { module_out_path = module_output_path sources = - [ "./v1_0/neural_network_runtime_test/neural_network_runtime_test.cpp" ] + [ "./v1_0/neural_network_runtime_test/neural_network_runtime_test.cpp" ] sources += [ "../common/v1_0/executor_mock_device.cpp" ] configs = [ ":module_private_config" ] @@ -331,6 +353,29 @@ ohos_unittest("NeuralNetworkRuntimeV1_0Test") { ] } +ohos_unittest("NeuralNetworkCore1_0Test") { + module_out_path = module_output_path + + sources = [ "./v1_0/neural_network_core_test/neural_network_core_test.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] +} + ohos_unittest("CompilationV2_0Test") { module_out_path = module_output_path @@ -589,7 +634,7 @@ ohos_unittest("NeuralNetworkRuntimeV2_0Test") { module_out_path = module_output_path sources = - [ "./v2_0/neural_network_runtime_test/neural_network_runtime_test.cpp" ] + [ "./v2_0/neural_network_runtime_test/neural_network_runtime_test.cpp" ] sources += [ "../common/v2_0/executor_mock_device.cpp" ] configs = [ ":module_private_config" ] @@ -614,6 +659,7 @@ ohos_unittest("NeuralNetworkRuntimeV2_0Test") { group("components_unittest") { testonly = true deps = [ + ":BackendManagerV1_0Test", ":CompilationV1_0Test", ":CompilationV2_0Test", ":ExecutorV1_0Test", @@ -625,6 +671,7 @@ group("components_unittest") { ":InnerModelV1_0Test", ":InnerModelV2_0Test", ":MemoryManagerTest", + ":NeuralNetworkCore1_0Test", ":NeuralNetworkRuntimeV1_0Test", ":NeuralNetworkRuntimeV2_0Test", ":NnTensorV1_0Test", diff --git a/test/unittest/components/v1_0/backend_manager/backend_manager_test.cpp b/test/unittest/components/v1_0/backend_manager/backend_manager_test.cpp new file mode 100644 index 0000000..0113775 --- /dev/null +++ b/test/unittest/components/v1_0/backend_manager/backend_manager_test.cpp @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. + * 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. + */ + +#include +#include + +#include "common/log.h" +#include "backend_manager.h" +#include "test/unittest/common/mock_backend.h" + +using namespace testing; +using namespace testing::ext; +namespace OHOS { +namespace NeuralNetworkRuntime { +namespace UnitTest { +class BackendManagerTest : public testing::Test { +protected: +}; + +/** + * @tc.name: backendmanager_getbackend_001 + * @tc.desc: Verify the GetBackend function return nullptr in case of backendid invalid. + * @tc.type: FUNC + */ +HWTEST_F(BackendManagerTest, backendmanager_getbackend_001, TestSize.Level0) +{ + auto &backendManager = BackendManager::GetInstance(); + const size_t backendId = 1; + std::shared_ptr result = backendManager.GetBackend(backendId); + EXPECT_EQ(nullptr,result); +} + +/** +* @tc.name: backendmanager_registerbackend_001 +* @tc.desc: Verify the GetBackend function return nullptr in case of backendid invalid. +* @tc.type: FUNC +*/ +HWTEST_F(BackendManagerTest, backendmanager_registerbackend_001, TestSize.Level0) +{ + auto &backendManager = BackendManager::GetInstance(); + const size_t backendId = 2; + std::shared_ptr result = backendManager.GetBackend(backendId); + EXPECT_EQ(result->GetBackendID(), OH_NN_INVALID_PARAMETER); +} + +/** + * @tc.name: backendmanager_getbackendname_001 + * @tc.desc: Verify the GetBackend function return empty string in case of backendid invalid. + * @tc.type: FUNC + */ +HWTEST_F(BackendManagerTest, backendmanager_getbackendname_001, TestSize.Level0) +{ + auto &backendManager = BackendManager::GetInstance(); + const size_t backendId = 1; + std::string result = backendManager.GetBackendName(backendId); + EXPECT_EQ("", result); +} +} // namespace UnitTest +} // namespace NeuralNetworkRuntime +} // namespace OHOS diff --git a/test/unittest/components/v1_0/neural_network_core_test/neural_network_core_test.cpp b/test/unittest/components/v1_0/neural_network_core_test/neural_network_core_test.cpp new file mode 100644 index 0000000..09fb926 --- /dev/null +++ b/test/unittest/components/v1_0/neural_network_core_test/neural_network_core_test.cpp @@ -0,0 +1,769 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * 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. + */ + +#include +#include + +#include "common/utils.h" +#include "neural_network_core_test.h" +#include "compilation.h" +#include "interfaces/kits/c/neural_network_runtime/neural_network_core.h" + +namespace OHOS { +namespace NeuralNetworkRuntime { +namespace Unittest { +const size_t SIZE_ONE = 1; +OH_NN_ReturnCode NeuralNetworkCoreTest::BuildModel(InnerModel& model) +{ + int32_t inputDims[2] = {3, 4}; + OH_NN_Tensor input1 = {OH_NN_FLOAT32, 2, inputDims, nullptr, OH_NN_TENSOR}; + OH_NN_ReturnCode ret = model.AddTensor(input1); + if (ret != OH_NN_SUCCESS) { + return ret; + } + + // 添加Add算子的第二个输入Tensor,类型为float32,张量形状为[3, 4] + OH_NN_Tensor input2 = {OH_NN_FLOAT32, 2, inputDims, nullptr, OH_NN_TENSOR}; + ret = model.AddTensor(input2); + if (ret != OH_NN_SUCCESS) { + return ret; + } + + // 添加Add算子的参数Tensor,该参数Tensor用于指定激活函数的类型,Tensor的数据类型为int8。 + int32_t activationDims = 1; + int8_t activationValue = OH_NN_FUSED_NONE; + OH_NN_Tensor activation = {OH_NN_INT8, 1, &activationDims, nullptr, OH_NN_ADD_ACTIVATIONTYPE}; + ret = model.AddTensor(activation); + if (ret != OH_NN_SUCCESS) { + return ret; + } + + // 将激活函数类型设置为OH_NN_FUSED_NONE,表示该算子不添加激活函数。 + uint32_t index = 2; + ret = model.SetTensorValue(index, &activationValue, sizeof(int8_t)); + if (ret != OH_NN_SUCCESS) { + return ret; + } + + // 设置Add算子的输出,类型为float32,张量形状为[3, 4] + OH_NN_Tensor output = {OH_NN_FLOAT32, 2, inputDims, nullptr, OH_NN_TENSOR}; + ret = model.AddTensor(output); + if (ret != OH_NN_SUCCESS) { + return ret; + } + + // 指定Add算子的输入、参数和输出索引 + uint32_t inputIndicesValues[2] = {0, 1}; + uint32_t paramIndicesValues = 2; + uint32_t outputIndicesValues = 3; + OH_NN_UInt32Array paramIndices = {¶mIndicesValues, 1}; + OH_NN_UInt32Array inputIndices = {inputIndicesValues, 2}; + OH_NN_UInt32Array outputIndices = {&outputIndicesValues, 1}; + + // 向模型实例添加Add算子 + ret = model.AddOperation(OH_NN_OPS_ADD, paramIndices, inputIndices, outputIndices); + if (ret != OH_NN_SUCCESS) { + return ret; + } + + // 设置模型实例的输入、输出索引 + ret = model.SpecifyInputsAndOutputs(inputIndices, outputIndices); + if (ret != OH_NN_SUCCESS) { + return ret; + } + + // 完成模型实例的构建 + ret = model.Build(); + if (ret != OH_NN_SUCCESS) { + return ret; + } + + return ret; +} + +/* + * @tc.name: alldevicesid_001 + * @tc.desc: Verify the allDeviceIds is nullptr of the OH_NNDevice_GetAllDevicesID function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, alldevicesid_001, testing::ext::TestSize.Level0) +{ + + const size_t* allDeviceIds = nullptr; + uint32_t count {0}; + OH_NN_ReturnCode ret = OH_NNDevice_GetAllDevicesID(&allDeviceIds, &count); + EXPECT_EQ(OH_NN_SUCCESS, ret); +} + +/* + * @tc.name: alldeviceid_002 + * @tc.desc: Verify the allDeviceIds is nullptr of the OH_NNDevice_GetAllDevicesID function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, alldeviceid_002, testing::ext::TestSize.Level0) +{ + uint32_t count {0}; + OH_NN_ReturnCode ret = OH_NNDevice_GetAllDevicesID(nullptr, &count); + EXPECT_EQ(OH_NN_INVALID_PARAMETER,ret); +} + +/* + * @tc.name: alldeviceid_003 + * @tc.desc: Verify the allDeviceIds is nullptr of the OH_NNDevice_GetAllDevicesID function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, alldeviceid_003, testing::ext::TestSize.Level0) +{ + const size_t* allDeviceIds = nullptr; + OH_NN_ReturnCode ret = OH_NNDevice_GetAllDevicesID(&allDeviceIds, nullptr); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: alldeviceid_004 + * @tc.desc: Verify the allDeviceIds is nullptr of the OH_NNDevice_GetAllDevicesID function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, alldeviceid_004, testing::ext::TestSize.Level0) +{ + const size_t allDeviceIds = 0; + const size_t* pAllDeviceIds = &allDeviceIds; + uint32_t count {0}; + + OH_NN_ReturnCode ret = OH_NNDevice_GetAllDevicesID(&pAllDeviceIds, &count); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: device_name_001 + * @tc.desc: Verify the name is nullptr of the OH_NNDevice_GetName function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, device_name_001, testing::ext::TestSize.Level0) +{ + const size_t deviceId = 0; + const char* name = nullptr; + OH_NN_ReturnCode ret = OH_NNDevice_GetName(deviceId, &name); + EXPECT_EQ(OH_NN_FAILED, ret); +} + +/* + * @tc.name: device_name_002 + * @tc.desc: Verify the name is no nullptr of the OH_NNDevice_GetName function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, device_name_002, testing::ext::TestSize.Level0) +{ + const size_t deviceId = 0; + const char* name = "name"; + OH_NN_ReturnCode ret = OH_NNDevice_GetName(deviceId, &name); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: device_name_003 + * @tc.desc: Verify the name is nullptr of the OH_NNDevice_GetName function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, device_name_003, testing::ext::TestSize.Level0) +{ + const size_t deviceId = 0; + OH_NN_ReturnCode ret = OH_NNDevice_GetName(deviceId, nullptr); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: device_get_type_001 + * @tc.desc: Verify the device is nullptr of the OH_NNDevice_GetType function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, device_get_type_001, testing::ext::TestSize.Level0) +{ + size_t deviceID = 0; + OH_NN_DeviceType deviceType = OH_NN_CPU; + OH_NN_DeviceType* pDeviceType = &deviceType; + OH_NN_ReturnCode ret = OH_NNDevice_GetType(deviceID, pDeviceType); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: device_get_type_002 + * @tc.desc: Verify the device is nullptr of the OH_NNDevice_GetType function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, device_get_type_002, testing::ext::TestSize.Level0) +{ + size_t deviceID = 0; + OH_NN_DeviceType* pDeviceType = nullptr; + OH_NN_ReturnCode ret = OH_NNDevice_GetType(deviceID, pDeviceType); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: compilation_construct_001 + * @tc.desc: Verify the OH_NNModel is nullptr of the OH_NNCompilation_Construct function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_construct_001, testing::ext::TestSize.Level0) +{ + const OH_NNModel* model = nullptr; + OH_NNCompilation* ret = OH_NNCompilation_Construct(model); + EXPECT_EQ(nullptr, ret); +} + +/* + * @tc.name: compilation_construct_with_off_modelfile_001 + * @tc.desc: Verify the modelpath is nullptr of the OH_NNCompilation_ConstructWithOfflineModelFile function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_construct_with_off_modelfile_001, testing::ext::TestSize.Level0) +{ + const char* modelpath = nullptr; + OH_NNCompilation* ret = OH_NNCompilation_ConstructWithOfflineModelFile(modelpath); + EXPECT_EQ(nullptr, ret); +} + +/* + * @tc.name: compilation_construct_with_off_modelfile_002 + * @tc.desc: Verify the modelpath is no nullptr of the OH_NNCompilation_ConstructWithOfflineModelFile function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_construct_with_off_modelfile_002, testing::ext::TestSize.Level0) +{ + const char* modelpath = "nrrtmodel"; + OH_NNCompilation* ret = OH_NNCompilation_ConstructWithOfflineModelFile(modelpath); + EXPECT_NE(nullptr, ret); +} + +/* + * @tc.name: compilation_construct_with_off_modelbuffer_001 + * @tc.desc: Verify the modelbuffer is nullptr of the OH_NNCompilation_ConstructWithOfflineModelBuffer function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_construct_with_off_modelbuffer_001, testing::ext::TestSize.Level0) +{ + const void* modelbuffer = nullptr; + size_t modelsize = 0; + OH_NNCompilation* ret = OH_NNCompilation_ConstructWithOfflineModelBuffer(modelbuffer, modelsize); + EXPECT_EQ(nullptr, ret); +} + +/* + * @tc.name: compilation_construct_with_off_modelbuffer_002 + * @tc.desc: Verify the modelbuffer is no nullptr of the OH_NNCompilation_ConstructWithOfflineModelBuffer function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_construct_with_off_modelbuffer_002, testing::ext::TestSize.Level0) +{ + char modelbuffer[SIZE_ONE]; + size_t modelsize = 0; + OH_NNCompilation* ret = OH_NNCompilation_ConstructWithOfflineModelBuffer(modelbuffer, modelsize); + EXPECT_EQ(nullptr, ret); +} + +/* + * @tc.name: compilation_constructforcache_001 + * @tc.desc: Verify the nnCompilation is no nullptr of the OH_NNCompilation_ConstructForCache function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_constructforcache_001, testing::ext::TestSize.Level0) +{ + OH_NNCompilation* ret = OH_NNCompilation_ConstructForCache(); + Compilation *compilation = new (std::nothrow) Compilation(); + OH_NNCompilation* nnCompilation = reinterpret_cast(compilation); + EXPECT_NE(nnCompilation, ret); +} + +/* + * @tc.name: compilation_exportchachetobuffer_001 + * @tc.desc: Verify the compilation is nullptr of the OH_NNCompilation_ExportCacheToBuffer function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_exportchachetobuffer_001, testing::ext::TestSize.Level0) +{ + OH_NNCompilation* compilation = nullptr; + const void* buffer = nullptr; + size_t length = 0; + size_t* modelSize = nullptr; + OH_NN_ReturnCode ret = OH_NNCompilation_ExportCacheToBuffer(compilation, buffer, length, modelSize); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: compilation_exportchachetobuffer_002 + * @tc.desc: Verify the buffer is nullptr of the OH_NNCompilation_ExportCacheToBuffer function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_exportchachetobuffer_002, testing::ext::TestSize.Level0) +{ + Compilation *compilation = new (std::nothrow) Compilation(); + OH_NNCompilation* nnCompilation = reinterpret_cast(compilation); + const void* buffer = nullptr; + size_t length = 0; + size_t* modelSize = nullptr; + OH_NN_ReturnCode ret = OH_NNCompilation_ExportCacheToBuffer(nnCompilation, buffer, length, modelSize); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: compilation_exportchachetobuffer_003 + * @tc.desc: Verify the length is 0 of the OH_NNCompilation_ExportCacheToBuffer function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_exportchachetobuffer_003, testing::ext::TestSize.Level0) +{ + Compilation *compilation = new (std::nothrow) Compilation(); + OH_NNCompilation* nnCompilation = reinterpret_cast(compilation); + char buffer[SIZE_ONE]; + size_t length = 0; + size_t* modelSize = nullptr; + OH_NN_ReturnCode ret = OH_NNCompilation_ExportCacheToBuffer(nnCompilation, buffer, length, modelSize); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: compilation_exportchachetobuffer_004 + * @tc.desc: Verify the modelSize is nullptr of the OH_NNCompilation_ExportCacheToBuffer function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_exportchachetobuffer_004, testing::ext::TestSize.Level0) +{ + Compilation *compilation = new (std::nothrow) Compilation(); + OH_NNCompilation* nnCompilation = reinterpret_cast(compilation); + char buffer[SIZE_ONE]; + size_t length = 0; + size_t* modelSize = nullptr; + OH_NN_ReturnCode ret = OH_NNCompilation_ExportCacheToBuffer(nnCompilation, buffer, length, modelSize); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: compilation_exportchachetobuffer_005 + * @tc.desc: Verify the modelSize is nullptr of the OH_NNCompilation_ExportCacheToBuffer function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_exportchachetobuffer_005, testing::ext::TestSize.Level0) +{ + Compilation *compilation = new (std::nothrow) Compilation(); + OH_NNCompilation* nnCompilation = reinterpret_cast(compilation); + char buffer[SIZE_ONE]; + size_t* modelSize = nullptr; + OH_NN_ReturnCode ret = OH_NNCompilation_ExportCacheToBuffer(nnCompilation, buffer, SIZE_ONE, modelSize); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: compilation_exportchachetobuffer_006 + * @tc.desc: Verify the length is 0 of the OH_NNCompilation_ExportCacheToBuffer function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_exportchachetobuffer_006, testing::ext::TestSize.Level0) +{ + Compilation *compilation = new (std::nothrow) Compilation(); + OH_NNCompilation* nnCompilation = reinterpret_cast(compilation); + char buffer[SIZE_ONE]; + size_t modelSize = 0; + OH_NN_ReturnCode ret = OH_NNCompilation_ExportCacheToBuffer(nnCompilation, buffer, SIZE_ONE, &modelSize); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: compilation_importcachefrombuffer_001 + * @tc.desc: Verify the compilation is nullptr of the OH_NNCompilation_ImportCacheFromBuffer function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_importcachefrombuffer_001, testing::ext::TestSize.Level0) +{ + OH_NNCompilation* compilation = nullptr; + const void* buffer = nullptr; + size_t modelsize = 0; + OH_NN_ReturnCode ret = OH_NNCompilation_ImportCacheFromBuffer(compilation, buffer, modelsize); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: compilation_importcachefrombuffer_002 + * @tc.desc: Verify the buffer is nullptr of the OH_NNCompilation_ImportCacheFromBuffer function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_importcachefrombuffer_002, testing::ext::TestSize.Level0) +{ + Compilation *compilation = new (std::nothrow) Compilation(); + OH_NNCompilation* nnCompilation = reinterpret_cast(compilation); + const void* buffer = nullptr; + size_t modelsize = 0; + OH_NN_ReturnCode ret = OH_NNCompilation_ImportCacheFromBuffer(nnCompilation, buffer, modelsize); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: compilation_importcachefrombuffer_003 + * @tc.desc: Verify the modelsize is 0 of the OH_NNCompilation_ImportCacheFromBuffer function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_importcachefrombuffer_003, testing::ext::TestSize.Level0) +{ + Compilation *compilation = new (std::nothrow) Compilation(); + OH_NNCompilation* nnCompilation = reinterpret_cast(compilation); + char buffer[SIZE_ONE]; + size_t modelsize = 0; + OH_NN_ReturnCode ret = OH_NNCompilation_ImportCacheFromBuffer(nnCompilation, buffer, modelsize); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: compilation_importcachefrombuffer_004 + * @tc.desc: Verify the modelsize is 0 of the OH_NNCompilation_ImportCacheFromBuffer function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_importcachefrombuffer_004, testing::ext::TestSize.Level0) +{ + Compilation *compilation = new (std::nothrow) Compilation(); + OH_NNCompilation* nnCompilation = reinterpret_cast(compilation); + char buffer[SIZE_ONE]; + OH_NN_ReturnCode ret = OH_NNCompilation_ImportCacheFromBuffer(nnCompilation, buffer, SIZE_ONE); + EXPECT_EQ(OH_NN_SUCCESS, ret); +} + +/* + * @tc.name: compilation_addextensionconfig_001 + * @tc.desc: Verify the compilation is nullptr of the OH_NNCompilation_AddExtensionConfig function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_addextensionconfig_001, testing::ext::TestSize.Level0) +{ + OH_NNCompilation* compilation = nullptr; + const char* configname = nullptr; + const void* configvalue = nullptr; + const size_t configvaluesize = 0; + OH_NN_ReturnCode ret = OH_NNCompilation_AddExtensionConfig(compilation, configname, configvalue, configvaluesize); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: compilation_addextensionconfig_002 + * @tc.desc: Verify the configname is nullptr of the OH_NNCompilation_AddExtensionConfig function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_addextensionconfig_002, testing::ext::TestSize.Level0) +{ + Compilation *compilation = new (std::nothrow) Compilation(); + OH_NNCompilation* nnCompilation = reinterpret_cast(compilation); + const char* configname = nullptr; + const void* cofigvalue = nullptr; + const size_t configvaluesize = 0; + OH_NN_ReturnCode ret = OH_NNCompilation_AddExtensionConfig(nnCompilation, configname, cofigvalue, configvaluesize); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: compilation_addextensionconfig_003 + * @tc.desc: Verify the cofigvalue is nullptr of the OH_NNCompilation_AddExtensionConfig function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_addextensionconfig_003, testing::ext::TestSize.Level0) +{ + Compilation *compilation = new (std::nothrow) Compilation(); + OH_NNCompilation* nnCompilation = reinterpret_cast(compilation); + const char* configname = "ConfigName"; + const void* cofigvalue = nullptr; + const size_t configvaluesize = 0; + OH_NN_ReturnCode ret = OH_NNCompilation_AddExtensionConfig(nnCompilation, configname, cofigvalue, configvaluesize); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: compilation_addextensionconfig_004 + * @tc.desc: Verify the cofigvalue is nullptr of the OH_NNCompilation_AddExtensionConfig function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_addextensionconfig_004, testing::ext::TestSize.Level0) +{ + Compilation *compilation = new (std::nothrow) Compilation(); + OH_NNCompilation* nnCompilation = reinterpret_cast(compilation); + const char* configname = "ConfigName"; + char cofigvalue[SIZE_ONE]; + const size_t configvaluesize = 0; + OH_NN_ReturnCode ret = OH_NNCompilation_AddExtensionConfig(nnCompilation, configname, cofigvalue, configvaluesize); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: compilation_addextensionconfig_005 + * @tc.desc: Verify the cofigvalue is nullptr of the OH_NNCompilation_AddExtensionConfig function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, compilation_addextensionconfig_005, testing::ext::TestSize.Level0) +{ + Compilation *compilation = new (std::nothrow) Compilation(); + OH_NNCompilation* nnCompilation = reinterpret_cast(compilation); + const char* configname = "ConfigName"; + char cofigvalue[SIZE_ONE]; + OH_NN_ReturnCode ret = OH_NNCompilation_AddExtensionConfig(nnCompilation, configname, cofigvalue, SIZE_ONE); + EXPECT_EQ(OH_NN_SUCCESS, ret); +} + +/* + * @tc.name: compilation_set_device_001 + * @tc.desc: Verify the OH_NNCompilation is nullptr of the OH_NNCompilation_SetDevice function. + * @tc.type: FUNC + */ + HWTEST_F(NeuralNetworkCoreTest, compilation_set_device_001, testing::ext::TestSize.Level0) +{ + OH_NNCompilation* compilation = nullptr; + size_t deviceId = 1; + OH_NN_ReturnCode ret = OH_NNCompilation_SetDevice(compilation, deviceId); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: compilation_set_cache_001 + * @tc.desc: Verify the OH_NNCompilation is nullptr of the OH_NNCompilation_SetCache function. + * @tc.type: FUNC + */ + HWTEST_F(NeuralNetworkCoreTest, compilation_set_cache_001, testing::ext::TestSize.Level0) +{ + OH_NNCompilation* nnCompilation = nullptr; + const char* cacheDir = "../"; + uint32_t version = 1; + OH_NN_ReturnCode ret = OH_NNCompilation_SetCache(nnCompilation, cacheDir, version); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: nnt_tensordesc_destroy_001 + * @tc.desc: Verify the NN_TensorDesc is nullptr of the OH_NNTensorDesc_Destroy function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_destroy_001, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = nullptr; + OH_NN_ReturnCode ret = OH_NNTensorDesc_Destroy(&tensorDesc); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: nnt_tensordesc_destroy_002 + * @tc.desc: Verify the NN_TensorDesc is nullptr of the OH_NNTensorDesc_Destroy function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_destroy_002, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = OH_NNTensorDesc_Create(); + OH_NN_ReturnCode ret = OH_NNTensorDesc_Destroy(&tensorDesc); + EXPECT_EQ(OH_NN_SUCCESS, ret); +} + +/* + * @tc.name: nnt_tensordesc_setname_001 + * @tc.desc: Verify the NN_TensorDesc is nullptr of the OH_NNTensorDesc_SetName function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_setname_001, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = nullptr; + const char* name = nullptr; + OH_NN_ReturnCode ret = OH_NNTensorDesc_SetName(tensorDesc, name); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: nnt_tensordesc_setname_002 + * @tc.desc: Verify the name is nullptr of the OH_NNTensorDesc_SetName function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_setname_002, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = OH_NNTensorDesc_Create(); + const char* name = nullptr; + OH_NN_ReturnCode ret = OH_NNTensorDesc_SetName(tensorDesc, name); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: nnt_tensordesc_setname_003 + * @tc.desc: Verify the name is nullptr of the OH_NNTensorDesc_SetName function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_setname_003, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = OH_NNTensorDesc_Create(); + const char* name = "name"; + OH_NN_ReturnCode ret = OH_NNTensorDesc_SetName(tensorDesc, name); + EXPECT_NE(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: nnt_tensordesc_getname_001 + * @tc.desc: Verify the NN_TensorDesc is nullptr of the OH_NNTensorDesc_GetName function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_getname_001, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = nullptr; + const char* name = nullptr; + OH_NN_ReturnCode ret = OH_NNTensorDesc_GetName(tensorDesc, &name); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: nnt_tensordesc_getname_002 + * @tc.desc: Verify the name is nullptr of the OH_NNTensorDesc_GetName function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_getname_002, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = OH_NNTensorDesc_Create(); + const char* name = nullptr; + OH_NN_ReturnCode ret = OH_NNTensorDesc_GetName(tensorDesc, &name); + EXPECT_EQ(OH_NN_SUCCESS, ret); +} + +/* + * @tc.name: nnt_tensordesc_getname_003 + * @tc.desc: Verify the name is nullptr of the OH_NNTensorDesc_GetName function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_getname_003, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = OH_NNTensorDesc_Create(); + const char* name = "name"; + OH_NN_ReturnCode ret = OH_NNTensorDesc_GetName(tensorDesc, &name); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: nnt_tensordesc_setdatatype_001 + * @tc.desc: Verify the NN_TensorDesc is nullptr of the OH_NNTensorDesc_SetDataType function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_setdatatype_001, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = nullptr; + OH_NN_DataType datatype = OH_NN_UNKNOWN; + OH_NN_ReturnCode ret = OH_NNTensorDesc_SetDataType(tensorDesc, datatype); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: nnt_tensordesc_setdatatype_002 + * @tc.desc: Verify the NN_TensorDesc is nullptr of the OH_NNTensorDesc_SetDataType function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_setdatatype_002, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = OH_NNTensorDesc_Create(); + OH_NN_DataType datatype = OH_NN_UNKNOWN; + OH_NN_ReturnCode ret = OH_NNTensorDesc_SetDataType(tensorDesc, datatype); + EXPECT_NE(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: nnt_tensordesc_getdatatype_001 + * @tc.desc: Verify the NN_TensorDesc is nullptr of the OH_NNTensorDesc_GetDataType function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_getdatatype_001, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = nullptr; + OH_NN_DataType* datatype = nullptr; + OH_NN_ReturnCode ret = OH_NNTensorDesc_GetDataType(tensorDesc, datatype); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: nnt_tensordesc_getdatatype_002 + * @tc.desc: Verify the OH_NN_DataType is nullptr of the OH_NNTensorDesc_GetDataType function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_getdatatype_002, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = OH_NNTensorDesc_Create(); + OH_NN_DataType* datatype = nullptr; + OH_NN_ReturnCode ret = OH_NNTensorDesc_GetDataType(tensorDesc, datatype); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: nnt_tensordesc_getdatatype_003 + * @tc.desc: Verify the NN_TensorDesc is nullptr of the OH_NNTensorDesc_GetDataType function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_getdatatype_003, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = nullptr; + OH_NN_DataType datatype = OH_NN_INT32; + OH_NN_ReturnCode ret = OH_NNTensorDesc_GetDataType(tensorDesc, &datatype); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: nnt_tensordesc_setshape_001 + * @tc.desc: Verify the NN_TensorDesc is nullptr of the OH_NNTensorDesc_SetShape function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_setshape_001, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = nullptr; + const int32_t* shape = nullptr; + size_t shapeLength = 0; + OH_NN_ReturnCode ret = OH_NNTensorDesc_SetShape(tensorDesc, shape, shapeLength); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: nnt_tensordesc_setshape_002 + * @tc.desc: Verify the shape is nullptr of the OH_NNTensorDesc_SetShape function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_setshape_002, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = OH_NNTensorDesc_Create(); + const int32_t* shape = nullptr; + size_t shapeLength = 0; + OH_NN_ReturnCode ret = OH_NNTensorDesc_SetShape(tensorDesc, shape, shapeLength); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: nnt_tensordesc_setshape_003 + * @tc.desc: Verify the NN_TensorDesc is nullptr of the OH_NNTensorDesc_SetShape function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_setshape_003, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = OH_NNTensorDesc_Create(); + int32_t inputDims[4] = {1, 2, 2, 3}; + size_t shapeLength = 0; + OH_NN_ReturnCode ret = OH_NNTensorDesc_SetShape(tensorDesc, inputDims, shapeLength); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); +} + +/* + * @tc.name: nnt_tensordesc_setshape_004 + * @tc.desc: Verify the NN_TensorDesc is nullptr of the OH_NNTensorDesc_SetShape function. + * @tc.type: FUNC + */ +HWTEST_F(NeuralNetworkCoreTest, nnt_tensordesc_setshape_004, testing::ext::TestSize.Level0) +{ + NN_TensorDesc* tensorDesc = OH_NNTensorDesc_Create(); + int32_t inputDims[4] = {1, 2, 2, 3}; + size_t shapeLength = 1; + OH_NN_ReturnCode ret = OH_NNTensorDesc_SetShape(tensorDesc, inputDims, shapeLength); + EXPECT_EQ(OH_NN_SUCCESS, ret); +} +} // Unittest +} // namespace NeuralNetworkRuntime +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/components/v1_0/neural_network_core_test/neural_network_core_test.h b/test/unittest/components/v1_0/neural_network_core_test/neural_network_core_test.h new file mode 100644 index 0000000..dc64937 --- /dev/null +++ b/test/unittest/components/v1_0/neural_network_core_test/neural_network_core_test.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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. + */ + +#ifndef NEURAL_NETWORK_RUNTIME_UNITTEST_H +#define NEURAL_NETWORK_RUNTIME_UNITTEST_H + +#include + +#include "interfaces/kits/c/neural_network_runtime/neural_network_runtime.h" +#include "inner_model.h" +#include "executor.h" + +namespace OHOS { +namespace NeuralNetworkRuntime { +namespace Unittest { +class NeuralNetworkCoreTest : public testing::Test { +public: + OH_NN_ReturnCode BuildModel(InnerModel& model); + void InitIndices(); + void AddModelTensor(InnerModel& innerModel); + void SetInnerBuild(InnerModel& innerModel); + void SetExecutor(Executor& executor); + void SetInputAndOutput(Executor& executor); + void SetTensor(); + +public: + OH_NN_UInt32Array m_inputIndices; + OH_NN_UInt32Array m_outputIndices; + OH_NN_UInt32Array m_paramIndices; + OH_NN_Tensor m_tensor; + + uint32_t m_inputIndexs[2] {0, 1}; + uint32_t m_outputIndexs[1] {2}; + uint32_t m_paramIndexs[1] {3}; +}; +} // namespace Unittest +} // namespace NeuralNetworkRuntime +} // namespace OHOS + +#endif // NEURAL_NETWORK_RUNTIME_UNITTEST_H -- Gitee From 1a2bab68cb3500f5ee3cc156c70a61d2a4bcf162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8F=B6=E5=86=9B?= Date: Fri, 14 Jun 2024 11:42:18 +0800 Subject: [PATCH 2/6] =?UTF-8?q?UT=E7=94=A8=E4=BE=8B=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王叶军 --- .../v1_0/backend_manager/backend_manager_test.cpp | 2 +- .../neural_network_core_test.cpp | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/test/unittest/components/v1_0/backend_manager/backend_manager_test.cpp b/test/unittest/components/v1_0/backend_manager/backend_manager_test.cpp index 0113775..0ab0707 100644 --- a/test/unittest/components/v1_0/backend_manager/backend_manager_test.cpp +++ b/test/unittest/components/v1_0/backend_manager/backend_manager_test.cpp @@ -39,7 +39,7 @@ HWTEST_F(BackendManagerTest, backendmanager_getbackend_001, TestSize.Level0) auto &backendManager = BackendManager::GetInstance(); const size_t backendId = 1; std::shared_ptr result = backendManager.GetBackend(backendId); - EXPECT_EQ(nullptr,result); + EXPECT_EQ(nullptr, result); } /** diff --git a/test/unittest/components/v1_0/neural_network_core_test/neural_network_core_test.cpp b/test/unittest/components/v1_0/neural_network_core_test/neural_network_core_test.cpp index 09fb926..c72af22 100644 --- a/test/unittest/components/v1_0/neural_network_core_test/neural_network_core_test.cpp +++ b/test/unittest/components/v1_0/neural_network_core_test/neural_network_core_test.cpp @@ -25,7 +25,7 @@ namespace OHOS { namespace NeuralNetworkRuntime { namespace Unittest { const size_t SIZE_ONE = 1; -OH_NN_ReturnCode NeuralNetworkCoreTest::BuildModel(InnerModel& model) +OH_NN_ReturnCode NeuralNetworkCoreTest::BuildModel(InnerModel& model) { int32_t inputDims[2] = {3, 4}; OH_NN_Tensor input1 = {OH_NN_FLOAT32, 2, inputDims, nullptr, OH_NN_TENSOR}; @@ -100,7 +100,6 @@ OH_NN_ReturnCode NeuralNetworkCoreTest::BuildModel(InnerModel& model) */ HWTEST_F(NeuralNetworkCoreTest, alldevicesid_001, testing::ext::TestSize.Level0) { - const size_t* allDeviceIds = nullptr; uint32_t count {0}; OH_NN_ReturnCode ret = OH_NNDevice_GetAllDevicesID(&allDeviceIds, &count); @@ -116,7 +115,7 @@ HWTEST_F(NeuralNetworkCoreTest, alldeviceid_002, testing::ext::TestSize.Level0) { uint32_t count {0}; OH_NN_ReturnCode ret = OH_NNDevice_GetAllDevicesID(nullptr, &count); - EXPECT_EQ(OH_NN_INVALID_PARAMETER,ret); + EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret); } /* @@ -385,7 +384,7 @@ HWTEST_F(NeuralNetworkCoreTest, compilation_exportchachetobuffer_006, testing::e * @tc.type: FUNC */ HWTEST_F(NeuralNetworkCoreTest, compilation_importcachefrombuffer_001, testing::ext::TestSize.Level0) -{ +{ OH_NNCompilation* compilation = nullptr; const void* buffer = nullptr; size_t modelsize = 0; @@ -520,7 +519,7 @@ HWTEST_F(NeuralNetworkCoreTest, compilation_addextensionconfig_005, testing::ext * @tc.desc: Verify the OH_NNCompilation is nullptr of the OH_NNCompilation_SetDevice function. * @tc.type: FUNC */ - HWTEST_F(NeuralNetworkCoreTest, compilation_set_device_001, testing::ext::TestSize.Level0) +HWTEST_F(NeuralNetworkCoreTest, compilation_set_device_001, testing::ext::TestSize.Level0) { OH_NNCompilation* compilation = nullptr; size_t deviceId = 1; @@ -533,7 +532,7 @@ HWTEST_F(NeuralNetworkCoreTest, compilation_addextensionconfig_005, testing::ext * @tc.desc: Verify the OH_NNCompilation is nullptr of the OH_NNCompilation_SetCache function. * @tc.type: FUNC */ - HWTEST_F(NeuralNetworkCoreTest, compilation_set_cache_001, testing::ext::TestSize.Level0) +HWTEST_F(NeuralNetworkCoreTest, compilation_set_cache_001, testing::ext::TestSize.Level0) { OH_NNCompilation* nnCompilation = nullptr; const char* cacheDir = "../"; -- Gitee From c36d98f1b6d9f1fc7c450ba9db76dcf327986d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8F=B6=E5=86=9B?= Date: Fri, 14 Jun 2024 13:59:52 +0800 Subject: [PATCH 3/6] =?UTF-8?q?UT=E7=94=A8=E4=BE=8B=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王叶军 --- test/unittest/components/BUILD.gn | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/unittest/components/BUILD.gn b/test/unittest/components/BUILD.gn index fe3f917..51a69b2 100644 --- a/test/unittest/components/BUILD.gn +++ b/test/unittest/components/BUILD.gn @@ -29,10 +29,10 @@ config("module_private_config") { ] } -ohos_unittest("CompilationV1_0Test") { +ohos_unittest("BackendManagerV1_0Test") { module_out_path = module_output_path - sources = [ "../common/v1_0/compilation_mock_idevice.cpp" ] + sources = [ "./v1_0/backend_manager/backend_manager_test.cpp" ] configs = [ ":module_private_config" ] deps = [ @@ -45,17 +45,16 @@ ohos_unittest("CompilationV1_0Test") { external_deps = [ "c_utils:utils", "drivers_interface_nnrt:libnnrt_proxy_1.0", - "hdf_core:libhdf_utils", "hilog:libhilog", "hitrace:libhitracechain", "mindspore:mindir", ] } -ohos_unittest("ExecutorV1_0Test") { +ohos_unittest("CompilationV1_0Test") { module_out_path = module_output_path - sources = [ "../common/v1_0/executor_mock_device.cpp" ] + sources = [ "../common/v1_0/compilation_mock_idevice.cpp" ] configs = [ ":module_private_config" ] deps = [ @@ -75,10 +74,10 @@ ohos_unittest("ExecutorV1_0Test") { ] } -ohos_unittest("BackendManagerV1_0Test") { +ohos_unittest("ExecutorV1_0Test") { module_out_path = module_output_path - sources = [ "./v1_0/backend_manager/backend_manager_test.cpp" ] + sources = [ "../common/v1_0/executor_mock_device.cpp" ] configs = [ ":module_private_config" ] deps = [ @@ -91,6 +90,7 @@ ohos_unittest("BackendManagerV1_0Test") { external_deps = [ "c_utils:utils", "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hdf_core:libhdf_utils", "hilog:libhilog", "hitrace:libhitracechain", "mindspore:mindir", @@ -327,13 +327,10 @@ ohos_unittest("OpsRegistryV1_0Test") { ] } -ohos_unittest("NeuralNetworkRuntimeV1_0Test") { +ohos_unittest("NeuralNetworkCore1_0Test") { module_out_path = module_output_path - sources = - [ "./v1_0/neural_network_runtime_test/neural_network_runtime_test.cpp" ] - sources += [ "../common/v1_0/executor_mock_device.cpp" ] - + sources = [ "./v1_0/neural_network_core_test/neural_network_core_test.cpp" ] configs = [ ":module_private_config" ] deps = [ @@ -353,10 +350,13 @@ ohos_unittest("NeuralNetworkRuntimeV1_0Test") { ] } -ohos_unittest("NeuralNetworkCore1_0Test") { +ohos_unittest("NeuralNetworkRuntimeV1_0Test") { module_out_path = module_output_path - sources = [ "./v1_0/neural_network_core_test/neural_network_core_test.cpp" ] + sources = + [ "./v1_0/neural_network_runtime_test/neural_network_runtime_test.cpp" ] + sources += [ "../common/v1_0/executor_mock_device.cpp" ] + configs = [ ":module_private_config" ] deps = [ -- Gitee From 5b58ec7b2c7de86e6aab7a6c97d5dab174bc16b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8F=B6=E5=86=9B?= Date: Fri, 14 Jun 2024 14:22:11 +0800 Subject: [PATCH 4/6] =?UTF-8?q?UT=E7=94=A8=E4=BE=8B=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王叶军 --- test/unittest/common/mock_backend.h | 41 ----------- test/unittest/components/BUILD.gn | 23 ------ .../backend_manager/backend_manager_test.cpp | 72 ------------------- 3 files changed, 136 deletions(-) delete mode 100644 test/unittest/common/mock_backend.h delete mode 100644 test/unittest/components/v1_0/backend_manager/backend_manager_test.cpp diff --git a/test/unittest/common/mock_backend.h b/test/unittest/common/mock_backend.h deleted file mode 100644 index 1a64a0e..0000000 --- a/test/unittest/common/mock_backend.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * 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. - */ -#ifndef NEURAL_NETWORK_RUNTIME_MOCK_BACKEND_H -#define NEURAL_NETWORK_RUNTIME_MOCK_BACKEND_H - -#include - -#include -#include "backend.h" - -namespace OHOS { -namespace NeuralNetworkRuntime { -class MockBackend : public Backend { -public: - MOCK_METHOD(size_t, GetBackendID, (), (const, override)); - MOCK_METHOD(OH_NN_ReturnCode, GetBackendName, (std::string&), (const, override)); - MOCK_METHOD(OH_NN_ReturnCode, GetBackendType, (OH_NN_DeviceType&), (const, override)); - MOCK_METHOD(OH_NN_ReturnCode, GetBackendStatus, (DeviceStatus&), (const, override)); - MOCK_METHOD(Compiler*, CreateCompiler, (Compilation*), (override)); - MOCK_METHOD(OH_NN_ReturnCode, DestroyCompiler, (Compiler*), (override)); - MOCK_METHOD(Executor*, CreateExecutor, (Compilation*), (override)); - MOCK_METHOD(OH_NN_ReturnCode, DestroyExecutor, (Executor*), (override)); - MOCK_METHOD(Tensor*, CreateTensor, (TensorDesc*), (override)); - MOCK_METHOD(OH_NN_ReturnCode, DestroyTensor, (Tensor*), (override)); -}; -} // NeuralNetworkRuntime -} // OHOS - -#endif // NEURAL_NETWORK_RUNTIME_MOCK_BACKEND_H \ No newline at end of file diff --git a/test/unittest/components/BUILD.gn b/test/unittest/components/BUILD.gn index 51a69b2..1e613cd 100644 --- a/test/unittest/components/BUILD.gn +++ b/test/unittest/components/BUILD.gn @@ -29,28 +29,6 @@ config("module_private_config") { ] } -ohos_unittest("BackendManagerV1_0Test") { - module_out_path = module_output_path - - sources = [ "./v1_0/backend_manager/backend_manager_test.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_1.0", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] -} - ohos_unittest("CompilationV1_0Test") { module_out_path = module_output_path @@ -659,7 +637,6 @@ ohos_unittest("NeuralNetworkRuntimeV2_0Test") { group("components_unittest") { testonly = true deps = [ - ":BackendManagerV1_0Test", ":CompilationV1_0Test", ":CompilationV2_0Test", ":ExecutorV1_0Test", diff --git a/test/unittest/components/v1_0/backend_manager/backend_manager_test.cpp b/test/unittest/components/v1_0/backend_manager/backend_manager_test.cpp deleted file mode 100644 index 0ab0707..0000000 --- a/test/unittest/components/v1_0/backend_manager/backend_manager_test.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* -* Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -#include -#include - -#include "common/log.h" -#include "backend_manager.h" -#include "test/unittest/common/mock_backend.h" - -using namespace testing; -using namespace testing::ext; -namespace OHOS { -namespace NeuralNetworkRuntime { -namespace UnitTest { -class BackendManagerTest : public testing::Test { -protected: -}; - -/** - * @tc.name: backendmanager_getbackend_001 - * @tc.desc: Verify the GetBackend function return nullptr in case of backendid invalid. - * @tc.type: FUNC - */ -HWTEST_F(BackendManagerTest, backendmanager_getbackend_001, TestSize.Level0) -{ - auto &backendManager = BackendManager::GetInstance(); - const size_t backendId = 1; - std::shared_ptr result = backendManager.GetBackend(backendId); - EXPECT_EQ(nullptr, result); -} - -/** -* @tc.name: backendmanager_registerbackend_001 -* @tc.desc: Verify the GetBackend function return nullptr in case of backendid invalid. -* @tc.type: FUNC -*/ -HWTEST_F(BackendManagerTest, backendmanager_registerbackend_001, TestSize.Level0) -{ - auto &backendManager = BackendManager::GetInstance(); - const size_t backendId = 2; - std::shared_ptr result = backendManager.GetBackend(backendId); - EXPECT_EQ(result->GetBackendID(), OH_NN_INVALID_PARAMETER); -} - -/** - * @tc.name: backendmanager_getbackendname_001 - * @tc.desc: Verify the GetBackend function return empty string in case of backendid invalid. - * @tc.type: FUNC - */ -HWTEST_F(BackendManagerTest, backendmanager_getbackendname_001, TestSize.Level0) -{ - auto &backendManager = BackendManager::GetInstance(); - const size_t backendId = 1; - std::string result = backendManager.GetBackendName(backendId); - EXPECT_EQ("", result); -} -} // namespace UnitTest -} // namespace NeuralNetworkRuntime -} // namespace OHOS -- Gitee From fdbd66dfb1ead9e5722f40ee2a873cd981d42a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8F=B6=E5=86=9B?= Date: Fri, 14 Jun 2024 14:33:37 +0800 Subject: [PATCH 5/6] =?UTF-8?q?UT=E7=94=A8=E4=BE=8B=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王叶军 --- test/unittest/components/BUILD.gn | 1132 ++++++++++++++--------------- 1 file changed, 566 insertions(+), 566 deletions(-) diff --git a/test/unittest/components/BUILD.gn b/test/unittest/components/BUILD.gn index 1e613cd..c3d94fe 100644 --- a/test/unittest/components/BUILD.gn +++ b/test/unittest/components/BUILD.gn @@ -16,648 +16,648 @@ import("//build/test.gni") module_output_path = "neural_network_runtime/" config("module_private_config") { - visibility = [ ":*" ] - - include_dirs = [ - "//third_party/googletest/googlemock/include", - "../../..", - "../../../frameworks/native", - "../../../frameworks/native/neural_network_runtime", - "../../../frameworks/native/neural_network_core", - "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", - "//third_party/mindspore/mindspore-src/source/mindspore/lite/mindir/include", - ] + visibility = [ ":*" ] + + include_dirs = [ + "//third_party/googletest/googlemock/include", + "../../..", + "../../../frameworks/native", + "../../../frameworks/native/neural_network_runtime", + "../../../frameworks/native/neural_network_core", + "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", + "//third_party/mindspore/mindspore-src/source/mindspore/lite/mindir/include", + ] } ohos_unittest("CompilationV1_0Test") { - module_out_path = module_output_path - - sources = [ "../common/v1_0/compilation_mock_idevice.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_1.0", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "../common/v1_0/compilation_mock_idevice.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("ExecutorV1_0Test") { - module_out_path = module_output_path - - sources = [ "../common/v1_0/executor_mock_device.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_1.0", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "../common/v1_0/executor_mock_device.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("DeviceManagerV1_0Test") { - module_out_path = module_output_path - - sources = [ "./v1_0/device_manager/device_manager_test.cpp" ] - sources += [ "../common/v1_0/mock_idevice.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_1.0", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v1_0/device_manager/device_manager_test.cpp" ] + sources += [ "../common/v1_0/mock_idevice.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("DeviceRegistrarV1_0Test") { - module_out_path = module_output_path - - sources = [ "./v1_0/device_registrar/device_registrar_test.cpp" ] - sources += [ "../common/v1_0/mock_idevice.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_1.0", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v1_0/device_registrar/device_registrar_test.cpp" ] + sources += [ "../common/v1_0/mock_idevice.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("HDIDeviceV1_0Test") { - module_out_path = module_output_path - - sources = [ "./v1_0/hdi_device/hdi_device_test.cpp" ] - sources += [ "../common/v1_0/mock_idevice.cpp" ] - sources += [ "../common/file_utils.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_1.0", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v1_0/hdi_device/hdi_device_test.cpp" ] + sources += [ "../common/v1_0/mock_idevice.cpp" ] + sources += [ "../common/file_utils.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("HDIPreparedModelV1_0Test") { - module_out_path = module_output_path - - sources = [ "./v1_0/hdi_prepared_model/hdi_prepared_model_test.cpp" ] - sources += [ "../common/v1_0/mock_idevice.cpp" ] - sources += [ "../common/file_utils.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_1.0", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v1_0/hdi_prepared_model/hdi_prepared_model_test.cpp" ] + sources += [ "../common/v1_0/mock_idevice.cpp" ] + sources += [ "../common/file_utils.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("MemoryManagerTest") { - module_out_path = module_output_path - - sources = [ "./memory_manager/memory_manager_test.cpp" ] - sources += [ "../common/file_utils.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "drivers_interface_nnrt:libnnrt_proxy_1.0", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./memory_manager/memory_manager_test.cpp" ] + sources += [ "../common/file_utils.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] +} + +ohos_unittest("NeuralNetworkCore1_0Test") { + module_out_path = module_output_path + + sources = [ "./v1_0/neural_network_core_test/neural_network_core_test.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("TransformV1_0Test") { - module_out_path = module_output_path - - sources = [ "./v1_0/transform/transform_test.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "drivers_interface_nnrt:libnnrt_proxy_1.0", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v1_0/transform/transform_test.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("InnerModelV1_0Test") { - module_out_path = module_output_path - - sources = [ "./v1_0/inner_model/inner_model_test.cpp" ] - sources += [ "../common/v1_0/inner_model_mock_device.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_1.0", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v1_0/inner_model/inner_model_test.cpp" ] + sources += [ "../common/v1_0/inner_model_mock_device.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("NnTensorV1_0Test") { - module_out_path = module_output_path - - sources = [ "./v1_0/inner_model/nn_tensor_test.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_1.0", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v1_0/inner_model/nn_tensor_test.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("NnValidationV1_0Test") { - module_out_path = module_output_path - - sources = [ "./v1_0/inner_model/nn_validation_test.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_1.0", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v1_0/inner_model/nn_validation_test.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("OpsRegistryV1_0Test") { - module_out_path = module_output_path - - sources = [ "./v1_0/inner_model/ops_registry_test.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_1.0", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] -} - -ohos_unittest("NeuralNetworkCore1_0Test") { - module_out_path = module_output_path - - sources = [ "./v1_0/neural_network_core_test/neural_network_core_test.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_1.0", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v1_0/inner_model/ops_registry_test.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("NeuralNetworkRuntimeV1_0Test") { - module_out_path = module_output_path - - sources = - [ "./v1_0/neural_network_runtime_test/neural_network_runtime_test.cpp" ] - sources += [ "../common/v1_0/executor_mock_device.cpp" ] - - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_1.0", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = + [ "./v1_0/neural_network_runtime_test/neural_network_runtime_test.cpp" ] + sources += [ "../common/v1_0/executor_mock_device.cpp" ] + + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_1.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("CompilationV2_0Test") { - module_out_path = module_output_path - - sources = [ "../common/v2_0/compilation_mock_idevice.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_2.0", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "../common/v2_0/compilation_mock_idevice.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_2.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("ExecutorV2_0Test") { - module_out_path = module_output_path - - sources = [ "../common/v2_0/executor_mock_device.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_2.0", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "../common/v2_0/executor_mock_device.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_2.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("DeviceManagerV2_0Test") { - module_out_path = module_output_path - - sources = [ "./v2_0/device_manager/device_manager_test.cpp" ] - sources += [ "../common/v2_0/mock_idevice.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_2.0", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v2_0/device_manager/device_manager_test.cpp" ] + sources += [ "../common/v2_0/mock_idevice.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_2.0", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("DeviceRegistrarV2_0Test") { - module_out_path = module_output_path - - sources = [ "./v2_0/device_registrar/device_registrar_test.cpp" ] - sources += [ "../common/v2_0/mock_idevice.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_2.0", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v2_0/device_registrar/device_registrar_test.cpp" ] + sources += [ "../common/v2_0/mock_idevice.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_2.0", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("HDIDeviceV2_0Test") { - module_out_path = module_output_path - - sources = [ "./v2_0/hdi_device/hdi_device_test.cpp" ] - sources += [ "../common/v2_0/mock_idevice.cpp" ] - sources += [ "../common/file_utils.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_2.0", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v2_0/hdi_device/hdi_device_test.cpp" ] + sources += [ "../common/v2_0/mock_idevice.cpp" ] + sources += [ "../common/file_utils.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_2.0", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("HDIPreparedModelV2_0Test") { - module_out_path = module_output_path - - sources = [ "./v2_0/hdi_prepared_model/hdi_prepared_model_test.cpp" ] - sources += [ "../common/v2_0/mock_idevice.cpp" ] - sources += [ "../common/file_utils.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_2.0", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v2_0/hdi_prepared_model/hdi_prepared_model_test.cpp" ] + sources += [ "../common/v2_0/mock_idevice.cpp" ] + sources += [ "../common/file_utils.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_2.0", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("TransformV2_0Test") { - module_out_path = module_output_path - - sources = [ "./v2_0/transform/transform_test.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "drivers_interface_nnrt:libnnrt_proxy_2.0", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v2_0/transform/transform_test.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "drivers_interface_nnrt:libnnrt_proxy_2.0", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("InnerModelV2_0Test") { - module_out_path = module_output_path - - sources = [ "./v2_0/inner_model/inner_model_test.cpp" ] - sources += [ "../common/v2_0/inner_model_mock_device.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_2.0", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v2_0/inner_model/inner_model_test.cpp" ] + sources += [ "../common/v2_0/inner_model_mock_device.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_2.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("NnTensorV2_0Test") { - module_out_path = module_output_path - - sources = [ "./v2_0/inner_model/nn_tensor_test.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_2.0", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v2_0/inner_model/nn_tensor_test.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_2.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("NnValidationV2_0Test") { - module_out_path = module_output_path - - sources = [ "./v2_0/inner_model/nn_validation_test.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_2.0", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v2_0/inner_model/nn_validation_test.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_2.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("OpsRegistryV2_0Test") { - module_out_path = module_output_path - - sources = [ "./v2_0/inner_model/ops_registry_test.cpp" ] - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_2.0", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = [ "./v2_0/inner_model/ops_registry_test.cpp" ] + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_2.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } ohos_unittest("NeuralNetworkRuntimeV2_0Test") { - module_out_path = module_output_path - - sources = - [ "./v2_0/neural_network_runtime_test/neural_network_runtime_test.cpp" ] - sources += [ "../common/v2_0/executor_mock_device.cpp" ] - - configs = [ ":module_private_config" ] - - deps = [ - "../../../frameworks/native/neural_network_core:libneural_network_core", - "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "drivers_interface_nnrt:libnnrt_proxy_2.0", - "hdf_core:libhdf_utils", - "hilog:libhilog", - "hitrace:libhitracechain", - "mindspore:mindir", - ] + module_out_path = module_output_path + + sources = + [ "./v2_0/neural_network_runtime_test/neural_network_runtime_test.cpp" ] + sources += [ "../common/v2_0/executor_mock_device.cpp" ] + + configs = [ ":module_private_config" ] + + deps = [ + "../../../frameworks/native/neural_network_core:libneural_network_core", + "../../../frameworks/native/neural_network_runtime:libneural_network_runtime", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "drivers_interface_nnrt:libnnrt_proxy_2.0", + "hdf_core:libhdf_utils", + "hilog:libhilog", + "hitrace:libhitracechain", + "mindspore:mindir", + ] } group("components_unittest") { - testonly = true - deps = [ - ":CompilationV1_0Test", - ":CompilationV2_0Test", - ":ExecutorV1_0Test", - ":ExecutorV2_0Test", - ":HDIDeviceV1_0Test", - ":HDIDeviceV2_0Test", - ":HDIPreparedModelV1_0Test", - ":HDIPreparedModelV2_0Test", - ":InnerModelV1_0Test", - ":InnerModelV2_0Test", - ":MemoryManagerTest", - ":NeuralNetworkCore1_0Test", - ":NeuralNetworkRuntimeV1_0Test", - ":NeuralNetworkRuntimeV2_0Test", - ":NnTensorV1_0Test", - ":NnTensorV2_0Test", - ":NnValidationV1_0Test", - ":NnValidationV2_0Test", - ":OpsRegistryV1_0Test", - ":OpsRegistryV2_0Test", - ":TransformV1_0Test", - ":TransformV2_0Test", - ] + testonly = true + deps = [ + ":CompilationV1_0Test", + ":CompilationV2_0Test", + ":ExecutorV1_0Test", + ":ExecutorV2_0Test", + ":HDIDeviceV1_0Test", + ":HDIDeviceV2_0Test", + ":HDIPreparedModelV1_0Test", + ":HDIPreparedModelV2_0Test", + ":InnerModelV1_0Test", + ":InnerModelV2_0Test", + ":MemoryManagerTest", + ":NeuralNetworkCore1_0Test", + ":NeuralNetworkRuntimeV1_0Test", + ":NeuralNetworkRuntimeV2_0Test", + ":NnTensorV1_0Test", + ":NnTensorV2_0Test", + ":NnValidationV1_0Test", + ":NnValidationV2_0Test", + ":OpsRegistryV1_0Test", + ":OpsRegistryV2_0Test", + ":TransformV1_0Test", + ":TransformV2_0Test", + ] } -- Gitee From cc7ed13d79b362a7a7ab047e95037582cdde385f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8F=B6=E5=86=9B?= Date: Fri, 14 Jun 2024 15:03:21 +0800 Subject: [PATCH 6/6] =?UTF-8?q?UT=E7=94=A8=E4=BE=8B=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王叶军 --- test/unittest/components/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unittest/components/BUILD.gn b/test/unittest/components/BUILD.gn index c3d94fe..f26c549 100644 --- a/test/unittest/components/BUILD.gn +++ b/test/unittest/components/BUILD.gn @@ -191,7 +191,7 @@ ohos_unittest("MemoryManagerTest") { ] } -ohos_unittest("NeuralNetworkCore1_0Test") { +ohos_unittest("NeuralNetworkCoreV1_0Test") { module_out_path = module_output_path sources = [ "./v1_0/neural_network_core_test/neural_network_core_test.cpp" ] @@ -648,7 +648,7 @@ group("components_unittest") { ":InnerModelV1_0Test", ":InnerModelV2_0Test", ":MemoryManagerTest", - ":NeuralNetworkCore1_0Test", + ":NeuralNetworkCoreV1_0Test", ":NeuralNetworkRuntimeV1_0Test", ":NeuralNetworkRuntimeV2_0Test", ":NnTensorV1_0Test", -- Gitee