From 6ad110664292d6aabd958f703b585ec9997c448e Mon Sep 17 00:00:00 2001 From: guoqi11 Date: Mon, 3 Jul 2023 06:50:43 +0000 Subject: [PATCH 1/3] fix:add sample about hdf load_vdi Signed-off-by: guoqi11 --- adapter/uhdf2/test/BUILD.gn | 2 + .../resource/load_vdi/arch32/ohos_test.xml | 1 + .../resource/load_vdi/arch64/ohos_test.xml | 1 + adapter/uhdf2/test/unittest/load_vdi/BUILD.gn | 15 +++++ .../core/host/test/sample/vdi_sample1_fault.c | 57 +++++++++++++++++++ .../core/host/test/sample/vdi_sample1_fault.h | 33 +++++++++++ .../core/host/test/unittest/hdf_vdi_test.cpp | 7 +++ 7 files changed, 116 insertions(+) create mode 100644 framework/core/host/test/sample/vdi_sample1_fault.c create mode 100644 framework/core/host/test/sample/vdi_sample1_fault.h diff --git a/adapter/uhdf2/test/BUILD.gn b/adapter/uhdf2/test/BUILD.gn index 81cecaeac..2d1659380 100644 --- a/adapter/uhdf2/test/BUILD.gn +++ b/adapter/uhdf2/test/BUILD.gn @@ -26,6 +26,7 @@ if (hdf_core_khdf_test_support) { "unittest/load_vdi:hdf_load_vdi_test", "unittest/load_vdi:libvdi_sample1_driver", "unittest/load_vdi:libvdi_sample2_driver", + "unittest/load_vdi:libvdi_sample1_fault", "unittest/manager:hdf_adapter_uhdf_test_core_shared", "unittest/manager:hdf_adapter_uhdf_test_ioservice", "unittest/manager:hdf_adapter_uhdf_test_manager", @@ -50,6 +51,7 @@ if (hdf_core_khdf_test_support) { "unittest/load_vdi:hdf_load_vdi_test", "unittest/load_vdi:libvdi_sample1_driver", "unittest/load_vdi:libvdi_sample2_driver", + "unittest/load_vdi:libvdi_sample1_fault", "unittest/manager:hdf_adapter_uhdf_test_core_shared", "unittest/manager:hdf_adapter_uhdf_test_remote_adapter", "unittest/manager:hdf_adapter_uhdf_test_sbuf", diff --git a/adapter/uhdf2/test/resource/load_vdi/arch32/ohos_test.xml b/adapter/uhdf2/test/resource/load_vdi/arch32/ohos_test.xml index a7742be75..e5b7b9ac7 100644 --- a/adapter/uhdf2/test/resource/load_vdi/arch32/ohos_test.xml +++ b/adapter/uhdf2/test/resource/load_vdi/arch32/ohos_test.xml @@ -18,6 +18,7 @@ diff --git a/adapter/uhdf2/test/resource/load_vdi/arch64/ohos_test.xml b/adapter/uhdf2/test/resource/load_vdi/arch64/ohos_test.xml index d4ad65972..1acbcdc66 100644 --- a/adapter/uhdf2/test/resource/load_vdi/arch64/ohos_test.xml +++ b/adapter/uhdf2/test/resource/load_vdi/arch64/ohos_test.xml @@ -18,6 +18,7 @@ diff --git a/adapter/uhdf2/test/unittest/load_vdi/BUILD.gn b/adapter/uhdf2/test/unittest/load_vdi/BUILD.gn index f3420266b..af3f4b595 100644 --- a/adapter/uhdf2/test/unittest/load_vdi/BUILD.gn +++ b/adapter/uhdf2/test/unittest/load_vdi/BUILD.gn @@ -68,3 +68,18 @@ ohos_shared_library("libvdi_sample2_driver") { ] external_deps = [ "hilog:libhilog" ] } + +ohos_shared_library("libvdi_sample1_fault") { + include_dirs = [ "../../../../../framework/core/host/test/sample" ] + + sources = + [ "../../../../../framework/core/host/test/sample/vdi_sample1_fault.c" ] + install_images = [ chipset_base_dir ] + subsystem_name = "hdf" + part_name = "hdf_core" + deps = [ + "../../../host:libhdf_host", + "../../../utils:libhdf_utils", + ] + external_deps = [ "hilog:libhilog" ] +} \ No newline at end of file diff --git a/framework/core/host/test/sample/vdi_sample1_fault.c b/framework/core/host/test/sample/vdi_sample1_fault.c new file mode 100644 index 000000000..881141f65 --- /dev/null +++ b/framework/core/host/test/sample/vdi_sample1_fault.c @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#include "hdf_base.h" +#include "hdf_load_vdi.h" +#include "hdf_log.h" + +#include "vdi_sample1_fault.h" + +#define HDF_LOG_TAG vdi_sample1 + +static int ServiceA(void) +{ + HDF_LOGI("%{public}s", __func__); + return HDF_SUCCESS; +} + +static int ServiceB(struct ModuleA1 *modA) +{ + HDF_LOGI("%{public}s %{public}d", __func__, modA->priData); + return HDF_SUCCESS; +} + +static int SampleAOpen(struct HdfVdiBase *vdiBase) +{ + (void)vdiBase; + HDF_LOGI("%{public}s", __func__); + return HDF_SUCCESS; +} + +static int SampleAClose(struct HdfVdiBase *vdiBase) +{ + (void)vdiBase; + HDF_LOGI("%{public}s", __func__); + return HDF_SUCCESS; +} + +static struct ModuleA1 g_modA1 = { + .ServiceA = ServiceA, + .ServiceB = ServiceB, + .priData = 1, +}; + +struct VdiWrapperA1 g_vdiA = { + .base = { + .moduleVersion = 1, + .moduleName = "SampleServiceA", + .CreateVdiInstance = SampleAOpen, + .DestoryVdiInstance = SampleAClose, + }, + .module = &g_modA1, +}; diff --git a/framework/core/host/test/sample/vdi_sample1_fault.h b/framework/core/host/test/sample/vdi_sample1_fault.h new file mode 100644 index 000000000..485709bf1 --- /dev/null +++ b/framework/core/host/test/sample/vdi_sample1_fault.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#ifndef VDI_SAMPLE1_FAULT_H +#define VDI_SAMPLE1_FAULT_H + +#include "hdf_load_vdi.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +struct ModuleA1 { + int (*ServiceA)(void); + int (*ServiceB)(struct ModuleA1 *modA); + int priData; +}; + +struct VdiWrapperA1 { + struct HdfVdiBase base; + struct ModuleA1 *module; +}; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* VDI_SAMPLE1_FAULT_H */ diff --git a/framework/core/host/test/unittest/hdf_vdi_test.cpp b/framework/core/host/test/unittest/hdf_vdi_test.cpp index d0d659ada..368075b59 100644 --- a/framework/core/host/test/unittest/hdf_vdi_test.cpp +++ b/framework/core/host/test/unittest/hdf_vdi_test.cpp @@ -116,6 +116,13 @@ HWTEST_F(HdfVdiTest, HdfVdiTestLoadInvalidLibName, TestSize.Level3) HdfCloseVdi(vdi); } +HWTEST_F(HdfVdiTest, HdfVdiTestLoadInvalidLibDesc, TestSize.Level3) +{ + struct HdfVdiObject *vdi = nullptr; + vdi = HdfLoadVdi("libvdi_sample1_fault.z.so"); + ASSERT_TRUE(vdi == nullptr); +} + HWTEST_F(HdfVdiTest, HdfVdiTestNulVdiGetVersion, TestSize.Level3) { struct HdfVdiObject *vdi = nullptr; -- Gitee From 202f5039514a90feebcb7db1d1aae86a75d683b3 Mon Sep 17 00:00:00 2001 From: guoqi11 Date: Mon, 3 Jul 2023 08:34:58 +0000 Subject: [PATCH 2/3] fix:add sample about hdf load vdi Signed-off-by: guoqi11 --- adapter/uhdf2/test/BUILD.gn | 61 ------------------- adapter/uhdf2/test/unittest/load_vdi/BUILD.gn | 2 +- 2 files changed, 1 insertion(+), 62 deletions(-) diff --git a/adapter/uhdf2/test/BUILD.gn b/adapter/uhdf2/test/BUILD.gn index 2d1659380..e69de29bb 100644 --- a/adapter/uhdf2/test/BUILD.gn +++ b/adapter/uhdf2/test/BUILD.gn @@ -1,61 +0,0 @@ -# Copyright (c) 2021-2023 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. - -declare_args() { - hdf_core_khdf_test_support = true - hdf_core_platform_test_support = false -} - -if (hdf_core_khdf_test_support) { - group("hdf_test_uhdf") { - testonly = true - deps = [ - "./../../../framework/test/fuzztest:hdf_framework_fuzztest", - "fuzztest:hdf_platform_test", - "unittest/config:hdf_adapter_uhdf_test_config", - "unittest/load_vdi:hdf_load_vdi_test", - "unittest/load_vdi:libvdi_sample1_driver", - "unittest/load_vdi:libvdi_sample2_driver", - "unittest/load_vdi:libvdi_sample1_fault", - "unittest/manager:hdf_adapter_uhdf_test_core_shared", - "unittest/manager:hdf_adapter_uhdf_test_ioservice", - "unittest/manager:hdf_adapter_uhdf_test_manager", - "unittest/manager:hdf_adapter_uhdf_test_pm", - "unittest/manager:hdf_adapter_uhdf_test_remote_adapter", - "unittest/manager:hdf_adapter_uhdf_test_sbuf", - "unittest/manager:hdf_adapter_uhdf_test_uevent", - "unittest/osal:hdf_adapter_uhdf_test_osal", - "unittest/osal:hdf_adapter_uhdf_test_osal_posix", - "unittest/platform/i2c:ui2c_test", - ] - if (hdf_core_platform_test_support) { - deps += [ "unittest/platform:hdf_adapter_uhdf_test_platform" ] - } - } -} else { - group("hdf_test_uhdf") { - testonly = true - deps = [ - "./../../../framework/test/fuzztest:hdf_framework_fuzztest", - "fuzztest:hdf_platform_test", - "unittest/load_vdi:hdf_load_vdi_test", - "unittest/load_vdi:libvdi_sample1_driver", - "unittest/load_vdi:libvdi_sample2_driver", - "unittest/load_vdi:libvdi_sample1_fault", - "unittest/manager:hdf_adapter_uhdf_test_core_shared", - "unittest/manager:hdf_adapter_uhdf_test_remote_adapter", - "unittest/manager:hdf_adapter_uhdf_test_sbuf", - "unittest/osal:hdf_adapter_uhdf_test_osal_posix", - ] - } -} diff --git a/adapter/uhdf2/test/unittest/load_vdi/BUILD.gn b/adapter/uhdf2/test/unittest/load_vdi/BUILD.gn index af3f4b595..a6c2829b2 100644 --- a/adapter/uhdf2/test/unittest/load_vdi/BUILD.gn +++ b/adapter/uhdf2/test/unittest/load_vdi/BUILD.gn @@ -82,4 +82,4 @@ ohos_shared_library("libvdi_sample1_fault") { "../../../utils:libhdf_utils", ] external_deps = [ "hilog:libhilog" ] -} \ No newline at end of file +} -- Gitee From 5061a43f5e5732d220c965d6b50874c33af6e1ac Mon Sep 17 00:00:00 2001 From: guoqi11 Date: Mon, 3 Jul 2023 09:20:59 +0000 Subject: [PATCH 3/3] fix: add sample about hdf load vdi Signed-off-by: guoqi11 --- adapter/uhdf2/test/BUILD.gn | 61 +++++++++++++++++++ adapter/uhdf2/test/unittest/load_vdi/BUILD.gn | 15 ++--- 2 files changed, 69 insertions(+), 7 deletions(-) diff --git a/adapter/uhdf2/test/BUILD.gn b/adapter/uhdf2/test/BUILD.gn index e69de29bb..cf2b408ab 100644 --- a/adapter/uhdf2/test/BUILD.gn +++ b/adapter/uhdf2/test/BUILD.gn @@ -0,0 +1,61 @@ +# Copyright (c) 2021-2023 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. + +declare_args() { + hdf_core_khdf_test_support = true + hdf_core_platform_test_support = false +} + +if (hdf_core_khdf_test_support) { + group("hdf_test_uhdf") { + testonly = true + deps = [ + "./../../../framework/test/fuzztest:hdf_framework_fuzztest", + "fuzztest:hdf_platform_test", + "unittest/config:hdf_adapter_uhdf_test_config", + "unittest/load_vdi:hdf_load_vdi_test", + "unittest/load_vdi:libvdi_sample1_driver", + "unittest/load_vdi:libvdi_sample1_fault", + "unittest/load_vdi:libvdi_sample2_driver", + "unittest/manager:hdf_adapter_uhdf_test_core_shared", + "unittest/manager:hdf_adapter_uhdf_test_ioservice", + "unittest/manager:hdf_adapter_uhdf_test_manager", + "unittest/manager:hdf_adapter_uhdf_test_pm", + "unittest/manager:hdf_adapter_uhdf_test_remote_adapter", + "unittest/manager:hdf_adapter_uhdf_test_sbuf", + "unittest/manager:hdf_adapter_uhdf_test_uevent", + "unittest/osal:hdf_adapter_uhdf_test_osal", + "unittest/osal:hdf_adapter_uhdf_test_osal_posix", + "unittest/platform/i2c:ui2c_test", + ] + if (hdf_core_platform_test_support) { + deps += [ "unittest/platform:hdf_adapter_uhdf_test_platform" ] + } + } +} else { + group("hdf_test_uhdf") { + testonly = true + deps = [ + "./../../../framework/test/fuzztest:hdf_framework_fuzztest", + "fuzztest:hdf_platform_test", + "unittest/load_vdi:hdf_load_vdi_test", + "unittest/load_vdi:libvdi_sample1_driver", + "unittest/load_vdi:libvdi_sample1_fault", + "unittest/load_vdi:libvdi_sample2_driver", + "unittest/manager:hdf_adapter_uhdf_test_core_shared", + "unittest/manager:hdf_adapter_uhdf_test_remote_adapter", + "unittest/manager:hdf_adapter_uhdf_test_sbuf", + "unittest/osal:hdf_adapter_uhdf_test_osal_posix", + ] + } +} diff --git a/adapter/uhdf2/test/unittest/load_vdi/BUILD.gn b/adapter/uhdf2/test/unittest/load_vdi/BUILD.gn index a6c2829b2..040e9e81e 100644 --- a/adapter/uhdf2/test/unittest/load_vdi/BUILD.gn +++ b/adapter/uhdf2/test/unittest/load_vdi/BUILD.gn @@ -28,6 +28,7 @@ ohos_unittest("hdf_load_vdi_test") { } deps = [ ":libvdi_sample1_driver", + ":libvdi_sample1_fault", ":libvdi_sample2_driver", "../../../host:libhdf_host", "../../../utils:libhdf_utils", @@ -53,12 +54,11 @@ ohos_shared_library("libvdi_sample1_driver") { external_deps = [ "hilog:libhilog" ] } -ohos_shared_library("libvdi_sample2_driver") { +ohos_shared_library("libvdi_sample1_fault") { include_dirs = [ "../../../../../framework/core/host/test/sample" ] - sources = [ - "../../../../../framework/core/host/test/sample/vdi_sample2_driver.cpp", - ] + sources = + [ "../../../../../framework/core/host/test/sample/vdi_sample1_fault.c" ] install_images = [ chipset_base_dir ] subsystem_name = "hdf" part_name = "hdf_core" @@ -69,11 +69,12 @@ ohos_shared_library("libvdi_sample2_driver") { external_deps = [ "hilog:libhilog" ] } -ohos_shared_library("libvdi_sample1_fault") { +ohos_shared_library("libvdi_sample2_driver") { include_dirs = [ "../../../../../framework/core/host/test/sample" ] - sources = - [ "../../../../../framework/core/host/test/sample/vdi_sample1_fault.c" ] + sources = [ + "../../../../../framework/core/host/test/sample/vdi_sample2_driver.cpp", + ] install_images = [ chipset_base_dir ] subsystem_name = "hdf" part_name = "hdf_core" -- Gitee