test/accel: add UT for test_spdk_accel_submit_compare()
Signed-off-by: Monica Kenguva <monica.kenguva@intel.com> Change-Id: I3287353d76de226f950620f1a4702887d33b1686 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9297 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
parent
2e736160e1
commit
b22cd665c9
@ -450,6 +450,75 @@ test_spdk_accel_submit_dualcast(void)
|
||||
spdk_free(dst2);
|
||||
}
|
||||
|
||||
static void
|
||||
test_spdk_accel_submit_compare(void)
|
||||
{
|
||||
void *src1;
|
||||
void *src2;
|
||||
uint64_t nbytes = TEST_SUBMIT_SIZE;
|
||||
void *cb_arg = NULL;
|
||||
int rc;
|
||||
struct spdk_accel_task task;
|
||||
struct spdk_accel_task *expected_accel_task = NULL;
|
||||
|
||||
src1 = calloc(1, TEST_SUBMIT_SIZE);
|
||||
SPDK_CU_ASSERT_FATAL(src1 != NULL);
|
||||
src2 = calloc(1, TEST_SUBMIT_SIZE);
|
||||
SPDK_CU_ASSERT_FATAL(src2 != NULL);
|
||||
|
||||
/* Fail with no tasks on _get_task() */
|
||||
rc = spdk_accel_submit_compare(g_ch, src1, src2, nbytes, dummy_submit_cb_fn, cb_arg);
|
||||
CU_ASSERT(rc == -ENOMEM);
|
||||
|
||||
TAILQ_INIT(&g_accel_ch->task_pool);
|
||||
task.cb_fn = dummy_submit_cb_fn;
|
||||
task.cb_arg = cb_arg;
|
||||
task.accel_ch = g_accel_ch;
|
||||
task.batch = NULL;
|
||||
TAILQ_INSERT_TAIL(&g_accel_ch->task_pool, &task, link);
|
||||
|
||||
g_accel_ch->engine = &g_accel_engine;
|
||||
g_accel_ch->engine->capabilities = ACCEL_COMPARE;
|
||||
g_accel_ch->engine->submit_tasks = dummy_submit_tasks;
|
||||
|
||||
/* HW accel submission OK. */
|
||||
rc = spdk_accel_submit_compare(g_ch, src1, src2, nbytes, dummy_submit_cb_fn, cb_arg);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(task.src == src1);
|
||||
CU_ASSERT(task.src2 == src2);
|
||||
CU_ASSERT(task.op_code == ACCEL_OPCODE_COMPARE);
|
||||
CU_ASSERT(task.nbytes == nbytes);
|
||||
CU_ASSERT(g_dummy_submit_called == true);
|
||||
|
||||
TAILQ_INSERT_TAIL(&g_accel_ch->task_pool, &task, link);
|
||||
/* Reset values before next case */
|
||||
g_dummy_submit_called = false;
|
||||
g_accel_ch->engine->capabilities = 0;
|
||||
task.src = 0;
|
||||
task.src2 = 0;
|
||||
task.op_code = 0xff;
|
||||
task.nbytes = 0;
|
||||
|
||||
memset(src1, 0x5A, TEST_SUBMIT_SIZE);
|
||||
memset(src2, 0x5A, TEST_SUBMIT_SIZE);
|
||||
|
||||
/* SW engine does compare. */
|
||||
rc = spdk_accel_submit_compare(g_ch, src1, src2, nbytes, dummy_submit_cb_fn, cb_arg);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(task.src == src1);
|
||||
CU_ASSERT(task.src2 == src2);
|
||||
CU_ASSERT(task.op_code == ACCEL_OPCODE_COMPARE);
|
||||
CU_ASSERT(task.nbytes == nbytes);
|
||||
CU_ASSERT(g_dummy_submit_cb_called == false);
|
||||
CU_ASSERT(memcmp(src1, src2, TEST_SUBMIT_SIZE) == 0);
|
||||
expected_accel_task = TAILQ_FIRST(&g_sw_ch->tasks_to_complete);
|
||||
TAILQ_REMOVE(&g_sw_ch->tasks_to_complete, expected_accel_task, link);
|
||||
CU_ASSERT(expected_accel_task == &task);
|
||||
|
||||
free(src1);
|
||||
free(src2);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CU_pSuite suite = NULL;
|
||||
@ -470,6 +539,7 @@ int main(int argc, char **argv)
|
||||
CU_ADD_TEST(suite, test_get_task);
|
||||
CU_ADD_TEST(suite, test_spdk_accel_submit_copy);
|
||||
CU_ADD_TEST(suite, test_spdk_accel_submit_dualcast);
|
||||
CU_ADD_TEST(suite, test_spdk_accel_submit_compare);
|
||||
|
||||
CU_basic_set_mode(CU_BRM_VERBOSE);
|
||||
CU_basic_run_tests();
|
||||
|
Loading…
Reference in New Issue
Block a user