From afef2104a5ae15358bf3b7fe60be034d12c979de Mon Sep 17 00:00:00 2001 From: Nick Connolly Date: Mon, 16 Nov 2020 11:26:09 +0000 Subject: [PATCH] test/unit/lib/idxd: Add unit test stubs With some build environments (e.g. clang, see #1613) linking fails with unresolved references. This is caused by the inclusion of 'unused code' which is usually discarded by the linker. The 'unused code' contains references to functions that have not been 'stubbed' out. The failure can be seen by removing 'LDFLAGS += -Wl,--gc-sections' in spdk.unittest.mk Resolved by adding stubs for missing references. These are never called so return an arbtrary default value. Move include of idxd/idxd.c after definition of movdir64b so that mock function is used. Part of a set of independent changes which Fixes #1613 Signed-off-by: Nick Connolly Change-Id: I760755122a1d3ca96f12b00b0040ae15471beafa Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5110 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk --- test/unit/lib/idxd/idxd.c/idxd_ut.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/unit/lib/idxd/idxd.c/idxd_ut.c b/test/unit/lib/idxd/idxd.c/idxd_ut.c index a4e1f390c..678c04145 100644 --- a/test/unit/lib/idxd/idxd.c/idxd_ut.c +++ b/test/unit/lib/idxd/idxd.c/idxd_ut.c @@ -35,7 +35,8 @@ #include "spdk_internal/mock.h" #include "spdk_internal/idxd.h" #include "common/lib/test_env.c" -#include "idxd/idxd.c" + +#include "idxd/idxd.h" #define FAKE_REG_SIZE 0x800 #define NUM_GROUPS 4 @@ -44,6 +45,8 @@ #define TOTAL_WQS (NUM_GROUPS * NUM_WQ_PER_GROUP) #define TOTAL_ENGINES (NUM_GROUPS * NUM_ENGINES_PER_GROUP) +DEFINE_STUB(spdk_pci_idxd_get_driver, struct spdk_pci_driver *, (void), NULL); + int spdk_pci_enumerate(struct spdk_pci_driver *driver, spdk_pci_enum_cb enum_cb, void *enum_ctx) { @@ -88,6 +91,8 @@ mock_movdir64b(void *dst, const void *src) return; } +#include "idxd/idxd.c" + #define WQ_CFG_OFFSET 0x500 #define TOTAL_WQE_SIZE 0x40 static int