diff --git a/adapter/uhdf2/test/BUILD.gn b/adapter/uhdf2/test/BUILD.gn
index 81cecaeac9d22907e608beabd676303b9390ff9f..cf2b408ab126880ed8e211d762ec7a43885ab6ad 100644
--- a/adapter/uhdf2/test/BUILD.gn
+++ b/adapter/uhdf2/test/BUILD.gn
@@ -1,59 +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_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_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",
- ]
- }
-}
+# 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/resource/load_vdi/arch32/ohos_test.xml b/adapter/uhdf2/test/resource/load_vdi/arch32/ohos_test.xml
index a7742be75ef1a676a89c15cfc13dca57b186f301..e5b7b9ac7146ef01dbf3db74e8c828e373ffd3b5 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 d4ad65972d4ca3599fd42f839aac40ed6aae70a3..1acbcdc66d2b2c6522bfa11392d253e6f69368f7 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 f3420266b16c1e5c6edb340e4e0e30e353f68c11..040e9e81e92d7c56856fd3cd417f086a44110aa0 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,6 +54,21 @@ ohos_shared_library("libvdi_sample1_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" ]
+}
+
ohos_shared_library("libvdi_sample2_driver") {
include_dirs = [ "../../../../../framework/core/host/test/sample" ]
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 0000000000000000000000000000000000000000..881141f659d5e5ecede767a4f39e6c21bfbc025b
--- /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 0000000000000000000000000000000000000000..485709bf1bf457b9535de7859fa4a7365a3a9ca7
--- /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 d0d659adabec2e98a48d6f8824cdf719f99ce61a..368075b59a63cbf13e02eb140952b1ba14a1a066 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;