From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AB713A0C4E; Mon, 8 Nov 2021 16:14:44 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 998E640E28; Mon, 8 Nov 2021 16:14:44 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 2D4E340E03 for ; Mon, 8 Nov 2021 16:14:43 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1A8CV8YW013729; Mon, 8 Nov 2021 07:14:42 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=RXlJXhqLMuWeRVmAhunQcRZ8M01nzp0z/y+mmVW9evo=; b=QYG0IKEMNVkhmDRyvc86Fj3GarIcazzhIE3GYartU0mK7qba1SNCec5PP3ls8QNoUZEG G3GrKw0TJsdsTZBTh+0JxiG6bzcoVROCneRYmsjVadZ5ukix1p7MrbVjO/AJUCR5+cCh EHcnWLs1fjwftIr7MpPhlmfR7TNce2YSElWVPlazN5HdxqxC57HJLh1cI1p+FyG4pHi7 8qIqV3huWps8RiOxxaFLR2FdD8V22xOP2qwB8KrrkWCNnJtNSJ7VnFzzV+GTuMZtHVYS LCv1bKhUGfqasH9sisRKrdJg3w2qZlQn0RXqeETYDcM+Us7npFcXEr4PWFvWdO3GF0er fQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3c6uwa2p0d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 08 Nov 2021 07:14:41 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 8 Nov 2021 07:14:39 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Mon, 8 Nov 2021 07:14:39 -0800 Received: from HY-LT1002.marvell.com (HY-LT1002.marvell.com [10.28.176.218]) by maili.marvell.com (Postfix) with ESMTP id 27F903F7071; Mon, 8 Nov 2021 07:14:33 -0800 (PST) From: Anoob Joseph To: Akhil Goyal , Declan Doherty , Fan Zhang CC: Anoob Joseph , Jerin Jacob , Archana Muniganti , Tejasree Kondoj , Hemant Agrawal , "Radu Nicolau" , Ciara Power , Gagandeep Singh , , Date: Mon, 8 Nov 2021 20:43:46 +0530 Message-ID: <1636384426-95-1-git-send-email-anoobj@marvell.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: QtyiEQofK_I_ZVT1YniAbUwLuxgLxZqg X-Proofpoint-GUID: QtyiEQofK_I_ZVT1YniAbUwLuxgLxZqg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-08_05,2021-11-08_01,2020-04-07_01 Subject: [dpdk-dev] [PATCH] test/crypto: fix missing return checks X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The API could return errors. Add error checking for the same. Fixes: b3bbd9e5f265 ("cryptodev: support device independent sessions") Cc: slawomirx.mrozowicz@intel.com Signed-off-by: Anoob Joseph --- app/test/test_cryptodev.c | 116 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 80 insertions(+), 36 deletions(-) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index cd5c3dc..e54a1a9 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -2138,6 +2138,7 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; + int status; /* Verify the capabilities */ struct rte_cryptodev_sym_capability_idx cap_idx; @@ -2184,12 +2185,17 @@ test_AES_CBC_HMAC_SHA1_encrypt_digest(void) ut_params->sess = rte_cryptodev_sym_session_create( ts_params->session_mpool); + TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); /* Create crypto session*/ - rte_cryptodev_sym_session_init(ts_params->valid_devs[0], + status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0], ut_params->sess, &ut_params->cipher_xform, ts_params->session_priv_mpool); - TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); + + if (status == -ENOTSUP) + return TEST_SKIPPED; + + TEST_ASSERT_EQUAL(status, 0, "Session init failed"); /* Generate crypto op data structure */ ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, @@ -7965,6 +7971,7 @@ create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo, uint8_t iv_len) { uint8_t aead_key[key_len]; + int status; struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -7988,14 +7995,13 @@ create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo, /* Create Crypto session*/ ut_params->sess = rte_cryptodev_sym_session_create( ts_params->session_mpool); + TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); - rte_cryptodev_sym_session_init(dev_id, ut_params->sess, + status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, &ut_params->aead_xform, ts_params->session_priv_mpool); - TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); - - return 0; + return status; } static int @@ -11113,6 +11119,7 @@ static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params, const struct HMAC_MD5_vector *test_case) { uint8_t key[64]; + int status; memcpy(key, test_case->key.data, test_case->key.len); @@ -11128,13 +11135,15 @@ static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params, ut_params->sess = rte_cryptodev_sym_session_create( ts_params->session_mpool); + TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); + if (ut_params->sess == NULL) + return TEST_FAILED; - rte_cryptodev_sym_session_init(ts_params->valid_devs[0], + status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0], ut_params->sess, &ut_params->auth_xform, ts_params->session_priv_mpool); - - if (ut_params->sess == NULL) - return TEST_FAILED; + if (status == -ENOTSUP) + return TEST_SKIPPED; ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); @@ -11347,6 +11356,7 @@ test_multi_session(void) struct rte_cryptodev_sym_session **sessions; uint16_t i; + int status; /* Verify the capabilities */ struct rte_cryptodev_sym_capability_idx cap_idx; @@ -11376,14 +11386,17 @@ test_multi_session(void) sessions[i] = rte_cryptodev_sym_session_create( ts_params->session_mpool); - - rte_cryptodev_sym_session_init(ts_params->valid_devs[0], - sessions[i], &ut_params->auth_xform, - ts_params->session_priv_mpool); TEST_ASSERT_NOT_NULL(sessions[i], "Session creation failed at session number %u", i); + status = rte_cryptodev_sym_session_init( + ts_params->valid_devs[0], + sessions[i], &ut_params->auth_xform, + ts_params->session_priv_mpool); + if (status == -ENOTSUP) + return TEST_SKIPPED; + /* Attempt to send a request on each session */ TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform( sessions[i], @@ -11476,6 +11489,7 @@ test_multi_session_random_usage(void) }, }; + int status; /* Verify the capabilities */ struct rte_cryptodev_sym_capability_idx cap_idx; @@ -11499,6 +11513,9 @@ test_multi_session_random_usage(void) for (i = 0; i < MB_SESSION_NUMBER; i++) { sessions[i] = rte_cryptodev_sym_session_create( ts_params->session_mpool); + TEST_ASSERT_NOT_NULL(sessions[i], + "Session creation failed at session number %u", + i); rte_memcpy(&ut_paramz[i].ut_params, &unittest_params, sizeof(struct crypto_unittest_params)); @@ -11508,16 +11525,16 @@ test_multi_session_random_usage(void) ut_paramz[i].cipher_key, ut_paramz[i].hmac_key); /* Create multiple crypto sessions*/ - rte_cryptodev_sym_session_init( + status = rte_cryptodev_sym_session_init( ts_params->valid_devs[0], sessions[i], &ut_paramz[i].ut_params.auth_xform, ts_params->session_priv_mpool); - TEST_ASSERT_NOT_NULL(sessions[i], - "Session creation failed at session number %u", - i); + if (status == -ENOTSUP) + return TEST_SKIPPED; + TEST_ASSERT_EQUAL(status, 0, "Session init failed"); } srand(time(NULL)); @@ -11629,6 +11646,7 @@ test_null_burst_operation(void) { struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; + int status; unsigned i, burst_len = NULL_BURST_LENGTH; @@ -11656,12 +11674,17 @@ test_null_burst_operation(void) ut_params->sess = rte_cryptodev_sym_session_create( ts_params->session_mpool); + TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); /* Create Crypto session*/ - rte_cryptodev_sym_session_init(ts_params->valid_devs[0], + status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0], ut_params->sess, &ut_params->cipher_xform, ts_params->session_priv_mpool); - TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); + + if (status == -ENOTSUP) + return TEST_SKIPPED; + + TEST_ASSERT_EQUAL(status, 0, "Session init failed"); TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len), @@ -12059,6 +12082,7 @@ static int create_gmac_session(uint8_t dev_id, enum rte_crypto_auth_operation auth_op) { uint8_t auth_key[tdata->key.len]; + int status; struct crypto_testsuite_params *ts_params = &testsuite_params; struct crypto_unittest_params *ut_params = &unittest_params; @@ -12079,14 +12103,13 @@ static int create_gmac_session(uint8_t dev_id, ut_params->sess = rte_cryptodev_sym_session_create( ts_params->session_mpool); + TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); - rte_cryptodev_sym_session_init(dev_id, ut_params->sess, + status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, &ut_params->auth_xform, ts_params->session_priv_mpool); - TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); - - return 0; + return status; } static int @@ -12124,6 +12147,8 @@ test_AES_GMAC_authentication(const struct gmac_test_data *tdata) retval = create_gmac_session(ts_params->valid_devs[0], tdata, RTE_CRYPTO_AUTH_OP_GENERATE); + if (retval == -ENOTSUP) + return TEST_SKIPPED; if (retval < 0) return retval; @@ -12253,6 +12278,8 @@ test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata) retval = create_gmac_session(ts_params->valid_devs[0], tdata, RTE_CRYPTO_AUTH_OP_VERIFY); + if (retval == -ENOTSUP) + return TEST_SKIPPED; if (retval < 0) return retval; @@ -12380,6 +12407,8 @@ test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata, retval = create_gmac_session(ts_params->valid_devs[0], tdata, RTE_CRYPTO_AUTH_OP_GENERATE); + if (retval == -ENOTSUP) + return TEST_SKIPPED; if (retval < 0) return retval; @@ -12709,6 +12738,7 @@ create_auth_session(struct crypto_unittest_params *ut_params, { struct crypto_testsuite_params *ts_params = &testsuite_params; uint8_t auth_key[reference->auth_key.len + 1]; + int status; memcpy(auth_key, reference->auth_key.data, reference->auth_key.len); @@ -12724,14 +12754,13 @@ create_auth_session(struct crypto_unittest_params *ut_params, /* Create Crypto session*/ ut_params->sess = rte_cryptodev_sym_session_create( ts_params->session_mpool); + TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); - rte_cryptodev_sym_session_init(dev_id, ut_params->sess, + status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, &ut_params->auth_xform, ts_params->session_priv_mpool); - TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); - - return 0; + return status; } static int @@ -12744,6 +12773,7 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params, struct crypto_testsuite_params *ts_params = &testsuite_params; uint8_t cipher_key[reference->cipher_key.len + 1]; uint8_t auth_key[reference->auth_key.len + 1]; + int status; memcpy(cipher_key, reference->cipher_key.data, reference->cipher_key.len); @@ -12777,14 +12807,13 @@ create_auth_cipher_session(struct crypto_unittest_params *ut_params, /* Create Crypto session*/ ut_params->sess = rte_cryptodev_sym_session_create( ts_params->session_mpool); + TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); - rte_cryptodev_sym_session_init(dev_id, ut_params->sess, + status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, &ut_params->auth_xform, ts_params->session_priv_mpool); - TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); - - return 0; + return status; } static int @@ -13000,6 +13029,9 @@ test_authentication_verify_fail_when_data_corruption( ts_params->valid_devs[0], reference, RTE_CRYPTO_AUTH_OP_VERIFY); + + if (retval == -ENOTSUP) + return TEST_SKIPPED; if (retval < 0) return retval; @@ -13175,6 +13207,9 @@ test_authenticated_decryption_fail_when_corruption( reference, RTE_CRYPTO_AUTH_OP_VERIFY, RTE_CRYPTO_CIPHER_OP_DECRYPT); + + if (retval == -ENOTSUP) + return TEST_SKIPPED; if (retval < 0) return retval; @@ -13236,6 +13271,7 @@ test_authenticated_encrypt_with_esn( uint8_t cipher_key[reference->cipher_key.len + 1]; uint8_t auth_key[reference->auth_key.len + 1]; struct rte_cryptodev_info dev_info; + int status; rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); uint64_t feat_flags = dev_info.feature_flags; @@ -13287,13 +13323,17 @@ test_authenticated_encrypt_with_esn( /* Create Crypto session*/ ut_params->sess = rte_cryptodev_sym_session_create( ts_params->session_mpool); + TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); - rte_cryptodev_sym_session_init(ts_params->valid_devs[0], + status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0], ut_params->sess, &ut_params->cipher_xform, ts_params->session_priv_mpool); - TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); + if (status == -ENOTSUP) + return TEST_SKIPPED; + + TEST_ASSERT_EQUAL(status, 0, "Session init failed"); ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); TEST_ASSERT_NOT_NULL(ut_params->ibuf, @@ -13419,13 +13459,17 @@ test_authenticated_decrypt_with_esn( /* Create Crypto session*/ ut_params->sess = rte_cryptodev_sym_session_create( ts_params->session_mpool); + TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); - rte_cryptodev_sym_session_init(ts_params->valid_devs[0], + retval = rte_cryptodev_sym_session_init(ts_params->valid_devs[0], ut_params->sess, &ut_params->auth_xform, ts_params->session_priv_mpool); - TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); + if (retval == -ENOTSUP) + return TEST_SKIPPED; + + TEST_ASSERT_EQUAL(retval, 0, "Session init failed"); ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); TEST_ASSERT_NOT_NULL(ut_params->ibuf, -- 2.7.4