[v4] Test/crypto: check valid test_stats before running test

Message ID 20200516015514.8773-1-apeksha.gupta@nxp.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series [v4] Test/crypto: check valid test_stats before running test |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-nxp-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing fail Testing issues

Commit Message

Apeksha Gupta May 16, 2020, 1:55 a.m. UTC
  Test_stats is an optional cryptodev op and if it is not defined by the
PMD, it should not run the test cases for it.

Signed-off-by: Apeksha Gupta <apeksha.gupta@nxp.com>
---
 app/test/test_cryptodev.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
  

Comments

Akhil Goyal May 17, 2020, 2:09 p.m. UTC | #1
> Test_stats is an optional cryptodev op and if it is not defined by the
> PMD, it should not run the test cases for it.
> 
> Signed-off-by: Apeksha Gupta <apeksha.gupta@nxp.com>
> ---

Acked-by: Akhil Goyal <akhil.goyal@nxp.com>

Title and description of the patch updated as
    test/crypto: fix statistics case

    The test case - test_stats is directly accessing the
    cryptodev and its dev_ops which are internal to library
    and should not be used directly by the application.
    However, the test case is also missing to check for the
    error ENOTSUP. It should skip the case if the API returns
    ENOTSUP. This patch fixes these two issues.

    Fixes: 202d375c60bc ("app/test: add cryptodev unit and performance tests")
    Cc: stable@dpdk.org

    Signed-off-by: Apeksha Gupta <apeksha.gupta@nxp.com>

Applied to dpdk-next-crypto.

Thanks.
  

Patch

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index c624018ee..83fee232d 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -8795,8 +8795,6 @@  test_stats(void)
 {
 	struct crypto_testsuite_params *ts_params = &testsuite_params;
 	struct rte_cryptodev_stats stats;
-	struct rte_cryptodev *dev;
-	cryptodev_stats_get_t temp_pfn;
 
 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
 		return -ENOTSUP;
@@ -8813,6 +8811,9 @@  test_stats(void)
 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
 			&cap_idx) == NULL)
 		return -ENOTSUP;
+	if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
+			== -ENOTSUP)
+		return -ENOTSUP;
 
 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
@@ -8820,13 +8821,6 @@  test_stats(void)
 		"rte_cryptodev_stats_get invalid dev failed");
 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
 		"rte_cryptodev_stats_get invalid Param failed");
-	dev = &rte_cryptodevs[ts_params->valid_devs[0]];
-	temp_pfn = dev->dev_ops->stats_get;
-	dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
-	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
-			== -ENOTSUP),
-		"rte_cryptodev_stats_get invalid Param failed");
-	dev->dev_ops->stats_get = temp_pfn;
 
 	/* Test expected values */
 	ut_setup();