DPDK patches and discussions
 help / color / mirror / Atom feed
From: Marko Kovacevic <marko.kovacevic@intel.com>
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" <marko.kovacevic@intel.com>
Subject: [dpdk-dev] [PATCH v1 1/2] test/compress: add out of space test
Date: Fri, 14 Dec 2018 15:33:25 +0000	[thread overview]
Message-ID: <20181214153326.17356-1-marko.kovacevic@intel.com> (raw)

From: "Kovacevic, Marko" <marko.kovacevic@intel.com>

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 <marko.kovacevic@intel.com>
---
 test/test/test_compressdev.c | 112 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 108 insertions(+), 4 deletions(-)

diff --git a/test/test/test_compressdev.c b/test/test/test_compressdev.c
index 4ea13f4..63b1ba9 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[] = {
@@ -727,8 +730,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,
@@ -739,8 +743,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);
 		}
 	}
@@ -1663,6 +1668,103 @@ 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];
+
+	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) == 0) {
+			ret = TEST_FAILED;
+			goto exit;
+
+		}
+
+		/* 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) == 0) {
+			ret = TEST_FAILED;
+			goto exit;
+		}
+	}
+
+	/* 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) == 0) {
+		ret = TEST_FAILED;
+		goto exit;
+
+	}
+
+	/* 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) == 0) {
+		ret = TEST_FAILED;
+		goto exit;
+	}
+
+	ret  = TEST_SUCCESS;
+	out_of_space = 0;
+
+exit:
+	rte_free(compress_xform);
+	return ret;
+}
+
 static struct unit_test_suite compressdev_testsuite  = {
 	.suite_name = "compressdev unit test suite",
 	.setup = testsuite_setup,
@@ -1684,6 +1786,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

             reply	other threads:[~2018-12-14 15:33 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-14 15:33 Marko Kovacevic [this message]
2018-12-14 15:33 ` [dpdk-dev] [PATCH v1 2/2] test/compress: add varied buffer input/outputs Marko Kovacevic
2018-12-14 15:56   ` Daly, Lee
2018-12-14 15:55 ` [dpdk-dev] [PATCH v1 1/2] test/compress: add out of space test Daly, Lee
2018-12-20 14:58 ` [dpdk-dev] [PATCH v2 " Marko Kovacevic
2018-12-20 14:58   ` [dpdk-dev] [PATCH v2 2/2] test/compress: add varied buffer input/outputs Marko Kovacevic
2018-12-21  0:44     ` Trahe, Fiona
2019-01-09 17:02     ` De Lara Guarch, Pablo
2018-12-21  0:41   ` [dpdk-dev] [PATCH v2 1/2] test/compress: add out of space test Trahe, Fiona
2019-01-09 16:47   ` De Lara Guarch, Pablo
2019-01-11 15:08   ` [dpdk-dev] [PATCH v3 0/3] Compression Unit Tests Kovacevic, Marko
2019-01-11 15:08     ` [dpdk-dev] [PATCH v3 1/3] test/compress: refactor main test function Kovacevic, Marko
2019-01-11 16:52       ` [dpdk-dev] [PATCH v4 0/3] Compression Unit Tests Kovacevic, Marko
2019-01-11 16:52         ` [dpdk-dev] [PATCH v4 1/3] test/compress: refactor main test function Kovacevic, Marko
2019-01-17 10:19           ` [dpdk-dev] [PATCH v5 0/3] Compression Unit Tests Kovacevic, Marko
2019-01-17 10:19             ` [dpdk-dev] [PATCH v5 1/3] test/compress: refactor main test function Kovacevic, Marko
2019-01-17 10:19             ` [dpdk-dev] [PATCH v5 2/3] test/compress: add out of space test Kovacevic, Marko
2019-01-17 10:19             ` [dpdk-dev] [PATCH v5 3/3] test/compress: add varied buffer input/outputs Kovacevic, Marko
2019-01-18  0:06             ` [dpdk-dev] [PATCH v5 0/3] Compression Unit Tests Thomas Monjalon
2019-01-11 16:52         ` [dpdk-dev] [PATCH v4 2/3] test/compress: add out of space test Kovacevic, Marko
2019-01-16 17:16           ` De Lara Guarch, Pablo
2019-01-11 16:52         ` [dpdk-dev] [PATCH v4 3/3] test/compress: add varied buffer input/outputs Kovacevic, Marko
2019-01-16 17:21           ` De Lara Guarch, Pablo
2019-01-11 15:08     ` [dpdk-dev] [PATCH v3 2/3] test/compress: add out of space test Kovacevic, Marko
2019-01-11 15:09     ` [dpdk-dev] [PATCH v3 3/3] test/compress: add varied buffer input/outputs Kovacevic, Marko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181214153326.17356-1-marko.kovacevic@intel.com \
    --to=marko.kovacevic@intel.com \
    --cc=akhil.goyal@nxp.com \
    --cc=cathal.ohare@intel.com \
    --cc=dev@dpdk.org \
    --cc=fiona.trahe@intel.com \
    --cc=lee.daly@intel.com \
    --cc=tomaszx.jozwiak@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).