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 <nick.connolly@mayadata.io>
Change-Id: I760755122a1d3ca96f12b00b0040ae15471beafa
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5110
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Nick Connolly 2020-11-16 11:26:09 +00:00 committed by Tomasz Zawadzki
parent 43b185746f
commit afef2104a5

View File

@ -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