public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v1] Add TST_EXP_FAIL_PTR
@ 2024-01-11  1:26 Wei Gao via ltp
  2024-01-16 17:49 ` Petr Vorel
  2024-01-17  8:04 ` [LTP] [PATCH v2] " Wei Gao via ltp
  0 siblings, 2 replies; 40+ messages in thread
From: Wei Gao via ltp @ 2024-01-11  1:26 UTC (permalink / raw)
  To: ltp

Signed-off-by: Wei Gao <wegao@suse.com>
---
 include/tst_test_macros.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

This is draft patch and should rebase after following patch merge.
https://patchwork.ozlabs.org/project/ltp/patch/20240103115700.14585-1-chrubis@suse.cz/

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index 3f4f9f11d..6e45e0b27 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -212,6 +212,26 @@ extern void *TST_RET_PTR;
 		}                                                              \
 	} while (0)
 
+#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, ERRNO, ...)             \
+	do {                                                                   \
+		TESTPTR(SCALL);                                                   \
+		                                                               \
+		TST_PASS = 0;                                                  \
+		                                                               \
+		if (TST_RET_PTR) {                                               \
+			TST_MSG_(TFAIL, " succeeded", SSCALL, ##__VA_ARGS__);  \
+		        break;                                                 \
+		}                                                              \
+		                                                               \
+		if (TST_ERR == (ERRNO)) {                                      \
+			TST_PASS = 1;                                          \
+		} else {                                                       \
+			TST_MSGP_(TFAIL | TTERRNO, " expected %s",             \
+				  tst_strerrno(ERRNO),                         \
+				  SSCALL, ##__VA_ARGS__);                      \
+		}                                                              \
+	} while (0)
+
 #define TST_EXP_FAIL(SCALL, ERRNO, ...)                                        \
 	do {                                                                   \
 		TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL,              \
@@ -228,6 +248,14 @@ extern void *TST_RET_PTR;
 			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
 	} while (0)
 
+#define TST_EXP_FAIL_PTR(SCALL, ERRNO, ...)                                        \
+	do {                                                                   \
+		TST_EXP_FAIL_SILENT_PTR_(SCALL, #SCALL,              \
+			ERRNO, ##__VA_ARGS__);                                 \
+		if (TST_PASS)                                                  \
+			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
+	} while (0)
+
 #define TST_EXP_FAIL_SILENT(SCALL, ERRNO, ...) \
 	TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
 
-- 
2.35.3


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

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

* Re: [LTP] [PATCH v1] Add TST_EXP_FAIL_PTR
  2024-01-11  1:26 [LTP] [PATCH v1] Add TST_EXP_FAIL_PTR Wei Gao via ltp
@ 2024-01-16 17:49 ` Petr Vorel
  2024-01-17  8:07   ` Wei Gao via ltp
  2024-01-17  8:04 ` [LTP] [PATCH v2] " Wei Gao via ltp
  1 sibling, 1 reply; 40+ messages in thread
From: Petr Vorel @ 2024-01-16 17:49 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi Wei,

> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
>  include/tst_test_macros.h | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)

> This is draft patch and should rebase after following patch merge.
> https://patchwork.ozlabs.org/project/ltp/patch/20240103115700.14585-1-chrubis@suse.cz/

Patch was accepted, please rebase. Also, please add at least one test which
uses it.

Also, I wonder if we need TST_EXP_PASS_PTR().

> diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
> index 3f4f9f11d..6e45e0b27 100644
> --- a/include/tst_test_macros.h
> +++ b/include/tst_test_macros.h
> @@ -212,6 +212,26 @@ extern void *TST_RET_PTR;
>  		}                                                              \
>  	} while (0)

> +#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, ERRNO, ...)             \
> +	do {                                                                   \
> +		TESTPTR(SCALL);                                                   \
> +		                                                               \
> +		TST_PASS = 0;                                                  \
> +		                                                               \
> +		if (TST_RET_PTR) {                                               \
> +			TST_MSG_(TFAIL, " succeeded", SSCALL, ##__VA_ARGS__);  \
> +		        break;                                                 \
> +		}                                                              \
> +		                                                               \
> +		if (TST_ERR == (ERRNO)) {                                      \
> +			TST_PASS = 1;                                          \
> +		} else {                                                       \
> +			TST_MSGP_(TFAIL | TTERRNO, " expected %s",             \
> +				  tst_strerrno(ERRNO),                         \
> +				  SSCALL, ##__VA_ARGS__);                      \
> +		}                                                              \

Maybe follow the pattern of already used tests (break saves else clause)?
 		if (TST_ERR != (ERRNO)) {                                      \
			TST_MSGP_(TFAIL | TTERRNO, " expected %s",             \
				  tst_strerrno(ERRNO),                         \
				  SSCALL, ##__VA_ARGS__);                      \
			break;                                                 \
		}                                                              \
                                                                               \
		TST_PASS = 1;                                                  \


> +	} while (0)
> +

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

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

* [LTP] [PATCH v2] Add TST_EXP_FAIL_PTR
  2024-01-11  1:26 [LTP] [PATCH v1] Add TST_EXP_FAIL_PTR Wei Gao via ltp
  2024-01-16 17:49 ` Petr Vorel
@ 2024-01-17  8:04 ` Wei Gao via ltp
  2024-01-17  9:49   ` Petr Vorel
  2024-01-17 12:52   ` [LTP] [PATCH v3 0/2] lib: TST_EXP_FAIL_PTR Wei Gao via ltp
  1 sibling, 2 replies; 40+ messages in thread
From: Wei Gao via ltp @ 2024-01-17  8:04 UTC (permalink / raw)
  To: ltp

Signed-off-by: Wei Gao <wegao@suse.com>
---
 include/tst_test_macros.h        | 41 +++++++++++++++++++++++++++++
 lib/newlib_tests/.gitignore      |  1 +
 lib/newlib_tests/test_macros07.c | 44 ++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+)
 create mode 100644 lib/newlib_tests/test_macros07.c

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index 24fd324bf..409e6847c 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -227,6 +227,30 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 		}                                                              \
 	} while (0)
 
+#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, ERRNOS, ERRNOS_CNT, ...)       \
+	do {                                                                   \
+		TESTPTR(SCALL);                                                \
+		                                                               \
+		TST_PASS = 0;                                                  \
+		                                                               \
+		if (TST_RET_PTR) {                                             \
+			TST_MSG_(TFAIL, " succeeded", SSCALL, ##__VA_ARGS__);  \
+		        break;                                                 \
+		}                                                              \
+		                                                               \
+		if (!tst_errno_in_set(TST_ERR, ERRNOS, ERRNOS_CNT)) {          \
+			char tst_str_buf__[ERRNOS_CNT * 20];                   \
+			TST_MSGP_(TFAIL | TTERRNO, " expected %s",             \
+				  tst_errno_names(tst_str_buf__,               \
+						  ERRNOS, ERRNOS_CNT),         \
+				  SSCALL, ##__VA_ARGS__);                      \
+			break;                                                 \
+		}                                                              \
+                                                                               \
+		TST_PASS = 1;                                                  \
+                                                                               \
+	} while (0)
+
 #define TST_EXP_FAIL_ARR_(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...)                  \
 	do {                                                                   \
 		TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL,              \
@@ -258,6 +282,23 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 		TST_EXP_FAIL2_ARR_(SCALL, EXP_ERRS, ARRAY_SIZE(EXP_ERRS),      \
                                   ##__VA_ARGS__);                              \
 
+#define TST_EXP_FAIL_PTR(SCALL, EXP_ERR, ...)                                  \
+	do {                                                                   \
+		int tst_exp_err__ = EXP_ERR;                                   \
+		TST_EXP_FAIL_SILENT_PTR_(SCALL, #SCALL,                        \
+			&tst_exp_err__, 1, ##__VA_ARGS__);                     \
+		if (TST_PASS)                                                  \
+			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
+	} while (0)
+
+#define TST_EXP_FAIL_PTR_ARR(SCALL, EXP_ERRS, ...)                             \
+	do {                                                                   \
+		TST_EXP_FAIL_SILENT_PTR_(SCALL, #SCALL,                        \
+			EXP_ERRS, ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);        \
+		if (TST_PASS)                                                  \
+			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
+	} while (0)
+
 #define TST_EXP_FAIL2(SCALL, EXP_ERR, ...)                                     \
 	do {                                                                   \
 		int tst_exp_err__ = EXP_ERR;                                   \
diff --git a/lib/newlib_tests/.gitignore b/lib/newlib_tests/.gitignore
index a69b29e24..4f43899e5 100644
--- a/lib/newlib_tests/.gitignore
+++ b/lib/newlib_tests/.gitignore
@@ -40,6 +40,7 @@ test_macros03
 test_macros04
 test_macros05
 test_macros06
+test_macros07
 tst_fuzzy_sync01
 tst_fuzzy_sync02
 tst_fuzzy_sync03
diff --git a/lib/newlib_tests/test_macros07.c b/lib/newlib_tests/test_macros07.c
new file mode 100644
index 000000000..45bba8409
--- /dev/null
+++ b/lib/newlib_tests/test_macros07.c
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2024 Wei Gao <wegao@suse.com>
+ */
+
+/*
+ * Test TST_EXP_FAIL_PTR and TST_EXP_FAIL_PTR_ARR macro.
+ */
+
+#include "tst_test.h"
+
+static char *fail_fn(void)
+{
+	errno = EINVAL;
+	return NULL;
+}
+
+static char *pass_fn(void)
+{
+	return "pass";
+}
+
+static void do_test(void)
+{
+	const int exp_errs_pass[] = {ENOTTY, EINVAL};
+	const int exp_errs_fail[] = {ENOTTY, EISDIR};
+
+	tst_res(TINFO, "Testing TST_EXP_FAIL_PTR macro");
+	TST_EXP_FAIL_PTR(fail_fn(), EINVAL, "fail_fn()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR(fail_fn(), ENOTTY, "fail_fn()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR(pass_fn(), ENOTTY, "pass_fn()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_ARR(fail_fn(), exp_errs_pass, "fail_fn()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_ARR(fail_fn(), exp_errs_fail, "fail_fn()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+
+}
+
+static struct tst_test test = {
+	.test_all = do_test,
+};
-- 
2.35.3


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

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

* Re: [LTP] [PATCH v1] Add TST_EXP_FAIL_PTR
  2024-01-16 17:49 ` Petr Vorel
@ 2024-01-17  8:07   ` Wei Gao via ltp
  0 siblings, 0 replies; 40+ messages in thread
From: Wei Gao via ltp @ 2024-01-17  8:07 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

On Tue, Jan 16, 2024 at 06:49:26PM +0100, Petr Vorel wrote:
> Hi Wei,
> 
> > Signed-off-by: Wei Gao <wegao@suse.com>
> > ---
> >  include/tst_test_macros.h | 28 ++++++++++++++++++++++++++++
> >  1 file changed, 28 insertions(+)
> 
> > This is draft patch and should rebase after following patch merge.
> > https://patchwork.ozlabs.org/project/ltp/patch/20240103115700.14585-1-chrubis@suse.cz/
> 
> Patch was accepted, please rebase. Also, please add at least one test which
> uses it.
> 
> Also, I wonder if we need TST_EXP_PASS_PTR().
Sure, i can create another patch for TST_EXP_PASS_PTR.
> 
> > diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
> > index 3f4f9f11d..6e45e0b27 100644
> > --- a/include/tst_test_macros.h
> > +++ b/include/tst_test_macros.h
> > @@ -212,6 +212,26 @@ extern void *TST_RET_PTR;
> >  		}                                                              \
> >  	} while (0)
> 
> > +#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, ERRNO, ...)             \
> > +	do {                                                                   \
> > +		TESTPTR(SCALL);                                                   \
> > +		                                                               \
> > +		TST_PASS = 0;                                                  \
> > +		                                                               \
> > +		if (TST_RET_PTR) {                                               \
> > +			TST_MSG_(TFAIL, " succeeded", SSCALL, ##__VA_ARGS__);  \
> > +		        break;                                                 \
> > +		}                                                              \
> > +		                                                               \
> > +		if (TST_ERR == (ERRNO)) {                                      \
> > +			TST_PASS = 1;                                          \
> > +		} else {                                                       \
> > +			TST_MSGP_(TFAIL | TTERRNO, " expected %s",             \
> > +				  tst_strerrno(ERRNO),                         \
> > +				  SSCALL, ##__VA_ARGS__);                      \
> > +		}                                                              \
> 
> Maybe follow the pattern of already used tests (break saves else clause)?
>  		if (TST_ERR != (ERRNO)) {                                      \
> 			TST_MSGP_(TFAIL | TTERRNO, " expected %s",             \
> 				  tst_strerrno(ERRNO),                         \
> 				  SSCALL, ##__VA_ARGS__);                      \
> 			break;                                                 \
> 		}                                                              \
>                                                                                \
> 		TST_PASS = 1;                                                  \
> 
> 
> > +	} while (0)
> > +

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

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

* Re: [LTP] [PATCH v2] Add TST_EXP_FAIL_PTR
  2024-01-17  8:04 ` [LTP] [PATCH v2] " Wei Gao via ltp
@ 2024-01-17  9:49   ` Petr Vorel
  2024-01-30 12:21     ` Petr Vorel
  2024-01-17 12:52   ` [LTP] [PATCH v3 0/2] lib: TST_EXP_FAIL_PTR Wei Gao via ltp
  1 sibling, 1 reply; 40+ messages in thread
From: Petr Vorel @ 2024-01-17  9:49 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi Wei,

subject should be: "lib: TST_EXP_{FAIL,PASS}_PTR"
(can be changed before merge)

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Thanks for adding a library test.

If you send a patch for a test which actually uses these, we can merge it before
the release. Otherwise I would wait for the merge after the release.

Kind regards,
Petr

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

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

* [LTP] [PATCH v3 0/2] lib: TST_EXP_FAIL_PTR
  2024-01-17  8:04 ` [LTP] [PATCH v2] " Wei Gao via ltp
  2024-01-17  9:49   ` Petr Vorel
@ 2024-01-17 12:52   ` Wei Gao via ltp
  2024-01-17 12:52     ` [LTP] [PATCH v3 1/2] " Wei Gao via ltp
                       ` (2 more replies)
  1 sibling, 3 replies; 40+ messages in thread
From: Wei Gao via ltp @ 2024-01-17 12:52 UTC (permalink / raw)
  To: ltp

Wei Gao (2):
  lib: TST_EXP_FAIL_PTR
  getcwd01: Implement .test_variants

 include/tst_test_macros.h                   | 41 +++++++++++
 lib/newlib_tests/.gitignore                 |  1 +
 lib/newlib_tests/test_macros07.c            | 44 ++++++++++++
 testcases/kernel/syscalls/getcwd/getcwd01.c | 80 +++++++++++++++------
 4 files changed, 146 insertions(+), 20 deletions(-)
 create mode 100644 lib/newlib_tests/test_macros07.c

-- 
2.35.3


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

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

* [LTP] [PATCH v3 1/2] lib: TST_EXP_FAIL_PTR
  2024-01-17 12:52   ` [LTP] [PATCH v3 0/2] lib: TST_EXP_FAIL_PTR Wei Gao via ltp
@ 2024-01-17 12:52     ` Wei Gao via ltp
  2024-01-23  8:45       ` Petr Vorel
  2024-01-23 10:41       ` Cyril Hrubis
  2024-01-17 12:52     ` [LTP] [PATCH v3 2/2] getcwd01: Implement .test_variants Wei Gao via ltp
  2024-02-08  1:32     ` [LTP] [PATCH v4 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
  2 siblings, 2 replies; 40+ messages in thread
From: Wei Gao via ltp @ 2024-01-17 12:52 UTC (permalink / raw)
  To: ltp

Signed-off-by: Wei Gao <wegao@suse.com>
---
 include/tst_test_macros.h        | 41 +++++++++++++++++++++++++++++
 lib/newlib_tests/.gitignore      |  1 +
 lib/newlib_tests/test_macros07.c | 44 ++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+)
 create mode 100644 lib/newlib_tests/test_macros07.c

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index d2e50a219..5866d18b0 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -227,6 +227,30 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 		}                                                              \
 	} while (0)
 
+#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, ERRNOS, ERRNOS_CNT, ...)       \
+	do {                                                                   \
+		TESTPTR(SCALL);                                                \
+		                                                               \
+		TST_PASS = 0;                                                  \
+		                                                               \
+		if (TST_RET_PTR) {                                             \
+			TST_MSG_(TFAIL, " succeeded", SSCALL, ##__VA_ARGS__);  \
+		        break;                                                 \
+		}                                                              \
+		                                                               \
+		if (!tst_errno_in_set(TST_ERR, ERRNOS, ERRNOS_CNT)) {          \
+			char tst_str_buf__[ERRNOS_CNT * 20];                   \
+			TST_MSGP_(TFAIL | TTERRNO, " expected %s",             \
+				  tst_errno_names(tst_str_buf__,               \
+						  ERRNOS, ERRNOS_CNT),         \
+				  SSCALL, ##__VA_ARGS__);                      \
+			break;                                                 \
+		}                                                              \
+                                                                               \
+		TST_PASS = 1;                                                  \
+                                                                               \
+	} while (0)
+
 #define TST_EXP_FAIL_ARR_(SCALL, SSCALL, EXP_ERRS, EXP_ERRS_CNT, ...)          \
 	do {                                                                   \
 		TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, SSCALL,              \
@@ -258,6 +282,23 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 		TST_EXP_FAIL2_ARR_(SCALL, #SCALL, EXP_ERRS,                    \
 		                  ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);
 
+#define TST_EXP_FAIL_PTR(SCALL, EXP_ERR, ...)                                  \
+	do {                                                                   \
+		int tst_exp_err__ = EXP_ERR;                                   \
+		TST_EXP_FAIL_SILENT_PTR_(SCALL, #SCALL,                        \
+			&tst_exp_err__, 1, ##__VA_ARGS__);                     \
+		if (TST_PASS)                                                  \
+			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
+	} while (0)
+
+#define TST_EXP_FAIL_PTR_ARR(SCALL, EXP_ERRS, ...)                             \
+	do {                                                                   \
+		TST_EXP_FAIL_SILENT_PTR_(SCALL, #SCALL,                        \
+			EXP_ERRS, ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);        \
+		if (TST_PASS)                                                  \
+			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
+	} while (0)
+
 #define TST_EXP_FAIL2(SCALL, EXP_ERR, ...)                                     \
 	do {                                                                   \
 		int tst_exp_err__ = EXP_ERR;                                   \
diff --git a/lib/newlib_tests/.gitignore b/lib/newlib_tests/.gitignore
index a69b29e24..4f43899e5 100644
--- a/lib/newlib_tests/.gitignore
+++ b/lib/newlib_tests/.gitignore
@@ -40,6 +40,7 @@ test_macros03
 test_macros04
 test_macros05
 test_macros06
+test_macros07
 tst_fuzzy_sync01
 tst_fuzzy_sync02
 tst_fuzzy_sync03
diff --git a/lib/newlib_tests/test_macros07.c b/lib/newlib_tests/test_macros07.c
new file mode 100644
index 000000000..45bba8409
--- /dev/null
+++ b/lib/newlib_tests/test_macros07.c
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2024 Wei Gao <wegao@suse.com>
+ */
+
+/*
+ * Test TST_EXP_FAIL_PTR and TST_EXP_FAIL_PTR_ARR macro.
+ */
+
+#include "tst_test.h"
+
+static char *fail_fn(void)
+{
+	errno = EINVAL;
+	return NULL;
+}
+
+static char *pass_fn(void)
+{
+	return "pass";
+}
+
+static void do_test(void)
+{
+	const int exp_errs_pass[] = {ENOTTY, EINVAL};
+	const int exp_errs_fail[] = {ENOTTY, EISDIR};
+
+	tst_res(TINFO, "Testing TST_EXP_FAIL_PTR macro");
+	TST_EXP_FAIL_PTR(fail_fn(), EINVAL, "fail_fn()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR(fail_fn(), ENOTTY, "fail_fn()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR(pass_fn(), ENOTTY, "pass_fn()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_ARR(fail_fn(), exp_errs_pass, "fail_fn()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_ARR(fail_fn(), exp_errs_fail, "fail_fn()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+
+}
+
+static struct tst_test test = {
+	.test_all = do_test,
+};
-- 
2.35.3


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

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

* [LTP] [PATCH v3 2/2] getcwd01: Implement .test_variants
  2024-01-17 12:52   ` [LTP] [PATCH v3 0/2] lib: TST_EXP_FAIL_PTR Wei Gao via ltp
  2024-01-17 12:52     ` [LTP] [PATCH v3 1/2] " Wei Gao via ltp
@ 2024-01-17 12:52     ` Wei Gao via ltp
  2024-01-23  9:45       ` Petr Vorel
  2024-02-08  1:32     ` [LTP] [PATCH v4 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
  2 siblings, 1 reply; 40+ messages in thread
From: Wei Gao via ltp @ 2024-01-17 12:52 UTC (permalink / raw)
  To: ltp

Signed-off-by: Wei Gao <wegao@suse.com>
---
 testcases/kernel/syscalls/getcwd/getcwd01.c | 80 +++++++++++++++------
 1 file changed, 60 insertions(+), 20 deletions(-)

NOTE: Cyril give solution for run the test in a child and pass
the test both on EFAULT and child being killed by SIGSEGV. But
currently i have no idea how to do it since no SIGSEGV will hapeen
if NULL buffer give to getcwd. This file just used for give a real
user case for TST_EXP_FAIL_PTR.


diff --git a/testcases/kernel/syscalls/getcwd/getcwd01.c b/testcases/kernel/syscalls/getcwd/getcwd01.c
index 218bf4ef2..879c36206 100644
--- a/testcases/kernel/syscalls/getcwd/getcwd01.c
+++ b/testcases/kernel/syscalls/getcwd/getcwd01.c
@@ -3,21 +3,34 @@
  * Copyright (c) International Business Machines Corp., 2001
  */
 
-/*
- * DESCRIPTION
+/*\
+ * [Description]
+ *
  * Testcase to test that getcwd(2) sets errno correctly.
- * 1) getcwd(2) fails if buf points to a bad address.
- * 2) getcwd(2) fails if the size is invalid.
- * 3) getcwd(2) fails if the size is set to 0.
- * 4) getcwd(2) fails if the size is set to 1.
- * 5) getcwd(2) fails if buf points to NULL and the size is set to 1.
+ *
+ * 1. getcwd(2) fails if buf points to a bad address.
+ * 2. getcwd(2) fails if the size is invalid.
+ * 3. getcwd(2) fails if the size is set to 0.
+ * 4. getcwd(2) fails if the size is set to 1.
+ * 5. getcwd(2) fails if buf points to NULL and the size is set to 1.
  *
  * Expected Result:
- * 1) getcwd(2) should return NULL and set errno to EFAULT.
- * 2) getcwd(2) should return NULL and set errno to EFAULT.
- * 3) getcwd(2) should return NULL and set errno to ERANGE.
- * 4) getcwd(2) should return NULL and set errno to ERANGE.
- * 5) getcwd(2) should return NULL and set errno to ERANGE.
+ *
+ * linux syscall
+ *
+ * 1. getcwd(2) should return NULL and set errno to EFAULT.
+ * 2. getcwd(2) should return NULL and set errno to EFAULT.
+ * 3. getcwd(2) should return NULL and set errno to ERANGE.
+ * 4. getcwd(2) should return NULL and set errno to ERANGE.
+ * 5. getcwd(2) should return NULL and set errno to ERANGE.
+ *
+ * glibc and uclibc{,-ng}.
+ *
+ * 1. getcwd(2) should return NULL and set errno to EFAULT.
+ * 2. getcwd(2) should return NULL and set errno to ENOMEM.
+ * 3. getcwd(2) should return NULL and set errno to EINVAL.
+ * 4. getcwd(2) should return NULL and set errno to ERANGE.
+ * 5. getcwd(2) should return NULL and set errno to ERANGE.
  */
 
 #include <errno.h>
@@ -32,23 +45,50 @@ static struct t_case {
 	char *buf;
 	size_t size;
 	int exp_err;
+	int exp_err_libc;
 } tcases[] = {
-	{(void *)-1, PATH_MAX, EFAULT},
-	{NULL, (size_t)-1, EFAULT},
-	{buffer, 0, ERANGE},
-	{buffer, 1, ERANGE},
-	{NULL, 1, ERANGE}
+	{(void *)-1, PATH_MAX, EFAULT, EFAULT},
+	{NULL, (size_t)-1, EFAULT, ENOMEM},
+	{buffer, 0, ERANGE, EINVAL},
+	{buffer, 1, ERANGE, ERANGE},
+	{NULL, 1, ERANGE, ERANGE},
 };
 
+static inline void tst_getcwd(char *buf, size_t size, int exp_err, int exp_err_libc)
+{
+
+	if (tst_variant == 0)
+		TST_EXP_FAIL2(tst_syscall(__NR_getcwd, buf, size), exp_err);
+	else
+		TST_EXP_FAIL_PTR(getcwd(buf, size), exp_err_libc);
+}
 
-static void verify_getcwd(unsigned int n)
+static void run(unsigned int n)
 {
 	struct t_case *tc = &tcases[n];
 
-	TST_EXP_FAIL2(tst_syscall(__NR_getcwd, tc->buf, tc->size), tc->exp_err);
+	/* https://github.com/linux-test-project/ltp/issues/1084 */
+#if !defined(__GLIBC__) && !defined(__ANDROID__)
+	if (tst_variant && !tc->buf) {
+		tst_res(TCONF, "NULL buffer test skipped on MUSL due different implementation");
+		return;
+	}
+#endif
+
+	tst_getcwd(tc->buf, tc->size, tc->exp_err, tc->exp_err_libc);
+}
+
+static void setup(void)
+{
+	if (tst_variant == 0)
+		tst_res(TINFO, "Testing getcwd with raw syscall");
+	else
+		tst_res(TINFO, "Testing getcwd with wrap syscall");
 }
 
 static struct tst_test test = {
+	.setup = setup,
 	.tcnt = ARRAY_SIZE(tcases),
-	.test = verify_getcwd
+	.test = run,
+	.test_variants = 2,
 };
-- 
2.35.3


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

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

* Re: [LTP] [PATCH v3 1/2] lib: TST_EXP_FAIL_PTR
  2024-01-17 12:52     ` [LTP] [PATCH v3 1/2] " Wei Gao via ltp
@ 2024-01-23  8:45       ` Petr Vorel
  2024-01-23 10:41       ` Cyril Hrubis
  1 sibling, 0 replies; 40+ messages in thread
From: Petr Vorel @ 2024-01-23  8:45 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi Wei,

thank you for sending rebased version.

You could have added my RBT (the code you added didn't change).
Reviewed-by: Petr Vorel <pvorel@suse.cz>

nit (I have suggested in v2): subject should be: "lib: TST_EXP_{FAIL,PASS}_PTR"

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v3 2/2] getcwd01: Implement .test_variants
  2024-01-17 12:52     ` [LTP] [PATCH v3 2/2] getcwd01: Implement .test_variants Wei Gao via ltp
@ 2024-01-23  9:45       ` Petr Vorel
  0 siblings, 0 replies; 40+ messages in thread
From: Petr Vorel @ 2024-01-23  9:45 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi Wei,

> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
>  testcases/kernel/syscalls/getcwd/getcwd01.c | 80 +++++++++++++++------
>  1 file changed, 60 insertions(+), 20 deletions(-)

> NOTE: Cyril give solution for run the test in a child and pass
> the test both on EFAULT and child being killed by SIGSEGV. But
> currently i have no idea how to do it since no SIGSEGV will hapeen
> if NULL buffer give to getcwd. This file just used for give a real
> user case for TST_EXP_FAIL_PTR.

@Cyril, could you please point out test which uses similar approach?
Maybe these?
testcases/kernel/syscalls/fstat/fstat03.c
testcases/kernel/syscalls/ipc/shmat/shmat01.c
testcases/kernel/syscalls/kill/kill11.c
testcases/kernel/syscalls/setrlimit/setrlimit05.c

Or can the current approach be used?

Below only nits (formatting).

> diff --git a/testcases/kernel/syscalls/getcwd/getcwd01.c b/testcases/kernel/syscalls/getcwd/getcwd01.c
> index 218bf4ef2..879c36206 100644
> --- a/testcases/kernel/syscalls/getcwd/getcwd01.c
> +++ b/testcases/kernel/syscalls/getcwd/getcwd01.c
> @@ -3,21 +3,34 @@
>   * Copyright (c) International Business Machines Corp., 2001

IBM in 2001 could be proud on this code :). There should have been some
copyright, I would add:
 * Copyright (c) Linux Test Project, 2002-2024

>   */

> -/*
> - * DESCRIPTION
> +/*\
> + * [Description]
> + *
>   * Testcase to test that getcwd(2) sets errno correctly.
> + *
> + * 1. getcwd(2) fails if buf points to a bad address.
> + * 2. getcwd(2) fails if the size is invalid.
> + * 3. getcwd(2) fails if the size is set to 0.
> + * 4. getcwd(2) fails if the size is set to 1.
> + * 5. getcwd(2) fails if buf points to NULL and the size is set to 1.
>   *
>   * Expected Result:
> + *
> + * linux syscall
> + *
> + * 1. getcwd(2) should return NULL and set errno to EFAULT.
I don't like repeating "getcwd(2) should return NULL and set errno to"

> + * 2. getcwd(2) should return NULL and set errno to EFAULT.
> + * 3. getcwd(2) should return NULL and set errno to ERANGE.
> + * 4. getcwd(2) should return NULL and set errno to ERANGE.
> + * 5. getcwd(2) should return NULL and set errno to ERANGE.
> + *
> + * glibc and uclibc{,-ng}.
Although in the past LTP developers cared only about glibc, now we generally
don't stick to any libc implementation. Thus it should be "libc syscall wrapper"

> + *
> + * 1. getcwd(2) should return NULL and set errno to EFAULT.
> + * 2. getcwd(2) should return NULL and set errno to ENOMEM.
> + * 3. getcwd(2) should return NULL and set errno to EINVAL.
> + * 4. getcwd(2) should return NULL and set errno to ERANGE.
> + * 5. getcwd(2) should return NULL and set errno to ERANGE.
>   */

How about to make it simple like this:
/*\
 * [Description]
 *
 * Testcase to test that getcwd(2) returns NULL and sets errno correctly.
 *
 * 1. getcwd(2) fails if buf points to a bad address (EFAULT).
 * 2. getcwd(2) fails if the size is invalid (syscall: EFAULT, libc wrapper: ENOMEM).
 * 3. getcwd(2) fails if the size is set to 0 (syscall: ERANGE, libc wrapper: EINVAL).
 * 4. getcwd(2) fails if the size is set to 1 (ERANGE).
 * 5. getcwd(2) fails if buf points to NULL and the size is set to 1 (ERANGE).
 */

>  #include <errno.h>
> @@ -32,23 +45,50 @@ static struct t_case {
>  	char *buf;
>  	size_t size;
>  	int exp_err;
> +	int exp_err_libc;
>  } tcases[] = {
> -	{(void *)-1, PATH_MAX, EFAULT},
> -	{NULL, (size_t)-1, EFAULT},
> -	{buffer, 0, ERANGE},
> -	{buffer, 1, ERANGE},
> -	{NULL, 1, ERANGE}
> +	{(void *)-1, PATH_MAX, EFAULT, EFAULT},
> +	{NULL, (size_t)-1, EFAULT, ENOMEM},
> +	{buffer, 0, ERANGE, EINVAL},
> +	{buffer, 1, ERANGE, ERANGE},
> +	{NULL, 1, ERANGE, ERANGE},
>  };

> +static inline void tst_getcwd(char *buf, size_t size, int exp_err, int exp_err_libc)
> +{
> +
> +	if (tst_variant == 0)
> +		TST_EXP_FAIL2(tst_syscall(__NR_getcwd, buf, size), exp_err);
> +	else
> +		TST_EXP_FAIL_PTR(getcwd(buf, size), exp_err_libc);
> +}
+1

> -static void verify_getcwd(unsigned int n)
> +static void run(unsigned int n)
>  {
>  	struct t_case *tc = &tcases[n];

> -	TST_EXP_FAIL2(tst_syscall(__NR_getcwd, tc->buf, tc->size), tc->exp_err);
> +	/* https://github.com/linux-test-project/ltp/issues/1084 */
IMHO this comment should go to the commit message.

> +#if !defined(__GLIBC__) && !defined(__ANDROID__)
I'll ask AOSP developers to check this.

> +	if (tst_variant && !tc->buf) {
> +		tst_res(TCONF, "NULL buffer test skipped on MUSL due different implementation");
> +		return;
> +	}
> +#endif
> +
> +	tst_getcwd(tc->buf, tc->size, tc->exp_err, tc->exp_err_libc);
> +}
> +
> +static void setup(void)
> +{
> +	if (tst_variant == 0)
> +		tst_res(TINFO, "Testing getcwd with raw syscall");
> +	else
> +		tst_res(TINFO, "Testing getcwd with wrap syscall");

"wrap syscall" => "libc syscall wrapper"

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v3 1/2] lib: TST_EXP_FAIL_PTR
  2024-01-17 12:52     ` [LTP] [PATCH v3 1/2] " Wei Gao via ltp
  2024-01-23  8:45       ` Petr Vorel
@ 2024-01-23 10:41       ` Cyril Hrubis
  2024-01-30 12:20         ` Petr Vorel
  1 sibling, 1 reply; 40+ messages in thread
From: Cyril Hrubis @ 2024-01-23 10:41 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi!
> +#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, ERRNOS, ERRNOS_CNT, ...)       \
> +	do {                                                                   \
> +		TESTPTR(SCALL);                                                \
> +		                                                               \
> +		TST_PASS = 0;                                                  \
> +		                                                               \
> +		if (TST_RET_PTR) {                                             \

Unfortunatelly there are two types of calls, one returns NULL on a
failure and the second returns (void *)-1, from the top of my head these
are mmap(), shmat() and possibly other memory related syscalls.

So I suppose that this macro needs another parameter for the actual
value that is returned on a failure:

#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, FAIL_PTR_VAL, ERRNOS, ...)
	do {
		TESTPTR(SCALL);

		...

		if (TST_RET_PTR == FAILPTR_VAL) {
		...


The hard question is if we want to pass this parameter explicitly from the
macros used by the tests, i.e. if each test would need to specify a
FAIL_PTR_VAL or if we want to pass it in the macros, but that would mean
that the number of macros will explode again and we would have to figure
out a good names. So maybe it would be easier to pass them from each
test.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v3 1/2] lib: TST_EXP_FAIL_PTR
  2024-01-23 10:41       ` Cyril Hrubis
@ 2024-01-30 12:20         ` Petr Vorel
  0 siblings, 0 replies; 40+ messages in thread
From: Petr Vorel @ 2024-01-30 12:20 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Wei, Cyril,


> Hi!
> > +#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, ERRNOS, ERRNOS_CNT, ...)       \
> > +	do {                                                                   \
> > +		TESTPTR(SCALL);                                                \
> > +		                                                               \
> > +		TST_PASS = 0;                                                  \
> > +		                                                               \
> > +		if (TST_RET_PTR) {                                             \

> Unfortunatelly there are two types of calls, one returns NULL on a
> failure and the second returns (void *)-1, from the top of my head these
> are mmap(), shmat() and possibly other memory related syscalls.

> So I suppose that this macro needs another parameter for the actual
> value that is returned on a failure:

> #define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, FAIL_PTR_VAL, ERRNOS, ...)
> 	do {
> 		TESTPTR(SCALL);

> 		...

> 		if (TST_RET_PTR == FAILPTR_VAL) {
> 		...

+1

> The hard question is if we want to pass this parameter explicitly from the
> macros used by the tests, i.e. if each test would need to specify a
> FAIL_PTR_VAL or if we want to pass it in the macros, but that would mean
> that the number of macros will explode again and we would have to figure
> out a good names. So maybe it would be easier to pass them from each
> test.

Names could be _NULL and _VOID, but I understand you want to limit number of
macros.

Wei, I guess testcases/kernel/syscalls/realpath/realpath01.c could use
TST_EXP_FAIL_PTR().

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v2] Add TST_EXP_FAIL_PTR
  2024-01-17  9:49   ` Petr Vorel
@ 2024-01-30 12:21     ` Petr Vorel
  0 siblings, 0 replies; 40+ messages in thread
From: Petr Vorel @ 2024-01-30 12:21 UTC (permalink / raw)
  To: Wei Gao, ltp

> Hi Wei,

> subject should be: "lib: TST_EXP_{FAIL,PASS}_PTR"
I'm sorry, I did not concentrate enough. It was supposed to be

"lib: Add TST_EXP_FAIL_PTR{,_ARR}"

Kind regards,
Petr

> (can be changed before merge)

> Reviewed-by: Petr Vorel <pvorel@suse.cz>

> Thanks for adding a library test.

> If you send a patch for a test which actually uses these, we can merge it before
> the release. Otherwise I would wait for the merge after the release.

> Kind regards,
> Petr

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

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

* [LTP] [PATCH v4 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-01-17 12:52   ` [LTP] [PATCH v3 0/2] lib: TST_EXP_FAIL_PTR Wei Gao via ltp
  2024-01-17 12:52     ` [LTP] [PATCH v3 1/2] " Wei Gao via ltp
  2024-01-17 12:52     ` [LTP] [PATCH v3 2/2] getcwd01: Implement .test_variants Wei Gao via ltp
@ 2024-02-08  1:32     ` Wei Gao via ltp
  2024-02-08  1:32       ` [LTP] [PATCH v4 1/3] " Wei Gao via ltp
                         ` (3 more replies)
  2 siblings, 4 replies; 40+ messages in thread
From: Wei Gao via ltp @ 2024-02-08  1:32 UTC (permalink / raw)
  To: ltp

Wei Gao (3):
  lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  shmat02.c: Use TST_EXP_FAIL_PTR_VOID
  realpath01.c: use TST_EXP_FAIL_PTR_NULL

 include/tst_test_macros.h                     | 59 ++++++++++++++++++
 lib/newlib_tests/.gitignore                   |  1 +
 lib/newlib_tests/test_macros07.c              | 61 +++++++++++++++++++
 testcases/kernel/syscalls/ipc/shmat/shmat02.c | 15 +----
 .../kernel/syscalls/realpath/realpath01.c     | 11 +---
 5 files changed, 123 insertions(+), 24 deletions(-)
 create mode 100644 lib/newlib_tests/test_macros07.c

-- 
2.35.3


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

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

* [LTP] [PATCH v4 1/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-02-08  1:32     ` [LTP] [PATCH v4 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
@ 2024-02-08  1:32       ` Wei Gao via ltp
  2024-03-20 10:47         ` Petr Vorel
  2024-03-26 10:54         ` Cyril Hrubis
  2024-02-08  1:32       ` [LTP] [PATCH v4 2/3] shmat02.c: Use TST_EXP_FAIL_PTR_VOID Wei Gao via ltp
                         ` (2 subsequent siblings)
  3 siblings, 2 replies; 40+ messages in thread
From: Wei Gao via ltp @ 2024-02-08  1:32 UTC (permalink / raw)
  To: ltp

Signed-off-by: Wei Gao <wegao@suse.com>
---
 include/tst_test_macros.h        | 59 ++++++++++++++++++++++++++++++
 lib/newlib_tests/.gitignore      |  1 +
 lib/newlib_tests/test_macros07.c | 61 ++++++++++++++++++++++++++++++++
 3 files changed, 121 insertions(+)
 create mode 100644 lib/newlib_tests/test_macros07.c

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index d2e50a219..1f5b56d27 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -227,6 +227,31 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 		}                                                              \
 	} while (0)
 
+#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, FAIL_PTR_VAL,                  \
+	ERRNOS, ERRNOS_CNT, ...)                                               \
+	do {                                                                   \
+		TESTPTR(SCALL);                                                \
+		                                                               \
+		TST_PASS = 0;                                                  \
+		                                                               \
+		if (TST_RET_PTR != FAIL_PTR_VAL) {                             \
+			TST_MSG_(TFAIL, " succeeded", SSCALL, ##__VA_ARGS__);  \
+		        break;                                                 \
+		}                                                              \
+		                                                               \
+		if (!tst_errno_in_set(TST_ERR, ERRNOS, ERRNOS_CNT)) {          \
+			char tst_str_buf__[ERRNOS_CNT * 20];                   \
+			TST_MSGP_(TFAIL | TTERRNO, " expected %s",             \
+				  tst_errno_names(tst_str_buf__,               \
+						  ERRNOS, ERRNOS_CNT),         \
+				  SSCALL, ##__VA_ARGS__);                      \
+			break;                                                 \
+		}                                                              \
+                                                                               \
+		TST_PASS = 1;                                                  \
+                                                                               \
+	} while (0)
+
 #define TST_EXP_FAIL_ARR_(SCALL, SSCALL, EXP_ERRS, EXP_ERRS_CNT, ...)          \
 	do {                                                                   \
 		TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, SSCALL,              \
@@ -258,6 +283,40 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 		TST_EXP_FAIL2_ARR_(SCALL, #SCALL, EXP_ERRS,                    \
 		                  ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);
 
+#define TST_EXP_FAIL_PTR_NULL(SCALL, EXP_ERR, ...)                             \
+	do {                                                                   \
+		int tst_exp_err__ = EXP_ERR;                                   \
+		TST_EXP_FAIL_SILENT_PTR_(SCALL, #SCALL, NULL,                  \
+			&tst_exp_err__, 1, ##__VA_ARGS__);                     \
+		if (TST_PASS)                                                  \
+			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
+	} while (0)
+
+#define TST_EXP_FAIL_PTR_ARR_NULL(SCALL, EXP_ERRS, ...)                        \
+	do {                                                                   \
+		TST_EXP_FAIL_SILENT_PTR_(SCALL, #SCALL, NULL,                  \
+			EXP_ERRS, ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);        \
+		if (TST_PASS)                                                  \
+			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
+	} while (0)
+
+#define TST_EXP_FAIL_PTR_VOID(SCALL, EXP_ERR, ...)                             \
+	do {                                                                   \
+		int tst_exp_err__ = EXP_ERR;                                   \
+		TST_EXP_FAIL_SILENT_PTR_(SCALL, #SCALL, (void *)-1,            \
+			&tst_exp_err__, 1, ##__VA_ARGS__);                     \
+		if (TST_PASS)                                                  \
+			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
+	} while (0)
+
+#define TST_EXP_FAIL_PTR_ARR_VOID(SCALL, EXP_ERRS, ...)                        \
+	do {                                                                   \
+		TST_EXP_FAIL_SILENT_PTR_(SCALL, #SCALL, (void *)-1,            \
+			EXP_ERRS, ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);        \
+		if (TST_PASS)                                                  \
+			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
+	} while (0)
+
 #define TST_EXP_FAIL2(SCALL, EXP_ERR, ...)                                     \
 	do {                                                                   \
 		int tst_exp_err__ = EXP_ERR;                                   \
diff --git a/lib/newlib_tests/.gitignore b/lib/newlib_tests/.gitignore
index a69b29e24..4f43899e5 100644
--- a/lib/newlib_tests/.gitignore
+++ b/lib/newlib_tests/.gitignore
@@ -40,6 +40,7 @@ test_macros03
 test_macros04
 test_macros05
 test_macros06
+test_macros07
 tst_fuzzy_sync01
 tst_fuzzy_sync02
 tst_fuzzy_sync03
diff --git a/lib/newlib_tests/test_macros07.c b/lib/newlib_tests/test_macros07.c
new file mode 100644
index 000000000..ac361fd8e
--- /dev/null
+++ b/lib/newlib_tests/test_macros07.c
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2024 Wei Gao <wegao@suse.com>
+ */
+
+/*
+ * Test TST_EXP_FAIL_PTR_{NULL,VOID} and TST_EXP_FAIL_PTR_ARR{NULL,VOID} macro.
+ */
+
+#include "tst_test.h"
+
+static char *fail_fn_null(void)
+{
+	errno = EINVAL;
+	return NULL;
+}
+
+static char *fail_fn_void(void)
+{
+	errno = EINVAL;
+	return (void *)-1;
+}
+
+static char *pass_fn(void)
+{
+	return "pass";
+}
+
+static void do_test(void)
+{
+	const int exp_errs_pass[] = {ENOTTY, EINVAL};
+	const int exp_errs_fail[] = {ENOTTY, EISDIR};
+
+	tst_res(TINFO, "Testing TST_EXP_FAIL_PTR_NULL macro");
+	TST_EXP_FAIL_PTR_NULL(fail_fn_null(), EINVAL, "fail_fn_null()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_NULL(fail_fn_null(), ENOTTY, "fail_fn_null()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_NULL(pass_fn(), ENOTTY, "pass_fn()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_ARR_NULL(fail_fn_null(), exp_errs_pass, "fail_fn_null()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_ARR_NULL(fail_fn_null(), exp_errs_fail, "fail_fn()_null");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+
+	tst_res(TINFO, "Testing TST_EXP_FAIL_PTR_VOID macro");
+	TST_EXP_FAIL_PTR_VOID(fail_fn_void(), EINVAL, "fail_fn_void()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_VOID(fail_fn_void(), ENOTTY, "fail_fn_void()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_VOID(pass_fn(), ENOTTY, "pass_fn()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_ARR_VOID(fail_fn_void(), exp_errs_pass, "fail_fn_void()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_ARR_VOID(fail_fn_void(), exp_errs_fail, "fail_fn()_void");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+}
+
+static struct tst_test test = {
+	.test_all = do_test,
+};
-- 
2.35.3


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

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

* [LTP] [PATCH v4 2/3] shmat02.c: Use TST_EXP_FAIL_PTR_VOID
  2024-02-08  1:32     ` [LTP] [PATCH v4 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
  2024-02-08  1:32       ` [LTP] [PATCH v4 1/3] " Wei Gao via ltp
@ 2024-02-08  1:32       ` Wei Gao via ltp
  2024-03-20 10:47         ` Petr Vorel
  2024-02-08  1:32       ` [LTP] [PATCH v4 3/3] realpath01.c: use TST_EXP_FAIL_PTR_NULL Wei Gao via ltp
  2024-03-27  3:49       ` [LTP] [PATCH v5 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
  3 siblings, 1 reply; 40+ messages in thread
From: Wei Gao via ltp @ 2024-02-08  1:32 UTC (permalink / raw)
  To: ltp

Signed-off-by: Wei Gao <wegao@suse.com>
---
 testcases/kernel/syscalls/ipc/shmat/shmat02.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/shmat/shmat02.c b/testcases/kernel/syscalls/ipc/shmat/shmat02.c
index 53cb6f542..3ad1fd08e 100644
--- a/testcases/kernel/syscalls/ipc/shmat/shmat02.c
+++ b/testcases/kernel/syscalls/ipc/shmat/shmat02.c
@@ -44,20 +44,7 @@ static struct test_case_t {
 
 static void verify_shmat(struct test_case_t *tc)
 {
-	void *addr;
-
-	addr = shmat(*tc->shmid, *tc->shmaddr, 0);
-	if (addr != (void *)-1) {
-		tst_res(TFAIL, "shmat() succeeded unexpectedly");
-		return;
-	}
-
-	if (errno == tc->exp_err) {
-		tst_res(TPASS | TERRNO, "shmat() failed as expected");
-	} else {
-		tst_res(TFAIL | TERRNO, "shmat() failed unexpectedly, expected: %s",
-			tst_strerrno(tc->exp_err));
-	}
+	TST_EXP_FAIL_PTR_VOID(shmat(*tc->shmid, *tc->shmaddr, 0), tc->exp_err);
 }
 
 static void do_shmat(unsigned int n)
-- 
2.35.3


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

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

* [LTP] [PATCH v4 3/3] realpath01.c: use TST_EXP_FAIL_PTR_NULL
  2024-02-08  1:32     ` [LTP] [PATCH v4 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
  2024-02-08  1:32       ` [LTP] [PATCH v4 1/3] " Wei Gao via ltp
  2024-02-08  1:32       ` [LTP] [PATCH v4 2/3] shmat02.c: Use TST_EXP_FAIL_PTR_VOID Wei Gao via ltp
@ 2024-02-08  1:32       ` Wei Gao via ltp
  2024-03-20 10:47         ` Petr Vorel
  2024-03-27  3:49       ` [LTP] [PATCH v5 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
  3 siblings, 1 reply; 40+ messages in thread
From: Wei Gao via ltp @ 2024-02-08  1:32 UTC (permalink / raw)
  To: ltp

Signed-off-by: Wei Gao <wegao@suse.com>
---
 testcases/kernel/syscalls/realpath/realpath01.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/testcases/kernel/syscalls/realpath/realpath01.c b/testcases/kernel/syscalls/realpath/realpath01.c
index c0381e9cb..c4c603609 100644
--- a/testcases/kernel/syscalls/realpath/realpath01.c
+++ b/testcases/kernel/syscalls/realpath/realpath01.c
@@ -24,16 +24,7 @@ static void setup(void)
 
 static void run(void)
 {
-	TESTPTR(realpath(".", NULL));
-
-	if (TST_ERR != ENOENT) {
-		tst_res(TFAIL | TTERRNO, "returned unexpected errno");
-	} else	if (TST_RET_PTR != NULL) {
-		tst_res(TFAIL, "syscall didn't return NULL: '%s'",
-				(char *)TST_RET_PTR);
-	} else {
-		tst_res(TPASS, "bug not reproduced");
-	}
+	TST_EXP_FAIL_PTR_NULL(realpath(".", NULL), ENOENT);
 }
 
 static struct tst_test test = {
-- 
2.35.3


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

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

* Re: [LTP] [PATCH v4 1/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-02-08  1:32       ` [LTP] [PATCH v4 1/3] " Wei Gao via ltp
@ 2024-03-20 10:47         ` Petr Vorel
  2024-03-26 10:54         ` Cyril Hrubis
  1 sibling, 0 replies; 40+ messages in thread
From: Petr Vorel @ 2024-03-20 10:47 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi Wei,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v4 2/3] shmat02.c: Use TST_EXP_FAIL_PTR_VOID
  2024-02-08  1:32       ` [LTP] [PATCH v4 2/3] shmat02.c: Use TST_EXP_FAIL_PTR_VOID Wei Gao via ltp
@ 2024-03-20 10:47         ` Petr Vorel
  0 siblings, 0 replies; 40+ messages in thread
From: Petr Vorel @ 2024-03-20 10:47 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi Wei,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v4 3/3] realpath01.c: use TST_EXP_FAIL_PTR_NULL
  2024-02-08  1:32       ` [LTP] [PATCH v4 3/3] realpath01.c: use TST_EXP_FAIL_PTR_NULL Wei Gao via ltp
@ 2024-03-20 10:47         ` Petr Vorel
  0 siblings, 0 replies; 40+ messages in thread
From: Petr Vorel @ 2024-03-20 10:47 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi Wei,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v4 1/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-02-08  1:32       ` [LTP] [PATCH v4 1/3] " Wei Gao via ltp
  2024-03-20 10:47         ` Petr Vorel
@ 2024-03-26 10:54         ` Cyril Hrubis
  1 sibling, 0 replies; 40+ messages in thread
From: Cyril Hrubis @ 2024-03-26 10:54 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi!
> +#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, FAIL_PTR_VAL,                  \
> +	ERRNOS, ERRNOS_CNT, ...)                                               \
> +	do {                                                                   \
> +		TESTPTR(SCALL);                                                \
> +		                                                               \
> +		TST_PASS = 0;                                                  \
> +		                                                               \
> +		if (TST_RET_PTR != FAIL_PTR_VAL) {                             \
> +			TST_MSG_(TFAIL, " succeeded", SSCALL, ##__VA_ARGS__);  \
> +		        break;                                                 \
> +		}                                                              \
> +		                                                               \
> +		if (!tst_errno_in_set(TST_ERR, ERRNOS, ERRNOS_CNT)) {          \
> +			char tst_str_buf__[ERRNOS_CNT * 20];                   \
> +			TST_MSGP_(TFAIL | TTERRNO, " expected %s",             \
> +				  tst_errno_names(tst_str_buf__,               \
> +						  ERRNOS, ERRNOS_CNT),         \
> +				  SSCALL, ##__VA_ARGS__);                      \
> +			break;                                                 \
> +		}                                                              \
> +                                                                               \
> +		TST_PASS = 1;                                                  \
> +                                                                               \
> +	} while (0)
> +
>  #define TST_EXP_FAIL_ARR_(SCALL, SSCALL, EXP_ERRS, EXP_ERRS_CNT, ...)          \
>  	do {                                                                   \
>  		TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, SSCALL,              \
> @@ -258,6 +283,40 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
>  		TST_EXP_FAIL2_ARR_(SCALL, #SCALL, EXP_ERRS,                    \
>  		                  ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);
>  
> +#define TST_EXP_FAIL_PTR_NULL(SCALL, EXP_ERR, ...)                             \
> +	do {                                                                   \
> +		int tst_exp_err__ = EXP_ERR;                                   \
> +		TST_EXP_FAIL_SILENT_PTR_(SCALL, #SCALL, NULL,                  \
> +			&tst_exp_err__, 1, ##__VA_ARGS__);                     \
> +		if (TST_PASS)                                                  \
> +			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
> +	} while (0)

Given that the if (TST_PASS) message is same in all the cases we could
as well add TST_EX_FAIL_PTR_() and simplify all the
TST_EXP_FAIL_PTR_{NULL,ARR_NULL,VOID,ARR_VOID} to be build on the top of
that.

Other than that it looks good.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* [LTP] [PATCH v5 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-02-08  1:32     ` [LTP] [PATCH v4 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
                         ` (2 preceding siblings ...)
  2024-02-08  1:32       ` [LTP] [PATCH v4 3/3] realpath01.c: use TST_EXP_FAIL_PTR_NULL Wei Gao via ltp
@ 2024-03-27  3:49       ` Wei Gao via ltp
  2024-03-27  3:49         ` [LTP] [PATCH v5 1/3] " Wei Gao via ltp
                           ` (3 more replies)
  3 siblings, 4 replies; 40+ messages in thread
From: Wei Gao via ltp @ 2024-03-27  3:49 UTC (permalink / raw)
  To: ltp

Wei Gao (3):
  lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  shmat02.c: Use TST_EXP_FAIL_PTR_VOID
  realpath01.c: use TST_EXP_FAIL_PTR_NULL

 include/tst_test_macros.h                     | 61 +++++++++++++++++++
 lib/newlib_tests/.gitignore                   |  1 +
 lib/newlib_tests/test_macros07.c              | 61 +++++++++++++++++++
 testcases/kernel/syscalls/ipc/shmat/shmat02.c | 15 +----
 .../kernel/syscalls/realpath/realpath01.c     | 11 +---
 5 files changed, 125 insertions(+), 24 deletions(-)
 create mode 100644 lib/newlib_tests/test_macros07.c

-- 
2.35.3


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

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

* [LTP] [PATCH v5 1/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-03-27  3:49       ` [LTP] [PATCH v5 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
@ 2024-03-27  3:49         ` Wei Gao via ltp
  2024-03-28 11:29           ` Petr Vorel
                             ` (2 more replies)
  2024-03-27  3:49         ` [LTP] [PATCH v5 2/3] shmat02.c: Use TST_EXP_FAIL_PTR_VOID Wei Gao via ltp
                           ` (2 subsequent siblings)
  3 siblings, 3 replies; 40+ messages in thread
From: Wei Gao via ltp @ 2024-03-27  3:49 UTC (permalink / raw)
  To: ltp

Signed-off-by: Wei Gao <wegao@suse.com>
---
 include/tst_test_macros.h        | 61 ++++++++++++++++++++++++++++++++
 lib/newlib_tests/.gitignore      |  1 +
 lib/newlib_tests/test_macros07.c | 61 ++++++++++++++++++++++++++++++++
 3 files changed, 123 insertions(+)
 create mode 100644 lib/newlib_tests/test_macros07.c

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index d2e50a219..c70cad2f4 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -227,6 +227,41 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 		}                                                              \
 	} while (0)
 
+#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, FAIL_PTR_VAL,                  \
+	ERRNOS, ERRNOS_CNT, ...)                                               \
+	do {                                                                   \
+		TESTPTR(SCALL);                                                \
+		                                                               \
+		TST_PASS = 0;                                                  \
+		                                                               \
+		if (TST_RET_PTR != FAIL_PTR_VAL) {                             \
+			TST_MSG_(TFAIL, " succeeded", SSCALL, ##__VA_ARGS__);  \
+		        break;                                                 \
+		}                                                              \
+		                                                               \
+		if (!tst_errno_in_set(TST_ERR, ERRNOS, ERRNOS_CNT)) {          \
+			char tst_str_buf__[ERRNOS_CNT * 20];                   \
+			TST_MSGP_(TFAIL | TTERRNO, " expected %s",             \
+				  tst_errno_names(tst_str_buf__,               \
+						  ERRNOS, ERRNOS_CNT),         \
+				  SSCALL, ##__VA_ARGS__);                      \
+			break;                                                 \
+		}                                                              \
+                                                                               \
+		TST_PASS = 1;                                                  \
+                                                                               \
+	} while (0)
+
+#define TST_EXP_FAIL_PTR_(SCALL, SSCALL, FAIL_PTR_VAL,                         \
+	ERRNOS, ERRNOS_CNT, ...)                                               \
+	do {                                                                   \
+		TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, FAIL_PTR_VAL,          \
+	        ERRNOS, ERRNOS_CNT, ##__VA_ARGS__);                            \
+		if (TST_PASS)                                                  \
+			TST_MSG_(TPASS | TTERRNO, " ", SSCALL, ##__VA_ARGS__); \
+	} while (0)
+
+
 #define TST_EXP_FAIL_ARR_(SCALL, SSCALL, EXP_ERRS, EXP_ERRS_CNT, ...)          \
 	do {                                                                   \
 		TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, SSCALL,              \
@@ -258,6 +293,32 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 		TST_EXP_FAIL2_ARR_(SCALL, #SCALL, EXP_ERRS,                    \
 		                  ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);
 
+#define TST_EXP_FAIL_PTR_NULL(SCALL, EXP_ERR, ...)                             \
+	do {                                                                   \
+		int tst_exp_err__ = EXP_ERR;                                   \
+		TST_EXP_FAIL_PTR_(SCALL, #SCALL, NULL,                         \
+			&tst_exp_err__, 1, ##__VA_ARGS__);                     \
+	} while (0)
+
+#define TST_EXP_FAIL_PTR_ARR_NULL(SCALL, EXP_ERRS, ...)                        \
+	do {                                                                   \
+		TST_EXP_FAIL_PTR_(SCALL, #SCALL, NULL,                         \
+			EXP_ERRS, ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);        \
+	} while (0)
+
+#define TST_EXP_FAIL_PTR_VOID(SCALL, EXP_ERR, ...)                             \
+	do {                                                                   \
+		int tst_exp_err__ = EXP_ERR;                                   \
+		TST_EXP_FAIL_PTR_(SCALL, #SCALL, (void *)-1,                   \
+			&tst_exp_err__, 1, ##__VA_ARGS__);                     \
+	} while (0)
+
+#define TST_EXP_FAIL_PTR_ARR_VOID(SCALL, EXP_ERRS, ...)                        \
+	do {                                                                   \
+		TST_EXP_FAIL_PTR_(SCALL, #SCALL, (void *)-1,                   \
+			EXP_ERRS, ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);        \
+	} while (0)
+
 #define TST_EXP_FAIL2(SCALL, EXP_ERR, ...)                                     \
 	do {                                                                   \
 		int tst_exp_err__ = EXP_ERR;                                   \
diff --git a/lib/newlib_tests/.gitignore b/lib/newlib_tests/.gitignore
index a69b29e24..4f43899e5 100644
--- a/lib/newlib_tests/.gitignore
+++ b/lib/newlib_tests/.gitignore
@@ -40,6 +40,7 @@ test_macros03
 test_macros04
 test_macros05
 test_macros06
+test_macros07
 tst_fuzzy_sync01
 tst_fuzzy_sync02
 tst_fuzzy_sync03
diff --git a/lib/newlib_tests/test_macros07.c b/lib/newlib_tests/test_macros07.c
new file mode 100644
index 000000000..ac361fd8e
--- /dev/null
+++ b/lib/newlib_tests/test_macros07.c
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2024 Wei Gao <wegao@suse.com>
+ */
+
+/*
+ * Test TST_EXP_FAIL_PTR_{NULL,VOID} and TST_EXP_FAIL_PTR_ARR{NULL,VOID} macro.
+ */
+
+#include "tst_test.h"
+
+static char *fail_fn_null(void)
+{
+	errno = EINVAL;
+	return NULL;
+}
+
+static char *fail_fn_void(void)
+{
+	errno = EINVAL;
+	return (void *)-1;
+}
+
+static char *pass_fn(void)
+{
+	return "pass";
+}
+
+static void do_test(void)
+{
+	const int exp_errs_pass[] = {ENOTTY, EINVAL};
+	const int exp_errs_fail[] = {ENOTTY, EISDIR};
+
+	tst_res(TINFO, "Testing TST_EXP_FAIL_PTR_NULL macro");
+	TST_EXP_FAIL_PTR_NULL(fail_fn_null(), EINVAL, "fail_fn_null()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_NULL(fail_fn_null(), ENOTTY, "fail_fn_null()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_NULL(pass_fn(), ENOTTY, "pass_fn()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_ARR_NULL(fail_fn_null(), exp_errs_pass, "fail_fn_null()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_ARR_NULL(fail_fn_null(), exp_errs_fail, "fail_fn()_null");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+
+	tst_res(TINFO, "Testing TST_EXP_FAIL_PTR_VOID macro");
+	TST_EXP_FAIL_PTR_VOID(fail_fn_void(), EINVAL, "fail_fn_void()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_VOID(fail_fn_void(), ENOTTY, "fail_fn_void()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_VOID(pass_fn(), ENOTTY, "pass_fn()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_ARR_VOID(fail_fn_void(), exp_errs_pass, "fail_fn_void()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_ARR_VOID(fail_fn_void(), exp_errs_fail, "fail_fn()_void");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+}
+
+static struct tst_test test = {
+	.test_all = do_test,
+};
-- 
2.35.3


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

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

* [LTP] [PATCH v5 2/3] shmat02.c: Use TST_EXP_FAIL_PTR_VOID
  2024-03-27  3:49       ` [LTP] [PATCH v5 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
  2024-03-27  3:49         ` [LTP] [PATCH v5 1/3] " Wei Gao via ltp
@ 2024-03-27  3:49         ` Wei Gao via ltp
  2024-03-27  3:49         ` [LTP] [PATCH v5 3/3] realpath01.c: use TST_EXP_FAIL_PTR_NULL Wei Gao via ltp
  2024-04-03  3:28         ` [LTP] [PATCH v6 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
  3 siblings, 0 replies; 40+ messages in thread
From: Wei Gao via ltp @ 2024-03-27  3:49 UTC (permalink / raw)
  To: ltp

Signed-off-by: Wei Gao <wegao@suse.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/syscalls/ipc/shmat/shmat02.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/shmat/shmat02.c b/testcases/kernel/syscalls/ipc/shmat/shmat02.c
index 53cb6f542..3ad1fd08e 100644
--- a/testcases/kernel/syscalls/ipc/shmat/shmat02.c
+++ b/testcases/kernel/syscalls/ipc/shmat/shmat02.c
@@ -44,20 +44,7 @@ static struct test_case_t {
 
 static void verify_shmat(struct test_case_t *tc)
 {
-	void *addr;
-
-	addr = shmat(*tc->shmid, *tc->shmaddr, 0);
-	if (addr != (void *)-1) {
-		tst_res(TFAIL, "shmat() succeeded unexpectedly");
-		return;
-	}
-
-	if (errno == tc->exp_err) {
-		tst_res(TPASS | TERRNO, "shmat() failed as expected");
-	} else {
-		tst_res(TFAIL | TERRNO, "shmat() failed unexpectedly, expected: %s",
-			tst_strerrno(tc->exp_err));
-	}
+	TST_EXP_FAIL_PTR_VOID(shmat(*tc->shmid, *tc->shmaddr, 0), tc->exp_err);
 }
 
 static void do_shmat(unsigned int n)
-- 
2.35.3


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

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

* [LTP] [PATCH v5 3/3] realpath01.c: use TST_EXP_FAIL_PTR_NULL
  2024-03-27  3:49       ` [LTP] [PATCH v5 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
  2024-03-27  3:49         ` [LTP] [PATCH v5 1/3] " Wei Gao via ltp
  2024-03-27  3:49         ` [LTP] [PATCH v5 2/3] shmat02.c: Use TST_EXP_FAIL_PTR_VOID Wei Gao via ltp
@ 2024-03-27  3:49         ` Wei Gao via ltp
  2024-04-03  3:28         ` [LTP] [PATCH v6 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
  3 siblings, 0 replies; 40+ messages in thread
From: Wei Gao via ltp @ 2024-03-27  3:49 UTC (permalink / raw)
  To: ltp

Signed-off-by: Wei Gao <wegao@suse.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/kernel/syscalls/realpath/realpath01.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/testcases/kernel/syscalls/realpath/realpath01.c b/testcases/kernel/syscalls/realpath/realpath01.c
index c0381e9cb..c4c603609 100644
--- a/testcases/kernel/syscalls/realpath/realpath01.c
+++ b/testcases/kernel/syscalls/realpath/realpath01.c
@@ -24,16 +24,7 @@ static void setup(void)
 
 static void run(void)
 {
-	TESTPTR(realpath(".", NULL));
-
-	if (TST_ERR != ENOENT) {
-		tst_res(TFAIL | TTERRNO, "returned unexpected errno");
-	} else	if (TST_RET_PTR != NULL) {
-		tst_res(TFAIL, "syscall didn't return NULL: '%s'",
-				(char *)TST_RET_PTR);
-	} else {
-		tst_res(TPASS, "bug not reproduced");
-	}
+	TST_EXP_FAIL_PTR_NULL(realpath(".", NULL), ENOENT);
 }
 
 static struct tst_test test = {
-- 
2.35.3


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

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

* Re: [LTP] [PATCH v5 1/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-03-27  3:49         ` [LTP] [PATCH v5 1/3] " Wei Gao via ltp
@ 2024-03-28 11:29           ` Petr Vorel
  2024-03-28 11:49           ` Petr Vorel
  2024-03-28 12:11           ` Petr Vorel
  2 siblings, 0 replies; 40+ messages in thread
From: Petr Vorel @ 2024-03-28 11:29 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi Wei,

> --- /dev/null
> +++ b/lib/newlib_tests/test_macros07.c
nit: Instead of creating a new test I would add it to existing test_macros02.c
(it would reduce some duplicity).

Also having exp_errs_pass[] and exp_errs_fail[] static and put testing all 4
macros into it's own functions, I'll send a suggestion shortly.

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v5 1/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-03-27  3:49         ` [LTP] [PATCH v5 1/3] " Wei Gao via ltp
  2024-03-28 11:29           ` Petr Vorel
@ 2024-03-28 11:49           ` Petr Vorel
  2024-03-28 11:57             ` Petr Vorel
  2024-03-28 12:11           ` Petr Vorel
  2 siblings, 1 reply; 40+ messages in thread
From: Petr Vorel @ 2024-03-28 11:49 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi Wei,

> --- /dev/null
> +++ b/lib/newlib_tests/test_macros07.c
> @@ -0,0 +1,61 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2024 Wei Gao <wegao@suse.com>
> + */
> +
> +/*
> + * Test TST_EXP_FAIL_PTR_{NULL,VOID} and TST_EXP_FAIL_PTR_ARR{NULL,VOID} macro.
> + */
> +
> +#include "tst_test.h"
> +
> +static char *fail_fn_null(void)
> +{
> +	errno = EINVAL;
> +	return NULL;
> +}
> +
> +static char *fail_fn_void(void)
> +{
> +	errno = EINVAL;
> +	return (void *)-1;
> +}
> +
> +static char *pass_fn(void)
> +{
> +	return "pass";
> +}
> +
> +static void do_test(void)
> +{
> +	const int exp_errs_pass[] = {ENOTTY, EINVAL};
> +	const int exp_errs_fail[] = {ENOTTY, EISDIR};
> +
> +	tst_res(TINFO, "Testing TST_EXP_FAIL_PTR_NULL macro");
> +	TST_EXP_FAIL_PTR_NULL(fail_fn_null(), EINVAL, "fail_fn_null()");
> +	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
> +	TST_EXP_FAIL_PTR_NULL(fail_fn_null(), ENOTTY, "fail_fn_null()");
> +	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
> +	TST_EXP_FAIL_PTR_NULL(pass_fn(), ENOTTY, "pass_fn()");
> +	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
> +	TST_EXP_FAIL_PTR_ARR_NULL(fail_fn_null(), exp_errs_pass, "fail_fn_null()");
> +	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
> +	TST_EXP_FAIL_PTR_ARR_NULL(fail_fn_null(), exp_errs_fail, "fail_fn()_null");
> +	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
> +
> +	tst_res(TINFO, "Testing TST_EXP_FAIL_PTR_VOID macro");
> +	TST_EXP_FAIL_PTR_VOID(fail_fn_void(), EINVAL, "fail_fn_void()");
> +	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
> +	TST_EXP_FAIL_PTR_VOID(fail_fn_void(), ENOTTY, "fail_fn_void()");
> +	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
> +	TST_EXP_FAIL_PTR_VOID(pass_fn(), ENOTTY, "pass_fn()");
> +	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
> +	TST_EXP_FAIL_PTR_ARR_VOID(fail_fn_void(), exp_errs_pass, "fail_fn_void()");
> +	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
> +	TST_EXP_FAIL_PTR_ARR_VOID(fail_fn_void(), exp_errs_fail, "fail_fn()_void");
> +	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
> +}
> +
> +static struct tst_test test = {
> +	.test_all = do_test,
> +};

How about extend test_macros02.c (add testing macro, renaming functions to avoid clash,
add inval_ret_fn_char() which was missing in your version):

static int fail_fn(void)
{
	errno = EINVAL;
	return -1;
}

static int pass_fn(void)
{
	return 0;
}

static int inval_ret_fn(void)
{
	return 42;
}

static char *fail_fn_null(void)
{
	errno = EINVAL;
	return NULL;
}

static char *fail_fn_void(void)
{
	errno = EINVAL;
	return (void *)-1;
}

static char *inval_ret_fn_char(void)
{
	return (void *)-1;
}

static char *pass_fn_char(void)
{
	return "pass";
}

#define TEST_MACRO(macro, macro_arr, fail_fn, pass_fn, inval_fn) \
	do {                                                                   \
		tst_res(TINFO, "Testing macro macro"); \
		macro(fail_fn(), EINVAL, "fail_fn()"); \
		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
		macro(fail_fn(), ENOTTY, "fail_fn()"); \
		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
		macro(pass_fn(), ENOTTY, "pass_fn()"); \
		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
		macro(inval_fn(), ENOTTY, "inval_fn()"); \
		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
		macro_arr(fail_fn(), exp_errs_pass, "fail_fn()"); \
		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
		macro_arr(fail_fn(), exp_errs_fail, "fail_fn()"); \
		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
	} while (0)

static void do_test(void)
{

	const int exp_errs_pass[] = {ENOTTY, EINVAL};
	const int exp_errs_fail[] = {ENOTTY, EISDIR};

	TEST_MACRO(TST_EXP_FAIL, TST_EXP_FAIL_ARR, fail_fn, pass_fn, inval_ret_fn);
	TEST_MACRO(TST_EXP_FAIL2, TST_EXP_FAIL2_ARR, fail_fn, pass_fn, inval_ret_fn);
	TEST_MACRO(TST_EXP_FAIL_PTR_NULL, TST_EXP_FAIL_PTR_ARR_NULL, fail_fn_null,
			   pass_fn_char, inval_ret_fn_char);
	TEST_MACRO(TST_EXP_FAIL_PTR_VOID, TST_EXP_FAIL_PTR_ARR_VOID, fail_fn_void,
			   pass_fn_char, inval_ret_fn_char);
}

static struct tst_test test = {
	.test_all = do_test,
};

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

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

* Re: [LTP] [PATCH v5 1/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-03-28 11:49           ` Petr Vorel
@ 2024-03-28 11:57             ` Petr Vorel
  0 siblings, 0 replies; 40+ messages in thread
From: Petr Vorel @ 2024-03-28 11:57 UTC (permalink / raw)
  To: Wei Gao, ltp

Hi Wei,
> Hi Wei,

...
> #define TEST_MACRO(macro, macro_arr, fail_fn, pass_fn, inval_fn) \
> 	do {                                                                   \
> 		tst_res(TINFO, "Testing macro macro"); \
> 		macro(fail_fn(), EINVAL, "fail_fn()"); \
> 		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
> 		macro(fail_fn(), ENOTTY, "fail_fn()"); \
> 		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
> 		macro(pass_fn(), ENOTTY, "pass_fn()"); \
> 		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
> 		macro(inval_fn(), ENOTTY, "inval_fn()"); \
> 		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
> 		macro_arr(fail_fn(), exp_errs_pass, "fail_fn()"); \
> 		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
> 		macro_arr(fail_fn(), exp_errs_fail, "fail_fn()"); \
> 		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
> 	} while (0)

Actually this (print real function with #macro and #macro_arr,
2x skip message parameter (to test also macro without error parameter):

#define TEST_MACRO(macro, macro_arr, fail_fn, pass_fn, inval_fn) \
	do {                                                                   \
		tst_res(TINFO, "Testing " #macro " macro"); \
		macro(fail_fn(), EINVAL, #fail_fn"()"); \
		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
		macro(fail_fn(), ENOTTY); /* skip msg parameter */ \
		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
		macro(pass_fn(), ENOTTY, #pass_fn"()"); \
		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
		macro(inval_fn(), ENOTTY, #inval_fn"()"); \
		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
		macro_arr(fail_fn(), exp_errs_pass, #fail_fn"()"); \
		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
		macro_arr(fail_fn(), exp_errs_fail); /* skip msg parameter */ \
		tst_res(TINFO, "TST_PASS = %i", TST_PASS); \
	} while (0)

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v5 1/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-03-27  3:49         ` [LTP] [PATCH v5 1/3] " Wei Gao via ltp
  2024-03-28 11:29           ` Petr Vorel
  2024-03-28 11:49           ` Petr Vorel
@ 2024-03-28 12:11           ` Petr Vorel
  2 siblings, 0 replies; 40+ messages in thread
From: Petr Vorel @ 2024-03-28 12:11 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi Wei,

...
>  #define TST_EXP_FAIL_ARR_(SCALL, SSCALL, EXP_ERRS, EXP_ERRS_CNT, ...)          \
>  	do {                                                                   \
>  		TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, SSCALL,              \
> @@ -258,6 +293,32 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
>  		TST_EXP_FAIL2_ARR_(SCALL, #SCALL, EXP_ERRS,                    \
>  		                  ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);

> +#define TST_EXP_FAIL_PTR_NULL(SCALL, EXP_ERR, ...)                             \
> +	do {                                                                   \
> +		int tst_exp_err__ = EXP_ERR;                                   \
> +		TST_EXP_FAIL_PTR_(SCALL, #SCALL, NULL,                         \
> +			&tst_exp_err__, 1, ##__VA_ARGS__);                     \
> +	} while (0)
> +
> +#define TST_EXP_FAIL_PTR_ARR_NULL(SCALL, EXP_ERRS, ...)                        \
> +	do {                                                                   \
> +		TST_EXP_FAIL_PTR_(SCALL, #SCALL, NULL,                         \
> +			EXP_ERRS, ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);        \

FYI I send a patch [1] (Cyril's suggestion) replacing ARRAY_SIZE() with just
size parameter. I.e. moving ARRAY_SIZE() to the caller. This allows to use array
of expected errnos more flexibly, e.g. fanotify14 [2].

Could you please send another version, which will be based on my v3 patchset or
just wait before it's merged and rebase?

Kind regards,
Petr

[1] https://lore.kernel.org/ltp/20240326144145.747735-3-pvorel@suse.cz/
[2] https://lore.kernel.org/ltp/20240326144145.747735-4-pvorel@suse.cz/
[3] https://patchwork.ozlabs.org/project/ltp/list/?series=400495

> +	} while (0)
> +
> +#define TST_EXP_FAIL_PTR_VOID(SCALL, EXP_ERR, ...)                             \
> +	do {                                                                   \
> +		int tst_exp_err__ = EXP_ERR;                                   \
> +		TST_EXP_FAIL_PTR_(SCALL, #SCALL, (void *)-1,                   \
> +			&tst_exp_err__, 1, ##__VA_ARGS__);                     \
> +	} while (0)
> +
> +#define TST_EXP_FAIL_PTR_ARR_VOID(SCALL, EXP_ERRS, ...)                        \
> +	do {                                                                   \
> +		TST_EXP_FAIL_PTR_(SCALL, #SCALL, (void *)-1,                   \
> +			EXP_ERRS, ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);        \
> +	} while (0)
> +

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

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

* [LTP] [PATCH v6 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-03-27  3:49       ` [LTP] [PATCH v5 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
                           ` (2 preceding siblings ...)
  2024-03-27  3:49         ` [LTP] [PATCH v5 3/3] realpath01.c: use TST_EXP_FAIL_PTR_NULL Wei Gao via ltp
@ 2024-04-03  3:28         ` Wei Gao via ltp
  2024-04-03  3:28           ` [LTP] [PATCH v6 1/3] " Wei Gao via ltp
                             ` (2 more replies)
  3 siblings, 3 replies; 40+ messages in thread
From: Wei Gao via ltp @ 2024-04-03  3:28 UTC (permalink / raw)
  To: ltp

Wei Gao (3):
  lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  shmat02.c: Use TST_EXP_FAIL_PTR_VOID
  realpath01.c: use TST_EXP_FAIL_PTR_NULL

 include/tst_test_macros.h                     | 61 +++++++++++++++++++
 lib/newlib_tests/.gitignore                   |  1 +
 lib/newlib_tests/test_macros07.c              | 61 +++++++++++++++++++
 testcases/kernel/syscalls/ipc/shmat/shmat02.c | 15 +----
 .../kernel/syscalls/realpath/realpath01.c     | 11 +---
 5 files changed, 125 insertions(+), 24 deletions(-)
 create mode 100644 lib/newlib_tests/test_macros07.c

-- 
2.35.3


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

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

* [LTP] [PATCH v6 1/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-04-03  3:28         ` [LTP] [PATCH v6 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
@ 2024-04-03  3:28           ` Wei Gao via ltp
  2024-04-04 13:51             ` Cyril Hrubis
  2024-04-03  3:28           ` [LTP] [PATCH v6 2/3] shmat02.c: Use TST_EXP_FAIL_PTR_VOID Wei Gao via ltp
  2024-04-03  3:28           ` [LTP] [PATCH v6 3/3] realpath01.c: use TST_EXP_FAIL_PTR_NULL Wei Gao via ltp
  2 siblings, 1 reply; 40+ messages in thread
From: Wei Gao via ltp @ 2024-04-03  3:28 UTC (permalink / raw)
  To: ltp

Signed-off-by: Wei Gao <wegao@suse.com>
---
 include/tst_test_macros.h        | 61 ++++++++++++++++++++++++++++++++
 lib/newlib_tests/.gitignore      |  1 +
 lib/newlib_tests/test_macros07.c | 61 ++++++++++++++++++++++++++++++++
 3 files changed, 123 insertions(+)
 create mode 100644 lib/newlib_tests/test_macros07.c

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index 6a7bcdce5..eff3aef69 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -227,6 +227,41 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 		}                                                              \
 	} while (0)
 
+#define TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, FAIL_PTR_VAL,                  \
+	ERRNOS, ERRNOS_CNT, ...)                                               \
+	do {                                                                   \
+		TESTPTR(SCALL);                                                \
+		                                                               \
+		TST_PASS = 0;                                                  \
+		                                                               \
+		if (TST_RET_PTR != FAIL_PTR_VAL) {                             \
+			TST_MSG_(TFAIL, " succeeded", SSCALL, ##__VA_ARGS__);  \
+		        break;                                                 \
+		}                                                              \
+		                                                               \
+		if (!tst_errno_in_set(TST_ERR, ERRNOS, ERRNOS_CNT)) {          \
+			char tst_str_buf__[ERRNOS_CNT * 20];                   \
+			TST_MSGP_(TFAIL | TTERRNO, " expected %s",             \
+				  tst_errno_names(tst_str_buf__,               \
+						  ERRNOS, ERRNOS_CNT),         \
+				  SSCALL, ##__VA_ARGS__);                      \
+			break;                                                 \
+		}                                                              \
+                                                                               \
+		TST_PASS = 1;                                                  \
+                                                                               \
+	} while (0)
+
+#define TST_EXP_FAIL_PTR_(SCALL, SSCALL, FAIL_PTR_VAL,                         \
+	ERRNOS, ERRNOS_CNT, ...)                                               \
+	do {                                                                   \
+		TST_EXP_FAIL_SILENT_PTR_(SCALL, SSCALL, FAIL_PTR_VAL,          \
+	        ERRNOS, ERRNOS_CNT, ##__VA_ARGS__);                            \
+		if (TST_PASS)                                                  \
+			TST_MSG_(TPASS | TTERRNO, " ", SSCALL, ##__VA_ARGS__); \
+	} while (0)
+
+
 #define TST_EXP_FAIL_ARR_(SCALL, SSCALL, EXP_ERRS, EXP_ERRS_CNT, ...)          \
 	do {                                                                   \
 		TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, SSCALL,              \
@@ -258,6 +293,32 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 		TST_EXP_FAIL2_ARR_(SCALL, #SCALL, EXP_ERRS,                    \
 		                  EXP_ERRS_CNT, ##__VA_ARGS__);
 
+#define TST_EXP_FAIL_PTR_NULL(SCALL, EXP_ERR, ...)                             \
+	do {                                                                   \
+		int tst_exp_err__ = EXP_ERR;                                   \
+		TST_EXP_FAIL_PTR_(SCALL, #SCALL, NULL,                         \
+			&tst_exp_err__, 1, ##__VA_ARGS__);                     \
+	} while (0)
+
+#define TST_EXP_FAIL_PTR_ARR_NULL(SCALL, EXP_ERRS, ...)                        \
+	do {                                                                   \
+		TST_EXP_FAIL_PTR_(SCALL, #SCALL, NULL,                         \
+			EXP_ERRS, ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);        \
+	} while (0)
+
+#define TST_EXP_FAIL_PTR_VOID(SCALL, EXP_ERR, ...)                             \
+	do {                                                                   \
+		int tst_exp_err__ = EXP_ERR;                                   \
+		TST_EXP_FAIL_PTR_(SCALL, #SCALL, (void *)-1,                   \
+			&tst_exp_err__, 1, ##__VA_ARGS__);                     \
+	} while (0)
+
+#define TST_EXP_FAIL_PTR_ARR_VOID(SCALL, EXP_ERRS, ...)                        \
+	do {                                                                   \
+		TST_EXP_FAIL_PTR_(SCALL, #SCALL, (void *)-1,                   \
+			EXP_ERRS, ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);        \
+	} while (0)
+
 #define TST_EXP_FAIL2(SCALL, EXP_ERR, ...)                                     \
 	do {                                                                   \
 		int tst_exp_err__ = EXP_ERR;                                   \
diff --git a/lib/newlib_tests/.gitignore b/lib/newlib_tests/.gitignore
index 6d125f933..ed10d860a 100644
--- a/lib/newlib_tests/.gitignore
+++ b/lib/newlib_tests/.gitignore
@@ -41,6 +41,7 @@ test_macros03
 test_macros04
 test_macros05
 test_macros06
+test_macros07
 tst_fuzzy_sync01
 tst_fuzzy_sync02
 tst_fuzzy_sync03
diff --git a/lib/newlib_tests/test_macros07.c b/lib/newlib_tests/test_macros07.c
new file mode 100644
index 000000000..ac361fd8e
--- /dev/null
+++ b/lib/newlib_tests/test_macros07.c
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2024 Wei Gao <wegao@suse.com>
+ */
+
+/*
+ * Test TST_EXP_FAIL_PTR_{NULL,VOID} and TST_EXP_FAIL_PTR_ARR{NULL,VOID} macro.
+ */
+
+#include "tst_test.h"
+
+static char *fail_fn_null(void)
+{
+	errno = EINVAL;
+	return NULL;
+}
+
+static char *fail_fn_void(void)
+{
+	errno = EINVAL;
+	return (void *)-1;
+}
+
+static char *pass_fn(void)
+{
+	return "pass";
+}
+
+static void do_test(void)
+{
+	const int exp_errs_pass[] = {ENOTTY, EINVAL};
+	const int exp_errs_fail[] = {ENOTTY, EISDIR};
+
+	tst_res(TINFO, "Testing TST_EXP_FAIL_PTR_NULL macro");
+	TST_EXP_FAIL_PTR_NULL(fail_fn_null(), EINVAL, "fail_fn_null()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_NULL(fail_fn_null(), ENOTTY, "fail_fn_null()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_NULL(pass_fn(), ENOTTY, "pass_fn()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_ARR_NULL(fail_fn_null(), exp_errs_pass, "fail_fn_null()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_ARR_NULL(fail_fn_null(), exp_errs_fail, "fail_fn()_null");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+
+	tst_res(TINFO, "Testing TST_EXP_FAIL_PTR_VOID macro");
+	TST_EXP_FAIL_PTR_VOID(fail_fn_void(), EINVAL, "fail_fn_void()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_VOID(fail_fn_void(), ENOTTY, "fail_fn_void()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_VOID(pass_fn(), ENOTTY, "pass_fn()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_ARR_VOID(fail_fn_void(), exp_errs_pass, "fail_fn_void()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_FAIL_PTR_ARR_VOID(fail_fn_void(), exp_errs_fail, "fail_fn()_void");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+}
+
+static struct tst_test test = {
+	.test_all = do_test,
+};
-- 
2.35.3


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

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

* [LTP] [PATCH v6 2/3] shmat02.c: Use TST_EXP_FAIL_PTR_VOID
  2024-04-03  3:28         ` [LTP] [PATCH v6 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
  2024-04-03  3:28           ` [LTP] [PATCH v6 1/3] " Wei Gao via ltp
@ 2024-04-03  3:28           ` Wei Gao via ltp
  2024-04-03  3:28           ` [LTP] [PATCH v6 3/3] realpath01.c: use TST_EXP_FAIL_PTR_NULL Wei Gao via ltp
  2 siblings, 0 replies; 40+ messages in thread
From: Wei Gao via ltp @ 2024-04-03  3:28 UTC (permalink / raw)
  To: ltp

Signed-off-by: Wei Gao <wegao@suse.com>
---
 testcases/kernel/syscalls/ipc/shmat/shmat02.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/shmat/shmat02.c b/testcases/kernel/syscalls/ipc/shmat/shmat02.c
index 53cb6f542..3ad1fd08e 100644
--- a/testcases/kernel/syscalls/ipc/shmat/shmat02.c
+++ b/testcases/kernel/syscalls/ipc/shmat/shmat02.c
@@ -44,20 +44,7 @@ static struct test_case_t {
 
 static void verify_shmat(struct test_case_t *tc)
 {
-	void *addr;
-
-	addr = shmat(*tc->shmid, *tc->shmaddr, 0);
-	if (addr != (void *)-1) {
-		tst_res(TFAIL, "shmat() succeeded unexpectedly");
-		return;
-	}
-
-	if (errno == tc->exp_err) {
-		tst_res(TPASS | TERRNO, "shmat() failed as expected");
-	} else {
-		tst_res(TFAIL | TERRNO, "shmat() failed unexpectedly, expected: %s",
-			tst_strerrno(tc->exp_err));
-	}
+	TST_EXP_FAIL_PTR_VOID(shmat(*tc->shmid, *tc->shmaddr, 0), tc->exp_err);
 }
 
 static void do_shmat(unsigned int n)
-- 
2.35.3


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

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

* [LTP] [PATCH v6 3/3] realpath01.c: use TST_EXP_FAIL_PTR_NULL
  2024-04-03  3:28         ` [LTP] [PATCH v6 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
  2024-04-03  3:28           ` [LTP] [PATCH v6 1/3] " Wei Gao via ltp
  2024-04-03  3:28           ` [LTP] [PATCH v6 2/3] shmat02.c: Use TST_EXP_FAIL_PTR_VOID Wei Gao via ltp
@ 2024-04-03  3:28           ` Wei Gao via ltp
  2 siblings, 0 replies; 40+ messages in thread
From: Wei Gao via ltp @ 2024-04-03  3:28 UTC (permalink / raw)
  To: ltp

Signed-off-by: Wei Gao <wegao@suse.com>
---
 include/tst_test_macros.h                       |  8 ++++----
 lib/newlib_tests/test_macros07.c                |  8 ++++----
 testcases/kernel/syscalls/realpath/realpath01.c | 11 +----------
 3 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index eff3aef69..88c329333 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -300,10 +300,10 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 			&tst_exp_err__, 1, ##__VA_ARGS__);                     \
 	} while (0)
 
-#define TST_EXP_FAIL_PTR_ARR_NULL(SCALL, EXP_ERRS, ...)                        \
+#define TST_EXP_FAIL_PTR_ARR_NULL(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...)          \
 	do {                                                                   \
 		TST_EXP_FAIL_PTR_(SCALL, #SCALL, NULL,                         \
-			EXP_ERRS, ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);        \
+			EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__);                \
 	} while (0)
 
 #define TST_EXP_FAIL_PTR_VOID(SCALL, EXP_ERR, ...)                             \
@@ -313,10 +313,10 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 			&tst_exp_err__, 1, ##__VA_ARGS__);                     \
 	} while (0)
 
-#define TST_EXP_FAIL_PTR_ARR_VOID(SCALL, EXP_ERRS, ...)                        \
+#define TST_EXP_FAIL_PTR_ARR_VOID(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...)          \
 	do {                                                                   \
 		TST_EXP_FAIL_PTR_(SCALL, #SCALL, (void *)-1,                   \
-			EXP_ERRS, ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);        \
+			EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__);                \
 	} while (0)
 
 #define TST_EXP_FAIL2(SCALL, EXP_ERR, ...)                                     \
diff --git a/lib/newlib_tests/test_macros07.c b/lib/newlib_tests/test_macros07.c
index ac361fd8e..6015988cf 100644
--- a/lib/newlib_tests/test_macros07.c
+++ b/lib/newlib_tests/test_macros07.c
@@ -38,9 +38,9 @@ static void do_test(void)
 	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
 	TST_EXP_FAIL_PTR_NULL(pass_fn(), ENOTTY, "pass_fn()");
 	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
-	TST_EXP_FAIL_PTR_ARR_NULL(fail_fn_null(), exp_errs_pass, "fail_fn_null()");
+	TST_EXP_FAIL_PTR_ARR_NULL(fail_fn_null(), exp_errs_pass, ARRAY_SIZE(exp_errs_pass), "fail_fn_null()");
 	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
-	TST_EXP_FAIL_PTR_ARR_NULL(fail_fn_null(), exp_errs_fail, "fail_fn()_null");
+	TST_EXP_FAIL_PTR_ARR_NULL(fail_fn_null(), exp_errs_fail, ARRAY_SIZE(exp_errs_fail), "fail_fn()_null");
 	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
 
 	tst_res(TINFO, "Testing TST_EXP_FAIL_PTR_VOID macro");
@@ -50,9 +50,9 @@ static void do_test(void)
 	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
 	TST_EXP_FAIL_PTR_VOID(pass_fn(), ENOTTY, "pass_fn()");
 	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
-	TST_EXP_FAIL_PTR_ARR_VOID(fail_fn_void(), exp_errs_pass, "fail_fn_void()");
+	TST_EXP_FAIL_PTR_ARR_VOID(fail_fn_void(), exp_errs_pass, ARRAY_SIZE(exp_errs_pass), "fail_fn_void()");
 	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
-	TST_EXP_FAIL_PTR_ARR_VOID(fail_fn_void(), exp_errs_fail, "fail_fn()_void");
+	TST_EXP_FAIL_PTR_ARR_VOID(fail_fn_void(), exp_errs_fail, ARRAY_SIZE(exp_errs_fail), "fail_fn()_void");
 	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
 }
 
diff --git a/testcases/kernel/syscalls/realpath/realpath01.c b/testcases/kernel/syscalls/realpath/realpath01.c
index c0381e9cb..c4c603609 100644
--- a/testcases/kernel/syscalls/realpath/realpath01.c
+++ b/testcases/kernel/syscalls/realpath/realpath01.c
@@ -24,16 +24,7 @@ static void setup(void)
 
 static void run(void)
 {
-	TESTPTR(realpath(".", NULL));
-
-	if (TST_ERR != ENOENT) {
-		tst_res(TFAIL | TTERRNO, "returned unexpected errno");
-	} else	if (TST_RET_PTR != NULL) {
-		tst_res(TFAIL, "syscall didn't return NULL: '%s'",
-				(char *)TST_RET_PTR);
-	} else {
-		tst_res(TPASS, "bug not reproduced");
-	}
+	TST_EXP_FAIL_PTR_NULL(realpath(".", NULL), ENOENT);
 }
 
 static struct tst_test test = {
-- 
2.35.3


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

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

* Re: [LTP] [PATCH v6 1/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-04-03  3:28           ` [LTP] [PATCH v6 1/3] " Wei Gao via ltp
@ 2024-04-04 13:51             ` Cyril Hrubis
  2024-04-04 16:01               ` Petr Vorel
  0 siblings, 1 reply; 40+ messages in thread
From: Cyril Hrubis @ 2024-04-04 13:51 UTC (permalink / raw)
  To: Wei Gao; +Cc: ltp

Hi!
This one looks good, I would wote for merging it now, however the
subject suggests that the TST_EXP_PASS_PTR_* functions are implemented
here as well, which isn't the case.

So I propse to fix the subject to include only EXP_FAIL_ and merge this
then add the EXP_PASS_ variants in another patch.

With that:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz> for the whole patchset.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v6 1/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-04-04 13:51             ` Cyril Hrubis
@ 2024-04-04 16:01               ` Petr Vorel
  2024-04-05  8:53                 ` Cyril Hrubis
  0 siblings, 1 reply; 40+ messages in thread
From: Petr Vorel @ 2024-04-04 16:01 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril, Wei,

> Hi!
> This one looks good, I would wote for merging it now, however the
> subject suggests that the TST_EXP_PASS_PTR_* functions are implemented
> here as well, which isn't the case.

> So I propse to fix the subject to include only EXP_FAIL_ and merge this
> then add the EXP_PASS_ variants in another patch.

Sure, I'll fix that before merge.

BTW I fix that in the v6 patchset which I sent (and I Cc Wei and you) before Wei
sent his v6 (my only change was adding everything into test_macros02 and use
macros to shorten the code as more macros will be added to it in the future. I
suppose you prefer the original code as you acked this).

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/project/ltp/patch/20240328162939.100872-2-pvorel@suse.cz/

> With that:

> Reviewed-by: Cyril Hrubis <chrubis@suse.cz> for the whole patchset.

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

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

* Re: [LTP] [PATCH v6 1/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-04-04 16:01               ` Petr Vorel
@ 2024-04-05  8:53                 ` Cyril Hrubis
  2024-04-05 10:28                   ` Petr Vorel
  0 siblings, 1 reply; 40+ messages in thread
From: Cyril Hrubis @ 2024-04-05  8:53 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi!
> > This one looks good, I would wote for merging it now, however the
> > subject suggests that the TST_EXP_PASS_PTR_* functions are implemented
> > here as well, which isn't the case.
> 
> > So I propse to fix the subject to include only EXP_FAIL_ and merge this
> > then add the EXP_PASS_ variants in another patch.
> 
> Sure, I'll fix that before merge.
> 
> BTW I fix that in the v6 patchset which I sent (and I Cc Wei and you) before Wei
> sent his v6 (my only change was adding everything into test_macros02 and use
> macros to shorten the code as more macros will be added to it in the future. I
> suppose you prefer the original code as you acked this).

I'm simply lost in the number of iterations for this patch. Also I do
not think that reducing the duplication in the library test is that
important, but feel free to push that with my reviewed-by as well.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v6 1/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-04-05  8:53                 ` Cyril Hrubis
@ 2024-04-05 10:28                   ` Petr Vorel
  2024-04-05 11:23                     ` Cyril Hrubis
  0 siblings, 1 reply; 40+ messages in thread
From: Petr Vorel @ 2024-04-05 10:28 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

> Hi!
> > > This one looks good, I would wote for merging it now, however the
> > > subject suggests that the TST_EXP_PASS_PTR_* functions are implemented
> > > here as well, which isn't the case.

> > > So I propse to fix the subject to include only EXP_FAIL_ and merge this
> > > then add the EXP_PASS_ variants in another patch.

> > Sure, I'll fix that before merge.

> > BTW I fix that in the v6 patchset which I sent (and I Cc Wei and you) before Wei
> > sent his v6 (my only change was adding everything into test_macros02 and use
> > macros to shorten the code as more macros will be added to it in the future. I
> > suppose you prefer the original code as you acked this).

> I'm simply lost in the number of iterations for this patch. Also I do
> not think that reducing the duplication in the library test is that
> important, but feel free to push that with my reviewed-by as well.

Thanks, merged with that extra commit.

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v6 1/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-04-05 10:28                   ` Petr Vorel
@ 2024-04-05 11:23                     ` Cyril Hrubis
  2024-04-05 14:03                       ` Petr Vorel
  0 siblings, 1 reply; 40+ messages in thread
From: Cyril Hrubis @ 2024-04-05 11:23 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi!
Also is anybody going to work on the PASS variant? Looks like the huge*
tests would need that...

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v6 1/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-04-05 11:23                     ` Cyril Hrubis
@ 2024-04-05 14:03                       ` Petr Vorel
  2024-04-07 23:31                         ` Wei Gao via ltp
  0 siblings, 1 reply; 40+ messages in thread
From: Petr Vorel @ 2024-04-05 14:03 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril, Wei,

merged with the cleanup commit before.

> Hi!
> Also is anybody going to work on the PASS variant? Looks like the huge*
> tests would need that...

@Wei I suppose you plan to work on it. If not, please let us know.

Kind regards,
Petr

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

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

* Re: [LTP] [PATCH v6 1/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID}
  2024-04-05 14:03                       ` Petr Vorel
@ 2024-04-07 23:31                         ` Wei Gao via ltp
  0 siblings, 0 replies; 40+ messages in thread
From: Wei Gao via ltp @ 2024-04-07 23:31 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

On Fri, Apr 05, 2024 at 04:03:25PM +0200, Petr Vorel wrote:
> Hi Cyril, Wei,
> 
> merged with the cleanup commit before.
> 
> > Hi!
> > Also is anybody going to work on the PASS variant? Looks like the huge*
> > tests would need that...
> 
> @Wei I suppose you plan to work on it. If not, please let us know.
Sure, i will work on this.
> 
> Kind regards,
> Petr

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

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

end of thread, other threads:[~2024-04-07 23:32 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-11  1:26 [LTP] [PATCH v1] Add TST_EXP_FAIL_PTR Wei Gao via ltp
2024-01-16 17:49 ` Petr Vorel
2024-01-17  8:07   ` Wei Gao via ltp
2024-01-17  8:04 ` [LTP] [PATCH v2] " Wei Gao via ltp
2024-01-17  9:49   ` Petr Vorel
2024-01-30 12:21     ` Petr Vorel
2024-01-17 12:52   ` [LTP] [PATCH v3 0/2] lib: TST_EXP_FAIL_PTR Wei Gao via ltp
2024-01-17 12:52     ` [LTP] [PATCH v3 1/2] " Wei Gao via ltp
2024-01-23  8:45       ` Petr Vorel
2024-01-23 10:41       ` Cyril Hrubis
2024-01-30 12:20         ` Petr Vorel
2024-01-17 12:52     ` [LTP] [PATCH v3 2/2] getcwd01: Implement .test_variants Wei Gao via ltp
2024-01-23  9:45       ` Petr Vorel
2024-02-08  1:32     ` [LTP] [PATCH v4 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
2024-02-08  1:32       ` [LTP] [PATCH v4 1/3] " Wei Gao via ltp
2024-03-20 10:47         ` Petr Vorel
2024-03-26 10:54         ` Cyril Hrubis
2024-02-08  1:32       ` [LTP] [PATCH v4 2/3] shmat02.c: Use TST_EXP_FAIL_PTR_VOID Wei Gao via ltp
2024-03-20 10:47         ` Petr Vorel
2024-02-08  1:32       ` [LTP] [PATCH v4 3/3] realpath01.c: use TST_EXP_FAIL_PTR_NULL Wei Gao via ltp
2024-03-20 10:47         ` Petr Vorel
2024-03-27  3:49       ` [LTP] [PATCH v5 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
2024-03-27  3:49         ` [LTP] [PATCH v5 1/3] " Wei Gao via ltp
2024-03-28 11:29           ` Petr Vorel
2024-03-28 11:49           ` Petr Vorel
2024-03-28 11:57             ` Petr Vorel
2024-03-28 12:11           ` Petr Vorel
2024-03-27  3:49         ` [LTP] [PATCH v5 2/3] shmat02.c: Use TST_EXP_FAIL_PTR_VOID Wei Gao via ltp
2024-03-27  3:49         ` [LTP] [PATCH v5 3/3] realpath01.c: use TST_EXP_FAIL_PTR_NULL Wei Gao via ltp
2024-04-03  3:28         ` [LTP] [PATCH v6 0/3] lib: TST_EXP_{FAIL,PASS}_PTR_{NULL,VOID} Wei Gao via ltp
2024-04-03  3:28           ` [LTP] [PATCH v6 1/3] " Wei Gao via ltp
2024-04-04 13:51             ` Cyril Hrubis
2024-04-04 16:01               ` Petr Vorel
2024-04-05  8:53                 ` Cyril Hrubis
2024-04-05 10:28                   ` Petr Vorel
2024-04-05 11:23                     ` Cyril Hrubis
2024-04-05 14:03                       ` Petr Vorel
2024-04-07 23:31                         ` Wei Gao via ltp
2024-04-03  3:28           ` [LTP] [PATCH v6 2/3] shmat02.c: Use TST_EXP_FAIL_PTR_VOID Wei Gao via ltp
2024-04-03  3:28           ` [LTP] [PATCH v6 3/3] realpath01.c: use TST_EXP_FAIL_PTR_NULL Wei Gao via ltp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox