From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 2BCFC2C56 for ; Fri, 4 May 2018 12:22:56 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 May 2018 03:22:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,362,1520924400"; d="scan'208";a="225767761" Received: from silpixa00399464.ir.intel.com (HELO silpixa00399464.ger.corp.intel.com) ([10.237.222.157]) by fmsmga006.fm.intel.com with ESMTP; 04 May 2018 03:22:54 -0700 From: Pablo de Lara To: dev@dpdk.org Cc: fiona.trahe@intel.com, lee.daly@intel.com, shally.verma@cavium.com, ahmed.mansour@nxp.com, Ashish.Gupta@cavium.com, Pablo de Lara Date: Fri, 4 May 2018 11:22:18 +0100 Message-Id: <20180504102218.30672-6-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180504102218.30672-1-pablo.de.lara.guarch@intel.com> References: <20180228140010.27251-1-pablo.de.lara.guarch@intel.com> <20180504102218.30672-1-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v4 5/5] test/compress: add invalid configuration tests X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2018 10:22:56 -0000 Add tests that check if device configuration is not successful when providing invalid parameters. Signed-off-by: Pablo de Lara Acked-by: Lee Daly --- test/test/test_compressdev.c | 49 +++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/test/test/test_compressdev.c b/test/test/test_compressdev.c index 1f54263ed..210f87afe 100644 --- a/test/test/test_compressdev.c +++ b/test/test/test_compressdev.c @@ -185,6 +185,51 @@ generic_ut_teardown(void) RTE_LOG(ERR, USER1, "Device could not be closed\n"); } +static int +test_compressdev_invalid_configuration(void) +{ + struct rte_compressdev_config invalid_config; + struct rte_compressdev_config valid_config = { + .socket_id = rte_socket_id(), + .nb_queue_pairs = 1, + .max_nb_priv_xforms = NUM_MAX_XFORMS, + .max_nb_streams = 0 + }; + struct rte_compressdev_info dev_info; + + /* Invalid configuration with 0 queue pairs */ + memcpy(&invalid_config, &valid_config, + sizeof(struct rte_compressdev_config)); + invalid_config.nb_queue_pairs = 0; + + TEST_ASSERT_FAIL(rte_compressdev_configure(0, &invalid_config), + "Device configuration was successful " + "with no queue pairs (invalid)\n"); + + /* + * Invalid configuration with too many queue pairs + * (if there is an actual maximum number of queue pairs) + */ + rte_compressdev_info_get(0, &dev_info); + if (dev_info.max_nb_queue_pairs != 0) { + memcpy(&invalid_config, &valid_config, + sizeof(struct rte_compressdev_config)); + invalid_config.nb_queue_pairs = dev_info.max_nb_queue_pairs + 1; + + TEST_ASSERT_FAIL(rte_compressdev_configure(0, &invalid_config), + "Device configuration was successful " + "with too many queue pairs (invalid)\n"); + } + + /* Invalid queue pair setup, with no number of queue pairs set */ + TEST_ASSERT_FAIL(rte_compressdev_queue_pair_setup(0, 0, + NUM_MAX_INFLIGHT_OPS, rte_socket_id()), + "Queue pair setup was successful " + "with no queue pairs set (invalid)\n"); + + return TEST_SUCCESS; +} + static int compare_buffers(const char *buffer1, uint32_t buffer1_len, const char *buffer2, uint32_t buffer2_len) @@ -700,7 +745,7 @@ test_deflate_comp_decomp(const char * const test_bufs[], /* Attach non shareable private xform data to ops */ for (i = 0; i < num_bufs; i++) { - priv_data = (struct priv_op_data *) (ops[i] + 1); + priv_data = (struct priv_op_data *)(ops[i] + 1); uint16_t xform_idx = priv_data->orig_idx; ops[i]->private_xform = priv_xforms[xform_idx]; } @@ -1067,6 +1112,8 @@ static struct unit_test_suite compressdev_testsuite = { .setup = testsuite_setup, .teardown = testsuite_teardown, .unit_test_cases = { + TEST_CASE_ST(NULL, NULL, + test_compressdev_invalid_configuration), TEST_CASE_ST(generic_ut_setup, generic_ut_teardown, test_compressdev_deflate_stateless_fixed), TEST_CASE_ST(generic_ut_setup, generic_ut_teardown, -- 2.17.0