diff mbox series

crypto: testmgr - extend acomp tests for NULL destination buffer

Message ID 20220812141602.5571-1-lucas.segarra.fernandez@intel.com
State Accepted
Commit 5a4c2936669736f2e915fe6135a668e9e079de34
Headers show
Series crypto: testmgr - extend acomp tests for NULL destination buffer | expand

Commit Message

Lucas Segarra Fernandez Aug. 12, 2022, 2:16 p.m. UTC
Acomp API supports NULL destination buffer for compression
and decompression requests. In such cases allocation is
performed by API.

Add test cases for crypto_acomp_compress() and crypto_acomp_decompress()
with dst buffer allocated by API.

Tests will only run if CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y.

Signed-off-by: Lucas Segarra Fernandez <lucas.segarra.fernandez@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
---
 crypto/testmgr.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

Comments

Herbert Xu Aug. 19, 2022, 11:03 a.m. UTC | #1
On Fri, Aug 12, 2022 at 04:16:02PM +0200, Lucas Segarra Fernandez wrote:
> Acomp API supports NULL destination buffer for compression
> and decompression requests. In such cases allocation is
> performed by API.
> 
> Add test cases for crypto_acomp_compress() and crypto_acomp_decompress()
> with dst buffer allocated by API.
> 
> Tests will only run if CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y.
> 
> Signed-off-by: Lucas Segarra Fernandez <lucas.segarra.fernandez@intel.com>
> Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
> ---
>  crypto/testmgr.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)

Patch applied.  Thanks.
diff mbox series

Patch

diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 5349ffee6bbd..bf905c1e89ed 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -3417,6 +3417,21 @@  static int test_acomp(struct crypto_acomp *tfm,
 			goto out;
 		}
 
+#ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS
+		crypto_init_wait(&wait);
+		sg_init_one(&src, input_vec, ilen);
+		acomp_request_set_params(req, &src, NULL, ilen, 0);
+
+		ret = crypto_wait_req(crypto_acomp_compress(req), &wait);
+		if (ret) {
+			pr_err("alg: acomp: compression failed on NULL dst buffer test %d for %s: ret=%d\n",
+			       i + 1, algo, -ret);
+			kfree(input_vec);
+			acomp_request_free(req);
+			goto out;
+		}
+#endif
+
 		kfree(input_vec);
 		acomp_request_free(req);
 	}
@@ -3478,6 +3493,20 @@  static int test_acomp(struct crypto_acomp *tfm,
 			goto out;
 		}
 
+#ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS
+		crypto_init_wait(&wait);
+		acomp_request_set_params(req, &src, NULL, ilen, 0);
+
+		ret = crypto_wait_req(crypto_acomp_decompress(req), &wait);
+		if (ret) {
+			pr_err("alg: acomp: decompression failed on NULL dst buffer test %d for %s: ret=%d\n",
+			       i + 1, algo, -ret);
+			kfree(input_vec);
+			acomp_request_free(req);
+			goto out;
+		}
+#endif
+
 		kfree(input_vec);
 		acomp_request_free(req);
 	}