From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id D5FBC5B40 for ; Thu, 20 Dec 2018 15:58:29 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Dec 2018 06:58:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,377,1539673200"; d="scan'208";a="119873520" Received: from silpixa00399502.ir.intel.com (HELO silpixa00399502.ger.corp.intel.com) ([10.237.222.111]) by orsmga002.jf.intel.com with ESMTP; 20 Dec 2018 06:58:26 -0800 From: Marko Kovacevic To: dev@dpdk.org Cc: akhil.goyal@nxp.com, lee.daly@intel.com, tomaszx.jozwiak@intel.com, cathal.ohare@intel.com, fiona.trahe@intel.com, "Kovacevic, Marko" Date: Thu, 20 Dec 2018 14:58:23 +0000 Message-Id: <20181220145824.37223-1-marko.kovacevic@intel.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20181214153326.17356-1-marko.kovacevic@intel.com> References: <20181214153326.17356-1-marko.kovacevic@intel.com> Subject: [dpdk-dev] [PATCH v2 1/2] test/compress: add out of space test 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: Thu, 20 Dec 2018 14:58:30 -0000 From: "Kovacevic, Marko" This patch adds new out of space testcase to check that the destination mbuf is smaller than required for the output of compression to ensure the driver doesn't crash and returns the valid error case. Signed-off-by: Marko Kovacevic Acked-by: Lee Daly --- V2: Added check flag to return proper status to user --- test/test/test_compressdev.c | 130 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 126 insertions(+), 4 deletions(-) diff --git a/test/test/test_compressdev.c b/test/test/test_compressdev.c index 42327dc..b2999fa 100644 --- a/test/test/test_compressdev.c +++ b/test/test/test_compressdev.c @@ -41,6 +41,9 @@ #define ZLIB_TRAILER_SIZE 4 #define GZIP_HEADER_SIZE 10 #define GZIP_TRAILER_SIZE 8 +#define OUT_OF_SPACE_BUF 1 + +int out_of_space; const char * huffman_type_strings[] = { @@ -734,8 +737,9 @@ test_deflate_comp_decomp(const char * const test_bufs[], if (sgl) { for (i = 0; i < num_bufs; i++) { - data_size = strlen(test_bufs[i]) * - COMPRESS_BUF_SIZE_RATIO; + out_of_space ? data_size = OUT_OF_SPACE_BUF : + (data_size = strlen(test_bufs[i]) * + COMPRESS_BUF_SIZE_RATIO); if (prepare_sgl_bufs(NULL, comp_bufs[i], data_size, ts_params->small_mbuf_pool, @@ -746,8 +750,9 @@ test_deflate_comp_decomp(const char * const test_bufs[], } else { for (i = 0; i < num_bufs; i++) { - data_size = strlen(test_bufs[i]) * - COMPRESS_BUF_SIZE_RATIO; + out_of_space ? data_size = OUT_OF_SPACE_BUF : + (data_size = strlen(test_bufs[i]) * + COMPRESS_BUF_SIZE_RATIO); rte_pktmbuf_append(comp_bufs[i], data_size); } } @@ -913,6 +918,16 @@ test_deflate_comp_decomp(const char * const test_bufs[], * compress operation information is needed for the decompression stage) */ for (i = 0; i < num_bufs; i++) { + if(out_of_space) { + if (ops_processed[i]->status == + RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED) { + RTE_LOG(ERR, USER1, + "Some operations were not successful\n"); + out_of_space = 0; + goto exit; + } + } + if (ops_processed[i]->status != RTE_COMP_OP_STATUS_SUCCESS) { RTE_LOG(ERR, USER1, "Some operations were not successful\n"); @@ -1110,6 +1125,16 @@ test_deflate_comp_decomp(const char * const test_bufs[], * compress operation information is still needed) */ for (i = 0; i < num_bufs; i++) { + if(out_of_space) { + if (ops_processed[i]->status == + RTE_COMP_OP_STATUS_OUT_OF_SPACE_TERMINATED) { + RTE_LOG(ERR, USER1, + "Some operations were not successful\n"); + out_of_space = 0; + goto exit; + } + } + if (ops_processed[i]->status != RTE_COMP_OP_STATUS_SUCCESS) { RTE_LOG(ERR, USER1, "Some operations were not successful\n"); @@ -1664,6 +1689,101 @@ test_compressdev_deflate_stateless_checksum(void) return ret; } +static int +test_compressdev_out_of_space_buffer(void) +{ + struct comp_testsuite_params *ts_params = &testsuite_params; + const char *test_buffer; + int ret; + uint16_t i = 0; + const struct rte_compressdev_capabilities *capab; + out_of_space = 1; + + capab = rte_compressdev_capability_get(0, RTE_COMP_ALGO_DEFLATE); + TEST_ASSERT(capab != NULL, "Failed to retrieve device capabilities"); + + if ((capab->comp_feature_flags & RTE_COMP_FF_HUFFMAN_FIXED) == 0) + return -ENOTSUP; + + struct rte_comp_xform *compress_xform = + rte_malloc(NULL, sizeof(struct rte_comp_xform), 0); + + if (compress_xform == NULL) { + RTE_LOG(ERR, USER1, + "Compress xform could not be created\n"); + ret = TEST_FAILED; + goto exit; + } + + test_buffer = compress_test_bufs[i]; + + /* Compress with compressdev, decompress with Zlib */ + if (test_deflate_comp_decomp(&test_buffer, 1, + &i, + &ts_params->def_comp_xform, + &ts_params->def_decomp_xform, + 1, + RTE_COMP_OP_STATELESS, + 0, + ZLIB_DECOMPRESS) == 0 && out_of_space == 1) { + ret = TEST_FAILED; + goto exit; + } + out_of_space =1; + + /* Compress with Zlib, decompress with compressdev */ + if (test_deflate_comp_decomp(&test_buffer, 1, + &i, + &ts_params->def_comp_xform, + &ts_params->def_decomp_xform, + 1, + RTE_COMP_OP_STATELESS, + 0, + ZLIB_COMPRESS) == 0 && out_of_space == 1) { + ret = TEST_FAILED; + goto exit; + } + out_of_space =1; + + if (capab->comp_feature_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) { + /* Compress with compressdev, decompress with Zlib */ + if (test_deflate_comp_decomp(&test_buffer, 1, + &i, + &ts_params->def_comp_xform, + &ts_params->def_decomp_xform, + 1, + RTE_COMP_OP_STATELESS, + 1, + ZLIB_DECOMPRESS) == 0 && out_of_space == 1) { + ret = TEST_FAILED; + goto exit; + + } + out_of_space =1; + + /* Compress with Zlib, decompress with compressdev */ + if (test_deflate_comp_decomp(&test_buffer, 1, + &i, + &ts_params->def_comp_xform, + &ts_params->def_decomp_xform, + 1, + RTE_COMP_OP_STATELESS, + 1, + ZLIB_COMPRESS) == 0 && out_of_space == 1) { + ret = TEST_FAILED; + goto exit; + } + + } + + ret = TEST_SUCCESS; + +exit: + out_of_space = 0; + rte_free(compress_xform); + return ret; +} + static struct unit_test_suite compressdev_testsuite = { .suite_name = "compressdev unit test suite", .setup = testsuite_setup, @@ -1685,6 +1805,8 @@ static struct unit_test_suite compressdev_testsuite = { test_compressdev_deflate_stateless_sgl), TEST_CASE_ST(generic_ut_setup, generic_ut_teardown, test_compressdev_deflate_stateless_checksum), + TEST_CASE_ST(generic_ut_setup, generic_ut_teardown, + test_compressdev_out_of_space_buffer), TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 2.9.5