All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] Add TST_EXP_FAIL_ARR_SILENT() helper macros
@ 2026-05-12 16:27 Martin Doucha
  2026-05-12 16:27 ` [LTP] [PATCH 2/2] af_alg08: Allow recv() to return EINVAL Martin Doucha
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Martin Doucha @ 2026-05-12 16:27 UTC (permalink / raw)
  To: ltp

Add silent version of TST_EXP_FAIL() macros with the possibility
to check multiple expected errno values.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 include/tst_test_macros.h | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index 2cfbdb586..b1e74278d 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -675,6 +675,36 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 			&tst_exp_err__, 1, ##__VA_ARGS__);                     \
 	} while (0)
 
+/**
+ * TST_EXP_FAIL_ARR_SILENT() - Test syscall to fail with expected errnos, silent variant.
+ *
+ * @SCALL: Tested syscall.
+ * @EXP_ERRS: Array of expected errnos.
+ * @EXP_ERRS_CNT: Lenght of EXP_ERRS.
+ * @...: A printf-like parameters.
+ *
+ * Unlike TST_EXP_FAIL_ARR() does not print :c:enum:`TPASS <tst_res_flags>` on
+ * success, only prints :c:enum:`TFAIL <tst_res_flags>` on failure.
+ */
+#define TST_EXP_FAIL_ARR_SILENT(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...)            \
+	TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL,                      \
+		EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__)
+
+/**
+ * TST_EXP_FAIL2_ARR_SILENT() - Test syscall to fail with expected errnos, silent variant.
+ *
+ * @SCALL: Tested syscall.
+ * @EXP_ERRS: Array of expected errnos.
+ * @EXP_ERRS_CNT: Lenght of EXP_ERRS.
+ * @...: A printf-like parameters.
+ *
+ * Unlike TST_EXP_FAIL2_ARR() does not print :c:enum:`TPASS <tst_res_flags>` on
+ * success, only prints :c:enum:`TFAIL <tst_res_flags>` on failure.
+ */
+#define TST_EXP_FAIL2_ARR_SILENT(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...)           \
+	TST_EXP_FAIL_SILENT_(TST_RET >= 0, SCALL, #SCALL,                     \
+		EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__)
+
 /**
  * TST_EXP_EXPR() - Check for expected expression.
  *
-- 
2.53.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [LTP] [PATCH 2/2] af_alg08: Allow recv() to return EINVAL
  2026-05-12 16:27 [LTP] [PATCH 1/2] Add TST_EXP_FAIL_ARR_SILENT() helper macros Martin Doucha
@ 2026-05-12 16:27 ` Martin Doucha
  2026-05-12 16:40   ` Cyril Hrubis
  2026-05-12 18:00   ` Petr Vorel
  2026-05-12 16:40 ` [LTP] [PATCH 1/2] Add TST_EXP_FAIL_ARR_SILENT() helper macros Cyril Hrubis
  2026-05-12 17:16 ` [LTP] " linuxtestproject.agent
  2 siblings, 2 replies; 7+ messages in thread
From: Martin Doucha @ 2026-05-12 16:27 UTC (permalink / raw)
  To: ltp

Recent kernels return EBADMSG from recv() when the crypto operation
fails. However, older kernels return EINVAL instead. Accept both
errno values.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 testcases/kernel/crypto/af_alg08.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/crypto/af_alg08.c b/testcases/kernel/crypto/af_alg08.c
index 5e04b579c..937ab1758 100644
--- a/testcases/kernel/crypto/af_alg08.c
+++ b/testcases/kernel/crypto/af_alg08.c
@@ -60,6 +60,10 @@ static int algfd = -1;
 static int reqfd = -1;
 static int pipefd[2] = { -1, -1 };
 static int file_fd = -1;
+static const int exp_errnos[] = {
+	EBADMSG,
+	EINVAL
+};
 
 static void try_corrupt(void)
 {
@@ -100,7 +104,8 @@ static void try_corrupt(void)
 	SAFE_SPLICE(pipefd[0], NULL, reqfd, NULL, OVERWRITE_SIZE, 0);
 
 	/* Expected to fail (invalid ciphertext); triggers the scratch write */
-	TST_EXP_FAIL_SILENT(recv(reqfd, recvbuf, sizeof(recvbuf), 0), EBADMSG);
+	TST_EXP_FAIL_ARR_SILENT(recv(reqfd, recvbuf, sizeof(recvbuf), 0),
+		exp_errnos, ARRAY_SIZE(exp_errnos));
 
 	SAFE_CLOSE(pipefd[0]);
 	SAFE_CLOSE(pipefd[1]);
-- 
2.53.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH 1/2] Add TST_EXP_FAIL_ARR_SILENT() helper macros
  2026-05-12 16:27 [LTP] [PATCH 1/2] Add TST_EXP_FAIL_ARR_SILENT() helper macros Martin Doucha
  2026-05-12 16:27 ` [LTP] [PATCH 2/2] af_alg08: Allow recv() to return EINVAL Martin Doucha
@ 2026-05-12 16:40 ` Cyril Hrubis
  2026-05-12 17:58   ` Petr Vorel
  2026-05-12 17:16 ` [LTP] " linuxtestproject.agent
  2 siblings, 1 reply; 7+ messages in thread
From: Cyril Hrubis @ 2026-05-12 16:40 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp

Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH 2/2] af_alg08: Allow recv() to return EINVAL
  2026-05-12 16:27 ` [LTP] [PATCH 2/2] af_alg08: Allow recv() to return EINVAL Martin Doucha
@ 2026-05-12 16:40   ` Cyril Hrubis
  2026-05-12 18:00   ` Petr Vorel
  1 sibling, 0 replies; 7+ messages in thread
From: Cyril Hrubis @ 2026-05-12 16:40 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp

Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] Add TST_EXP_FAIL_ARR_SILENT() helper macros
  2026-05-12 16:27 [LTP] [PATCH 1/2] Add TST_EXP_FAIL_ARR_SILENT() helper macros Martin Doucha
  2026-05-12 16:27 ` [LTP] [PATCH 2/2] af_alg08: Allow recv() to return EINVAL Martin Doucha
  2026-05-12 16:40 ` [LTP] [PATCH 1/2] Add TST_EXP_FAIL_ARR_SILENT() helper macros Cyril Hrubis
@ 2026-05-12 17:16 ` linuxtestproject.agent
  2 siblings, 0 replies; 7+ messages in thread
From: linuxtestproject.agent @ 2026-05-12 17:16 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp

Hi Martin,

--- [PATCH 1/2] ---

On Tue, 12 May 2026 18:27:16 +0200, Martin Doucha wrote:
> [PATCH 1/2] Add TST_EXP_FAIL_ARR_SILENT() helper macros

> + * @EXP_ERRS_CNT: Lenght of EXP_ERRS.

Typo: s/Lenght/Length/. Appears twice, in both new macro doc blocks.

---
Note:

Our agent completed the review of the patch. The full review can be
found at: https://patchwork.ozlabs.org/project/ltp/list/?series=503985

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH 1/2] Add TST_EXP_FAIL_ARR_SILENT() helper macros
  2026-05-12 16:40 ` [LTP] [PATCH 1/2] Add TST_EXP_FAIL_ARR_SILENT() helper macros Cyril Hrubis
@ 2026-05-12 17:58   ` Petr Vorel
  0 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2026-05-12 17:58 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi all,

> Hi!
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

I dared to mention 2 variant in the commit message and merge whole patchset.
Thanks!

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH 2/2] af_alg08: Allow recv() to return EINVAL
  2026-05-12 16:27 ` [LTP] [PATCH 2/2] af_alg08: Allow recv() to return EINVAL Martin Doucha
  2026-05-12 16:40   ` Cyril Hrubis
@ 2026-05-12 18:00   ` Petr Vorel
  1 sibling, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2026-05-12 18:00 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp

> Recent kernels return EBADMSG from recv() when the crypto operation
> fails. However, older kernels return EINVAL instead. Accept both
> errno values.

...
> +++ b/testcases/kernel/crypto/af_alg08.c
> @@ -60,6 +60,10 @@ static int algfd = -1;
>  static int reqfd = -1;
>  static int pipefd[2] = { -1, -1 };
>  static int file_fd = -1;
> +static const int exp_errnos[] = {
> +	EBADMSG,
> +	EINVAL

I'm also ok with not detecting kernel version because this is not a subject of
testing. I guess that's the rule for question "when to bother with kernel
version check for specific errno". Maybe we should mention it in the test macro
doc.

Anyway, merged.

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-05-12 18:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-12 16:27 [LTP] [PATCH 1/2] Add TST_EXP_FAIL_ARR_SILENT() helper macros Martin Doucha
2026-05-12 16:27 ` [LTP] [PATCH 2/2] af_alg08: Allow recv() to return EINVAL Martin Doucha
2026-05-12 16:40   ` Cyril Hrubis
2026-05-12 18:00   ` Petr Vorel
2026-05-12 16:40 ` [LTP] [PATCH 1/2] Add TST_EXP_FAIL_ARR_SILENT() helper macros Cyril Hrubis
2026-05-12 17:58   ` Petr Vorel
2026-05-12 17:16 ` [LTP] " linuxtestproject.agent

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.