lib/idxd: add unit test for idxd_wait_cmd()
Signed-off-by: paul luse <paul.e.luse@intel.com> Change-Id: Ida3185431b526092a0450f2452df665ea0d19abb Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1818 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
8e496c5155
commit
3075d23318
@ -81,6 +81,39 @@ mock_movdir64b(void *dst, const void *src)
|
||||
return;
|
||||
}
|
||||
|
||||
#define FAKE_REG_SIZE 1024
|
||||
static int
|
||||
test_idxd_wait_cmd(void)
|
||||
{
|
||||
struct spdk_idxd_device idxd = {};
|
||||
int timeout = 1;
|
||||
union idxd_cmdsts_reg *fake_cmd_status_reg;
|
||||
int rc;
|
||||
|
||||
idxd.reg_base = calloc(1, FAKE_REG_SIZE);
|
||||
SPDK_CU_ASSERT_FATAL(idxd.reg_base != NULL);
|
||||
fake_cmd_status_reg = idxd.reg_base + IDXD_CMDSTS_OFFSET;
|
||||
|
||||
/* Test happy path. */
|
||||
rc = idxd_wait_cmd(&idxd, timeout);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
/* Setup up our fake register to set the error bit. */
|
||||
fake_cmd_status_reg->err = 1;
|
||||
rc = idxd_wait_cmd(&idxd, timeout);
|
||||
CU_ASSERT(rc == -EINVAL);
|
||||
fake_cmd_status_reg->err = 0;
|
||||
|
||||
/* Setup up our fake register to set the active bit. */
|
||||
fake_cmd_status_reg->active = 1;
|
||||
rc = idxd_wait_cmd(&idxd, timeout);
|
||||
CU_ASSERT(rc == -EBUSY);
|
||||
|
||||
free(idxd.reg_base);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
test_spdk_idxd_set_config(void)
|
||||
{
|
||||
@ -128,6 +161,7 @@ int main(int argc, char **argv)
|
||||
|
||||
CU_ADD_TEST(suite, test_spdk_idxd_reconfigure_chan);
|
||||
CU_ADD_TEST(suite, test_spdk_idxd_set_config);
|
||||
CU_ADD_TEST(suite, test_idxd_wait_cmd);
|
||||
|
||||
CU_basic_set_mode(CU_BRM_VERBOSE);
|
||||
CU_basic_run_tests();
|
||||
|
Loading…
Reference in New Issue
Block a user