* [LTP] [PATCH v1] lib: Add TST_EXP_PASS_PTR_{NULL,VOID} macros
@ 2024-04-15 2:51 Wei Gao via ltp
2024-04-17 8:31 ` Petr Vorel
2024-04-25 2:03 ` [LTP] [PATCH v2 0/3] " Wei Gao via ltp
0 siblings, 2 replies; 11+ messages in thread
From: Wei Gao via ltp @ 2024-04-15 2:51 UTC (permalink / raw)
To: ltp
Signed-off-by: Wei Gao <wegao@suse.com>
---
include/tst_test_macros.h | 41 +++++++++++++++++++++++++
testcases/kernel/syscalls/sbrk/sbrk01.c | 7 +----
2 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index 22b39fb14..2668758fb 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -178,6 +178,28 @@ extern void *TST_RET_PTR;
\
} while (0)
+#define TST_EXP_PASS_SILENT_PTR_(SCALL, SSCALL, FAIL_PTR_VAL, ...) \
+ do { \
+ TESTPTR(SCALL); \
+ \
+ TST_PASS = 0; \
+ \
+ if (TST_RET_PTR == FAIL_PTR_VAL) { \
+ TST_MSG_(TFAIL | TTERRNO, " failed", \
+ SSCALL, ##__VA_ARGS__); \
+ break; \
+ } \
+ \
+ if (TST_RET != 0) { \
+ TST_MSGP_(TFAIL | TTERRNO, " invalid retval %ld", \
+ TST_RET, SSCALL, ##__VA_ARGS__); \
+ break; \
+ } \
+ \
+ TST_PASS = 1; \
+ \
+ } while (0)
+
#define TST_EXP_PASS_SILENT(SCALL, ...) TST_EXP_PASS_SILENT_(SCALL, #SCALL, ##__VA_ARGS__)
#define TST_EXP_PASS(SCALL, ...) \
@@ -188,6 +210,25 @@ extern void *TST_RET_PTR;
TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \
} while (0) \
+#define TST_EXP_PASS_PTR_(SCALL, SSCALL, FAIL_PTR_VAL, ...) \
+ do { \
+ TST_EXP_PASS_SILENT_PTR_(SCALL, SSCALL, \
+ FAIL_PTR_VAL, ##__VA_ARGS__); \
+ \
+ if (TST_PASS) \
+ TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \
+ } while (0)
+
+#define TST_EXP_PASS_PTR_NULL(SCALL, ...) \
+ do { \
+ TST_EXP_PASS_PTR_(SCALL, #SCALL, NULL, ##__VA_ARGS__); \
+ } while (0)
+
+#define TST_EXP_PASS_PTR_VOID(SCALL, ...) \
+ do { \
+ TST_EXP_PASS_PTR_(SCALL, #SCALL, (void *)-1, ##__VA_ARGS__); \
+ } while (0)
+
/*
* Returns true if err is in the exp_err array.
*/
diff --git a/testcases/kernel/syscalls/sbrk/sbrk01.c b/testcases/kernel/syscalls/sbrk/sbrk01.c
index bb78d9a7b..2d2244a35 100644
--- a/testcases/kernel/syscalls/sbrk/sbrk01.c
+++ b/testcases/kernel/syscalls/sbrk/sbrk01.c
@@ -26,12 +26,7 @@ static void run(unsigned int i)
{
struct tcase *tc = &tcases[i];
- TESTPTR(sbrk(tc->increment));
-
- if (TST_RET_PTR == (void *) -1)
- tst_res(TFAIL | TTERRNO, "sbrk(%ld) failed", tc->increment);
- else
- tst_res(TPASS, "sbrk(%ld) returned %p", tc->increment, TST_RET_PTR);
+ TST_EXP_PASS_PTR_VOID(sbrk(tc->increment), "sbrk(%ld) returned %p", tc->increment, TST_RET_PTR);
}
static struct tst_test test = {
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [LTP] [PATCH v1] lib: Add TST_EXP_PASS_PTR_{NULL,VOID} macros 2024-04-15 2:51 [LTP] [PATCH v1] lib: Add TST_EXP_PASS_PTR_{NULL,VOID} macros Wei Gao via ltp @ 2024-04-17 8:31 ` Petr Vorel 2024-04-25 2:03 ` [LTP] [PATCH v2 0/3] " Wei Gao via ltp 1 sibling, 0 replies; 11+ messages in thread From: Petr Vorel @ 2024-04-17 8:31 UTC (permalink / raw) To: Wei Gao; +Cc: ltp Hi Wei, > Signed-off-by: Wei Gao <wegao@suse.com> > --- > include/tst_test_macros.h | 41 +++++++++++++++++++++++++ > testcases/kernel/syscalls/sbrk/sbrk01.c | 7 +---- I would split sbrk01 change into separate commit (generally it's better to separate library change). And you can add also sbrk02. I tried to find test which could use TST_EXP_PASS_PTR_NULL(), but haven't found any. Do we need it? > 2 files changed, 42 insertions(+), 6 deletions(-) > diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h > index 22b39fb14..2668758fb 100644 > --- a/include/tst_test_macros.h > +++ b/include/tst_test_macros.h > @@ -178,6 +178,28 @@ extern void *TST_RET_PTR; > \ > } while (0) > +#define TST_EXP_PASS_SILENT_PTR_(SCALL, SSCALL, FAIL_PTR_VAL, ...) \ > + do { \ > + TESTPTR(SCALL); \ > + \ > + TST_PASS = 0; \ > + \ > + if (TST_RET_PTR == FAIL_PTR_VAL) { \ > + TST_MSG_(TFAIL | TTERRNO, " failed", \ > + SSCALL, ##__VA_ARGS__); \ > + break; \ > + } \ > + \ > + if (TST_RET != 0) { \ > + TST_MSGP_(TFAIL | TTERRNO, " invalid retval %ld", \ > + TST_RET, SSCALL, ##__VA_ARGS__); \ > + break; \ > + } \ > + \ > + TST_PASS = 1; \ > + \ > + } while (0) > + > #define TST_EXP_PASS_SILENT(SCALL, ...) TST_EXP_PASS_SILENT_(SCALL, #SCALL, ##__VA_ARGS__) > #define TST_EXP_PASS(SCALL, ...) \ > @@ -188,6 +210,25 @@ extern void *TST_RET_PTR; > TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \ > } while (0) \ > +#define TST_EXP_PASS_PTR_(SCALL, SSCALL, FAIL_PTR_VAL, ...) \ > + do { \ > + TST_EXP_PASS_SILENT_PTR_(SCALL, SSCALL, \ > + FAIL_PTR_VAL, ##__VA_ARGS__); \ > + \ > + if (TST_PASS) \ > + TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \ > + } while (0) > + > +#define TST_EXP_PASS_PTR_NULL(SCALL, ...) \ > + do { \ > + TST_EXP_PASS_PTR_(SCALL, #SCALL, NULL, ##__VA_ARGS__); \ > + } while (0) > + > +#define TST_EXP_PASS_PTR_VOID(SCALL, ...) \ > + do { \ > + TST_EXP_PASS_PTR_(SCALL, #SCALL, (void *)-1, ##__VA_ARGS__); \ > + } while (0) do { } while is not needed, maybe just (not an error, just code simplification): #define TST_EXP_PASS_PTR_NULL(SCALL, ...) \ TST_EXP_PASS_PTR_(SCALL, #SCALL, NULL, ##__VA_ARGS__) #define TST_EXP_PASS_PTR_VOID(SCALL, ...) \ TST_EXP_PASS_PTR_(SCALL, #SCALL, (void *)-1, ##__VA_ARGS__) Also, the same applies to TST_EXP_FAIL_PTR_NULL_ARR() and TST_EXP_FAIL_PTR_VOID_ARR(). > + > /* > * Returns true if err is in the exp_err array. > */ > diff --git a/testcases/kernel/syscalls/sbrk/sbrk01.c b/testcases/kernel/syscalls/sbrk/sbrk01.c > index bb78d9a7b..2d2244a35 100644 > --- a/testcases/kernel/syscalls/sbrk/sbrk01.c > +++ b/testcases/kernel/syscalls/sbrk/sbrk01.c > @@ -26,12 +26,7 @@ static void run(unsigned int i) > { > struct tcase *tc = &tcases[i]; > - TESTPTR(sbrk(tc->increment)); > - > - if (TST_RET_PTR == (void *) -1) > - tst_res(TFAIL | TTERRNO, "sbrk(%ld) failed", tc->increment); > - else > - tst_res(TPASS, "sbrk(%ld) returned %p", tc->increment, TST_RET_PTR); > + TST_EXP_PASS_PTR_VOID(sbrk(tc->increment), "sbrk(%ld) returned %p", tc->increment, TST_RET_PTR); Too long line, it's be better to split. Kind regards, Petr -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 11+ messages in thread
* [LTP] [PATCH v2 0/3] lib: Add TST_EXP_PASS_PTR_{NULL,VOID} macros 2024-04-15 2:51 [LTP] [PATCH v1] lib: Add TST_EXP_PASS_PTR_{NULL,VOID} macros Wei Gao via ltp 2024-04-17 8:31 ` Petr Vorel @ 2024-04-25 2:03 ` Wei Gao via ltp 2024-04-25 2:03 ` [LTP] [PATCH v2 1/3] " Wei Gao via ltp ` (3 more replies) 1 sibling, 4 replies; 11+ messages in thread From: Wei Gao via ltp @ 2024-04-25 2:03 UTC (permalink / raw) To: ltp Wei Gao (3): lib: Add TST_EXP_PASS_PTR_{NULL,VOID} macros sbrk01.c: Use TST_EXP_PASS_PTR_VOID sbrk02.c: Use TST_EXP_FAIL_PTR_VOID include/tst_test_macros.h | 45 +++++++++++++++++++++---- testcases/kernel/syscalls/sbrk/sbrk01.c | 8 ++--- testcases/kernel/syscalls/sbrk/sbrk02.c | 17 ++-------- 3 files changed, 43 insertions(+), 27 deletions(-) -- 2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 11+ messages in thread
* [LTP] [PATCH v2 1/3] lib: Add TST_EXP_PASS_PTR_{NULL,VOID} macros 2024-04-25 2:03 ` [LTP] [PATCH v2 0/3] " Wei Gao via ltp @ 2024-04-25 2:03 ` Wei Gao via ltp 2024-04-25 11:40 ` [LTP] [PATCH v2 1/3] lib: Add TST_EXP_PASS_PTR_{NULL, VOID} macros Petr Vorel 2024-04-25 2:03 ` [LTP] [PATCH v2 2/3] sbrk01.c: Use TST_EXP_PASS_PTR_VOID Wei Gao via ltp ` (2 subsequent siblings) 3 siblings, 1 reply; 11+ messages in thread From: Wei Gao via ltp @ 2024-04-25 2:03 UTC (permalink / raw) To: ltp Signed-off-by: Wei Gao <wegao@suse.com> --- include/tst_test_macros.h | 45 +++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h index 22b39fb14..1fb133dd3 100644 --- a/include/tst_test_macros.h +++ b/include/tst_test_macros.h @@ -178,6 +178,28 @@ extern void *TST_RET_PTR; \ } while (0) +#define TST_EXP_PASS_SILENT_PTR_(SCALL, SSCALL, FAIL_PTR_VAL, ...) \ + do { \ + TESTPTR(SCALL); \ + \ + TST_PASS = 0; \ + \ + if (TST_RET_PTR == FAIL_PTR_VAL) { \ + TST_MSG_(TFAIL | TTERRNO, " failed", \ + SSCALL, ##__VA_ARGS__); \ + break; \ + } \ + \ + if (TST_RET != 0) { \ + TST_MSGP_(TFAIL | TTERRNO, " invalid retval %ld", \ + TST_RET, SSCALL, ##__VA_ARGS__); \ + break; \ + } \ + \ + TST_PASS = 1; \ + \ + } while (0) + #define TST_EXP_PASS_SILENT(SCALL, ...) TST_EXP_PASS_SILENT_(SCALL, #SCALL, ##__VA_ARGS__) #define TST_EXP_PASS(SCALL, ...) \ @@ -188,6 +210,21 @@ extern void *TST_RET_PTR; TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \ } while (0) \ +#define TST_EXP_PASS_PTR_(SCALL, SSCALL, FAIL_PTR_VAL, ...) \ + do { \ + TST_EXP_PASS_SILENT_PTR_(SCALL, SSCALL, \ + FAIL_PTR_VAL, ##__VA_ARGS__); \ + \ + if (TST_PASS) \ + TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \ + } while (0) + +#define TST_EXP_PASS_PTR_NULL(SCALL, ...) \ + TST_EXP_PASS_PTR_(SCALL, #SCALL, NULL, ##__VA_ARGS__); + +#define TST_EXP_PASS_PTR_VOID(SCALL, ...) \ + TST_EXP_PASS_PTR_(SCALL, #SCALL, (void *)-1, ##__VA_ARGS__); + /* * Returns true if err is in the exp_err array. */ @@ -301,10 +338,8 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt); } while (0) #define TST_EXP_FAIL_PTR_NULL_ARR(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...) \ - do { \ TST_EXP_FAIL_PTR_(SCALL, #SCALL, NULL, \ - EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__); \ - } while (0) + EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__); #define TST_EXP_FAIL_PTR_VOID(SCALL, EXP_ERR, ...) \ do { \ @@ -314,10 +349,8 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt); } while (0) #define TST_EXP_FAIL_PTR_VOID_ARR(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...) \ - do { \ TST_EXP_FAIL_PTR_(SCALL, #SCALL, (void *)-1, \ - EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__); \ - } while (0) + EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__); #define TST_EXP_FAIL2(SCALL, EXP_ERR, ...) \ do { \ -- 2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH v2 1/3] lib: Add TST_EXP_PASS_PTR_{NULL, VOID} macros 2024-04-25 2:03 ` [LTP] [PATCH v2 1/3] " Wei Gao via ltp @ 2024-04-25 11:40 ` Petr Vorel 2024-04-29 17:51 ` Avinesh Kumar 0 siblings, 1 reply; 11+ messages in thread From: Petr Vorel @ 2024-04-25 11:40 UTC (permalink / raw) To: Wei Gao; +Cc: ltp Hi Wei, > Signed-off-by: Wei Gao <wegao@suse.com> > --- > include/tst_test_macros.h | 45 +++++++++++++++++++++++++++++++++------ > 1 file changed, 39 insertions(+), 6 deletions(-) > diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h > index 22b39fb14..1fb133dd3 100644 > --- a/include/tst_test_macros.h > +++ b/include/tst_test_macros.h > @@ -178,6 +178,28 @@ extern void *TST_RET_PTR; > \ > } while (0) > +#define TST_EXP_PASS_SILENT_PTR_(SCALL, SSCALL, FAIL_PTR_VAL, ...) \ > + do { \ > + TESTPTR(SCALL); \ > + \ > + TST_PASS = 0; \ > + \ > + if (TST_RET_PTR == FAIL_PTR_VAL) { \ > + TST_MSG_(TFAIL | TTERRNO, " failed", \ > + SSCALL, ##__VA_ARGS__); \ > + break; \ > + } \ > + \ > + if (TST_RET != 0) { \ > + TST_MSGP_(TFAIL | TTERRNO, " invalid retval %ld", \ > + TST_RET, SSCALL, ##__VA_ARGS__); \ > + break; \ > + } \ > + \ > + TST_PASS = 1; \ > + \ > + } while (0) > + > #define TST_EXP_PASS_SILENT(SCALL, ...) TST_EXP_PASS_SILENT_(SCALL, #SCALL, ##__VA_ARGS__) > #define TST_EXP_PASS(SCALL, ...) \ > @@ -188,6 +210,21 @@ extern void *TST_RET_PTR; > TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \ > } while (0) \ > +#define TST_EXP_PASS_PTR_(SCALL, SSCALL, FAIL_PTR_VAL, ...) \ > + do { \ > + TST_EXP_PASS_SILENT_PTR_(SCALL, SSCALL, \ > + FAIL_PTR_VAL, ##__VA_ARGS__); \ > + \ > + if (TST_PASS) \ > + TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \ > + } while (0) > + > +#define TST_EXP_PASS_PTR_NULL(SCALL, ...) \ > + TST_EXP_PASS_PTR_(SCALL, #SCALL, NULL, ##__VA_ARGS__); I'm still not sure whether add TST_EXP_PASS_PTR_NULL, which is not used. I wonder what others think (it can be removed before merge). > + > +#define TST_EXP_PASS_PTR_VOID(SCALL, ...) \ > + TST_EXP_PASS_PTR_(SCALL, #SCALL, (void *)-1, ##__VA_ARGS__); > + > /* > * Returns true if err is in the exp_err array. > */ > @@ -301,10 +338,8 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt); > } while (0) > #define TST_EXP_FAIL_PTR_NULL_ARR(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...) \ > - do { \ > TST_EXP_FAIL_PTR_(SCALL, #SCALL, NULL, \ > - EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__); \ > - } while (0) > + EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__); +1 > #define TST_EXP_FAIL_PTR_VOID(SCALL, EXP_ERR, ...) \ > do { \ > @@ -314,10 +349,8 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt); > } while (0) > #define TST_EXP_FAIL_PTR_VOID_ARR(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...) \ > - do { \ > TST_EXP_FAIL_PTR_(SCALL, #SCALL, (void *)-1, \ > - EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__); \ > - } while (0) > + EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__); +1 Reviewed-by: Petr Vorel <pvorel@suse.cz> Kind regards, Petr > #define TST_EXP_FAIL2(SCALL, EXP_ERR, ...) \ > do { \ -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH v2 1/3] lib: Add TST_EXP_PASS_PTR_{NULL, VOID} macros 2024-04-25 11:40 ` [LTP] [PATCH v2 1/3] lib: Add TST_EXP_PASS_PTR_{NULL, VOID} macros Petr Vorel @ 2024-04-29 17:51 ` Avinesh Kumar 0 siblings, 0 replies; 11+ messages in thread From: Avinesh Kumar @ 2024-04-29 17:51 UTC (permalink / raw) To: Wei Gao, Wei Gao; +Cc: ltp On Thursday, April 25, 2024 1:40:13 PM GMT+2 Petr Vorel wrote: > Hi Wei, > > > Signed-off-by: Wei Gao <wegao@suse.com> > > --- > > > > include/tst_test_macros.h | 45 +++++++++++++++++++++++++++++++++------ > > 1 file changed, 39 insertions(+), 6 deletions(-) > > > > diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h > > index 22b39fb14..1fb133dd3 100644 > > --- a/include/tst_test_macros.h > > +++ b/include/tst_test_macros.h > > @@ -178,6 +178,28 @@ extern void *TST_RET_PTR; > > > > \ > > > > } while (0) > > > > +#define TST_EXP_PASS_SILENT_PTR_(SCALL, SSCALL, FAIL_PTR_VAL, ...) > > \ + do { > > \ + TESTPTR(SCALL); > > \ + \ > > + TST_PASS = 0; \ + > > \ + if > > (TST_RET_PTR == FAIL_PTR_VAL) { \ > > + TST_MSG_(TFAIL | TTERRNO, " failed", \ > > + SSCALL, ##__VA_ARGS__); \ > > + break; \ > > + } \ > > + \ > > + if (TST_RET != 0) { \ > > + TST_MSGP_(TFAIL | TTERRNO, " invalid retval %ld", \ > > + TST_RET, SSCALL, ##__VA_ARGS__); \ > > + break; \ > > + } \ > > + > > \ + TST_PASS = 1; > > \ + > > \ + } while (0) > > + > > > > #define TST_EXP_PASS_SILENT(SCALL, ...) TST_EXP_PASS_SILENT_(SCALL, > > #SCALL, ##__VA_ARGS__) > > > > #define TST_EXP_PASS(SCALL, ...) > > \> > > @@ -188,6 +210,21 @@ extern void *TST_RET_PTR; > > > > TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \ > > > > } while (0) \ > > > > +#define TST_EXP_PASS_PTR_(SCALL, SSCALL, FAIL_PTR_VAL, ...) > > \ + do { > > \ + TST_EXP_PASS_SILENT_PTR_(SCALL, SSCALL, > > \ + FAIL_PTR_VAL, ##__VA_ARGS__); \ > > + \ > > + if (TST_PASS) \ > > + TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \ > > + } while (0) > > + > > +#define TST_EXP_PASS_PTR_NULL(SCALL, ...) > > \ + TST_EXP_PASS_PTR_(SCALL, #SCALL, NULL, > > ##__VA_ARGS__); > I'm still not sure whether add TST_EXP_PASS_PTR_NULL, which is not used. > I wonder what others think (it can be removed before merge). I too think we should add this macro only with another patch where it is being used. Also, I want to mention I find these macro names a little bit confusing. We have TST_EXP_FAIL_PTR_VOID(), which expects a syscall to fail and return (void *) -1. so maybe we should name TST_EXP_PASS_PTR_NONVOID() for expecting a syscall to pass and return any pointer value != (void *) -1. If it is just me confused with these names, please disregard this comment. > > > + > > +#define TST_EXP_PASS_PTR_VOID(SCALL, ...) > > \ + TST_EXP_PASS_PTR_(SCALL, #SCALL, (void *)-1, > > ##__VA_ARGS__); + > > > > /* > > > > * Returns true if err is in the exp_err array. > > */ > > > > @@ -301,10 +338,8 @@ const char *tst_errno_names(char *buf, const int > > *exp_errs, int exp_errs_cnt);> > > } while (0) > > > > #define TST_EXP_FAIL_PTR_NULL_ARR(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...) > > \> > > - do { \ > > > > TST_EXP_FAIL_PTR_(SCALL, #SCALL, NULL, \ > > > > - EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__); \ > > - } while (0) > > + EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__); > > +1 > > > #define TST_EXP_FAIL_PTR_VOID(SCALL, EXP_ERR, ...) > > \> > > do { \ > > > > @@ -314,10 +349,8 @@ const char *tst_errno_names(char *buf, const int > > *exp_errs, int exp_errs_cnt);> > > } while (0) > > > > #define TST_EXP_FAIL_PTR_VOID_ARR(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...) > > \> > > - do { \ > > > > TST_EXP_FAIL_PTR_(SCALL, #SCALL, (void *)-1, \ > > > > - EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__); \ > > - } while (0) > > + EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__); > > +1 > > Reviewed-by: Petr Vorel <pvorel@suse.cz> > > Kind regards, > Petr > > > #define TST_EXP_FAIL2(SCALL, EXP_ERR, ...) > > \> > > do { \ Regards, Avinesh -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 11+ messages in thread
* [LTP] [PATCH v2 2/3] sbrk01.c: Use TST_EXP_PASS_PTR_VOID 2024-04-25 2:03 ` [LTP] [PATCH v2 0/3] " Wei Gao via ltp 2024-04-25 2:03 ` [LTP] [PATCH v2 1/3] " Wei Gao via ltp @ 2024-04-25 2:03 ` Wei Gao via ltp 2024-04-25 11:42 ` Petr Vorel 2024-04-25 2:03 ` [LTP] [PATCH v2 3/3] sbrk02.c: Use TST_EXP_FAIL_PTR_VOID Wei Gao via ltp 2025-01-14 13:42 ` [LTP] [PATCH v2 0/3] lib: Add TST_EXP_PASS_PTR_{NULL, VOID} macros Andrea Cervesato via ltp 3 siblings, 1 reply; 11+ messages in thread From: Wei Gao via ltp @ 2024-04-25 2:03 UTC (permalink / raw) To: ltp Signed-off-by: Wei Gao <wegao@suse.com> --- testcases/kernel/syscalls/sbrk/sbrk01.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/testcases/kernel/syscalls/sbrk/sbrk01.c b/testcases/kernel/syscalls/sbrk/sbrk01.c index bb78d9a7b..39e92094b 100644 --- a/testcases/kernel/syscalls/sbrk/sbrk01.c +++ b/testcases/kernel/syscalls/sbrk/sbrk01.c @@ -26,12 +26,8 @@ static void run(unsigned int i) { struct tcase *tc = &tcases[i]; - TESTPTR(sbrk(tc->increment)); - - if (TST_RET_PTR == (void *) -1) - tst_res(TFAIL | TTERRNO, "sbrk(%ld) failed", tc->increment); - else - tst_res(TPASS, "sbrk(%ld) returned %p", tc->increment, TST_RET_PTR); + TST_EXP_PASS_PTR_VOID(sbrk(tc->increment), + "sbrk(%ld) returned %p", tc->increment, TST_RET_PTR); } static struct tst_test test = { -- 2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH v2 2/3] sbrk01.c: Use TST_EXP_PASS_PTR_VOID 2024-04-25 2:03 ` [LTP] [PATCH v2 2/3] sbrk01.c: Use TST_EXP_PASS_PTR_VOID Wei Gao via ltp @ 2024-04-25 11:42 ` Petr Vorel 0 siblings, 0 replies; 11+ messages in thread From: Petr Vorel @ 2024-04-25 11:42 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] 11+ messages in thread
* [LTP] [PATCH v2 3/3] sbrk02.c: Use TST_EXP_FAIL_PTR_VOID 2024-04-25 2:03 ` [LTP] [PATCH v2 0/3] " Wei Gao via ltp 2024-04-25 2:03 ` [LTP] [PATCH v2 1/3] " Wei Gao via ltp 2024-04-25 2:03 ` [LTP] [PATCH v2 2/3] sbrk01.c: Use TST_EXP_PASS_PTR_VOID Wei Gao via ltp @ 2024-04-25 2:03 ` Wei Gao via ltp 2024-04-25 11:44 ` Petr Vorel 2025-01-14 13:42 ` [LTP] [PATCH v2 0/3] lib: Add TST_EXP_PASS_PTR_{NULL, VOID} macros Andrea Cervesato via ltp 3 siblings, 1 reply; 11+ messages in thread From: Wei Gao via ltp @ 2024-04-25 2:03 UTC (permalink / raw) To: ltp Signed-off-by: Wei Gao <wegao@suse.com> --- testcases/kernel/syscalls/sbrk/sbrk02.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/testcases/kernel/syscalls/sbrk/sbrk02.c b/testcases/kernel/syscalls/sbrk/sbrk02.c index dc344577e..08cbdf367 100644 --- a/testcases/kernel/syscalls/sbrk/sbrk02.c +++ b/testcases/kernel/syscalls/sbrk/sbrk02.c @@ -19,21 +19,8 @@ static long increment = INC; static void run(void) { - TESTPTR(sbrk(increment)); - - if (TST_RET_PTR != (void *)-1) { - tst_res(TFAIL, "sbrk(%ld) unexpectedly passed and returned %p, " - "expected (void *)-1 with errno=%d", - increment, TST_RET_PTR, ENOMEM); - return; - } - - if (TST_ERR == ENOMEM) - tst_res(TPASS | TTERRNO, "sbrk(%ld) failed as expected", increment); - else - tst_res(TFAIL | TTERRNO, "sbrk(%ld) failed but unexpected errno, " - "expected errno=%d - %s", - increment, ENOMEM, strerror(ENOMEM)); + TST_EXP_FAIL_PTR_VOID(sbrk(increment), ENOMEM, + "sbrk(%ld) returned %p", increment, TST_RET_PTR); } static void setup(void) -- 2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [LTP] [PATCH v2 3/3] sbrk02.c: Use TST_EXP_FAIL_PTR_VOID 2024-04-25 2:03 ` [LTP] [PATCH v2 3/3] sbrk02.c: Use TST_EXP_FAIL_PTR_VOID Wei Gao via ltp @ 2024-04-25 11:44 ` Petr Vorel 0 siblings, 0 replies; 11+ messages in thread From: Petr Vorel @ 2024-04-25 11:44 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] 11+ messages in thread
* Re: [LTP] [PATCH v2 0/3] lib: Add TST_EXP_PASS_PTR_{NULL, VOID} macros 2024-04-25 2:03 ` [LTP] [PATCH v2 0/3] " Wei Gao via ltp ` (2 preceding siblings ...) 2024-04-25 2:03 ` [LTP] [PATCH v2 3/3] sbrk02.c: Use TST_EXP_FAIL_PTR_VOID Wei Gao via ltp @ 2025-01-14 13:42 ` Andrea Cervesato via ltp 3 siblings, 0 replies; 11+ messages in thread From: Andrea Cervesato via ltp @ 2025-01-14 13:42 UTC (permalink / raw) To: ltp Hi, pushed! Andrea On 4/25/24 04:03, Wei Gao via ltp wrote: > Wei Gao (3): > lib: Add TST_EXP_PASS_PTR_{NULL,VOID} macros > sbrk01.c: Use TST_EXP_PASS_PTR_VOID > sbrk02.c: Use TST_EXP_FAIL_PTR_VOID > > include/tst_test_macros.h | 45 +++++++++++++++++++++---- > testcases/kernel/syscalls/sbrk/sbrk01.c | 8 ++--- > testcases/kernel/syscalls/sbrk/sbrk02.c | 17 ++-------- > 3 files changed, 43 insertions(+), 27 deletions(-) > -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-01-14 13:43 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-15 2:51 [LTP] [PATCH v1] lib: Add TST_EXP_PASS_PTR_{NULL,VOID} macros Wei Gao via ltp
2024-04-17 8:31 ` Petr Vorel
2024-04-25 2:03 ` [LTP] [PATCH v2 0/3] " Wei Gao via ltp
2024-04-25 2:03 ` [LTP] [PATCH v2 1/3] " Wei Gao via ltp
2024-04-25 11:40 ` [LTP] [PATCH v2 1/3] lib: Add TST_EXP_PASS_PTR_{NULL, VOID} macros Petr Vorel
2024-04-29 17:51 ` Avinesh Kumar
2024-04-25 2:03 ` [LTP] [PATCH v2 2/3] sbrk01.c: Use TST_EXP_PASS_PTR_VOID Wei Gao via ltp
2024-04-25 11:42 ` Petr Vorel
2024-04-25 2:03 ` [LTP] [PATCH v2 3/3] sbrk02.c: Use TST_EXP_FAIL_PTR_VOID Wei Gao via ltp
2024-04-25 11:44 ` Petr Vorel
2025-01-14 13:42 ` [LTP] [PATCH v2 0/3] lib: Add TST_EXP_PASS_PTR_{NULL, VOID} macros Andrea Cervesato via ltp
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.