diff --git a/adapter/uhdf2/test/BUILD.gn b/adapter/uhdf2/test/BUILD.gn
index 81cecaeac9d22907e608beabd676303b9390ff9f..2d16593808694e74bef5c2525d17109494304987 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 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..af3f4b59593993f069f6d79fd811f69fa86fd342 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 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;