-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add framework for tests. Signed-off-by: Anoob Joseph <anoobj@marvell.com> Change-Id: Ide7761ebae84e29e4e32bf4a2a3cabf8fcadf746 Reviewed-by: Akhil Goyal <gakhil@marvell.com> Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpu-offload/+/147762 Tested-by: sa_ip-toolkits-Jenkins <sa_ip-toolkits-jenkins@marvell.com> Reviewed-by: Jerin Jacob <jerinj@marvell.com>
- Loading branch information
1 parent
5bdc69f
commit f645a70
Showing
6 changed files
with
448 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* SPDX-License-Identifier: Marvell-MIT | ||
* Copyright (c) 2025 Marvell. | ||
*/ | ||
|
||
#include <stdlib.h> | ||
|
||
#include <dao_liquid_crypto.h> | ||
|
||
#include <rte_cycles.h> | ||
|
||
#include "lc_autotest.h" | ||
#include "lc_test_generic.h" | ||
#include "test.h" | ||
|
||
struct global_params glb_params; | ||
|
||
int | ||
testsuite_setup(void) | ||
{ | ||
return 0; | ||
} | ||
|
||
void | ||
testsuite_teardown(void) | ||
{ | ||
} | ||
|
||
int | ||
ut_setup(void) | ||
{ | ||
return 0; | ||
} | ||
|
||
void | ||
ut_teardown(void) | ||
{ | ||
} | ||
|
||
int | ||
op_dequeue(uint8_t dev_id, uint16_t qp_id, struct dao_lc_res *res) | ||
{ | ||
uint64_t timeout; | ||
int ret; | ||
|
||
/* Set a timeout of 1 second. */ | ||
timeout = rte_get_timer_cycles() + rte_get_timer_hz(); | ||
|
||
do { | ||
ret = dao_liquid_crypto_dequeue_burst(dev_id, qp_id, res, 1); | ||
if (ret == 1) | ||
break; | ||
|
||
if (rte_get_timer_cycles() > timeout) { | ||
TEST_LC_ERR("Operation timed out"); | ||
break; | ||
} | ||
} while (ret == 0); | ||
|
||
if (ret != 1) { | ||
TEST_LC_ERR("Could not dequeue operation"); | ||
return -1; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
static int | ||
ut_passthrough(void) | ||
{ | ||
uint8_t dev_id = glb_params.dev_id; | ||
uint16_t qp_id = glb_params.qp_id; | ||
uint64_t op_cookie = 0xdeadbeef; | ||
struct dao_lc_res res; | ||
int ret; | ||
|
||
ret = dao_liquid_crypto_enqueue_op_passthrough(dev_id, qp_id, op_cookie); | ||
if (ret < 0) { | ||
TEST_LC_ERR("Could not enqueue passthrough operation"); | ||
return TEST_FAILED; | ||
} | ||
|
||
ret = op_dequeue(dev_id, qp_id, &res); | ||
if (ret < 0) { | ||
TEST_LC_ERR("Could not dequeue passthrough operation"); | ||
return TEST_FAILED; | ||
} | ||
|
||
TEST_ASSERT(res.op_cookie == op_cookie, "Invalid operation cookie"); | ||
|
||
return TEST_SUCCESS; | ||
} | ||
|
||
struct unit_test_suite lc_testsuite_generic = { | ||
.suite_name = "Liquid Crypto Generic Test Suite", | ||
.setup = testsuite_setup, | ||
.teardown = testsuite_teardown, | ||
.unit_test_cases = { | ||
TEST_CASE_NAMED_ST("Passthrough Operation", ut_setup, ut_teardown, ut_passthrough), | ||
TEST_CASES_END() /**< NULL terminate unit test array */ | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* SPDX-License-Identifier: Marvell-MIT | ||
* Copyright (c) 2025 Marvell. | ||
*/ | ||
|
||
#ifndef __LC_TEST_GENERIC__ | ||
#define __LC_TEST_GENERIC__ | ||
|
||
#include <stdint.h> | ||
|
||
#include <dao_liquid_crypto.h> | ||
|
||
struct global_params { | ||
uint8_t dev_id; | ||
uint16_t qp_id; | ||
}; | ||
|
||
int testsuite_setup(void); | ||
void testsuite_teardown(void); | ||
int ut_setup(void); | ||
void ut_teardown(void); | ||
|
||
extern struct unit_test_suite lc_testsuite_generic; | ||
extern struct global_params glb_params; | ||
|
||
int op_dequeue(uint8_t dev_id, uint16_t qp_id, struct dao_lc_res *res); | ||
|
||
#endif /* __LC_TEST_GENERIC__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.