Skip to contentSkip to conversation

lib: Add TST_EXP_PASS_PTR_{NULL,VOID} macros

PATCH Superseded Wei Gao via ltp 3 participants 11 messages Apr 15, 2024 – Jan 14, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: Add TST_EXP_PASS_PTR_{NULL,VOID} macros

---
 include/tst_test_macros.h               | 41 +++++++++++++++++++++++++
 testcases/kernel/syscalls/sbrk/sbrk01.c |  7 +----
 2 files changed, 42 insertions(+), 6 deletions(-)
include/tst_test_macros.h +41 -0
index 22b39fb14..2668758fb 100644
@@ -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.
  */
testcases/kernel/syscalls/sbrk/sbrk01.c +1 -6
index bb78d9a7b..2d2244a35 100644
@@ -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 = {
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Wei,

Quoted 4 lines
---
 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?

Quoted 47 lines
 2 files changed, 42 insertions(+), 6 deletions(-)
include/tst_test_macros.h +30 -0
index 22b39fb14..2668758fb 100644
@@ -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)

include/tst_test_macros.h extern void *TST_RET_PTR; · line 230

Quoted 10 lines
include/tst_test_macros.h +10 -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().

Quoted 9 lines
include/tst_test_macros.h +1 -0
+
 /*
  * Returns true if err is in the exp_err array.
  */
testcases/kernel/syscalls/sbrk/sbrk01.c +0 -0
index bb78d9a7b..2d2244a35 100644

testcases/kernel/syscalls/sbrk/sbrk01.c static void run(unsigned int i) · line 29

Quoted 10 lines
testcases/kernel/syscalls/sbrk/sbrk01.c +1 -6
@@ -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

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

v2 cover lib: Add TST_EXP_PASS_PTR_{NULL,VOID} macros

In reply to Wei Gao via 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(-)
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

PATCH v2 1/3 lib: Add TST_EXP_PASS_PTR_{NULL,VOID} macros

---
 include/tst_test_macros.h | 45 +++++++++++++++++++++++++++++++++------
 1 file changed, 39 insertions(+), 6 deletions(-)
include/tst_test_macros.h +39 -6
index 22b39fb14..1fb133dd3 100644
@@ -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 {                                                                   \
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v2 1/3
#4 lore raw

Re: [LTP] [PATCH v2 1/3] lib: Add TST_EXP_PASS_PTR_{NULL, VOID} macros

Hi Wei,

Quoted 43 lines
---
 include/tst_test_macros.h | 45 +++++++++++++++++++++++++++++++++------
 1 file changed, 39 insertions(+), 6 deletions(-)
include/tst_test_macros.h +23 -0
index 22b39fb14..1fb133dd3 100644
@@ -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, ...)                    \

include/tst_test_macros.h extern void *TST_RET_PTR; · line 223

Quoted 10 lines
include/tst_test_macros.h +10 -0
+	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).

Quoted 8 lines
include/tst_test_macros.h +4 -0
+
+#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.
  */

include/tst_test_macros.h const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt); · line 342

Quoted 8 lines
include/tst_test_macros.h +1 -3
@@ -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

include/tst_test_macros.h const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt); · line 353

Quoted 11 lines
include/tst_test_macros.h +1 -3
 #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

Kind regards,
Petr

Quoted 2 lines
include/tst_test_macros.h +0 -0
 #define TST_EXP_FAIL2(SCALL, EXP_ERR, ...)                                     \
 	do {                                                                   \
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

Re: [LTP] [PATCH v2 1/3] lib: Add TST_EXP_PASS_PTR_{NULL, VOID} macros

Quoted 52 lines · On Thursday, April 25, 2024 1:40:13 PM GMT+2 Petr Vorel wrote:

Hi Wei,

Quoted 50 lines

---

 include/tst_test_macros.h | 45 +++++++++++++++++++++++++++++++++------
 1 file changed, 39 insertions(+), 6 deletions(-)
include/tst_test_macros.h +1 -0
index 22b39fb14..1fb133dd3 100644
@@ -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);                                               

\ + \

include/tst_test_macros.h +1 -0
+		TST_PASS = 0;                                                  \ +		  
                                                            \ +		if

(TST_RET_PTR == FAIL_PTR_VAL) { \

include/tst_test_macros.h +11 -0
+			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)
include/tst_test_macros.h +1 -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)                                                            \
 
Quoted 14 lines
Quoted 11 lines
include/tst_test_macros.h +1 -0
+#define TST_EXP_PASS_PTR_(SCALL, SSCALL, FAIL_PTR_VAL, ...)              
     \ +	do {                                                            
      \ +		TST_EXP_PASS_SILENT_PTR_(SCALL, SSCALL,                       

\ + FAIL_PTR_VAL, ##__VA_ARGS__); \

include/tst_test_macros.h +6 -0
+		                                                               \
+		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,
Quoted 1 line

##__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.

Quoted 47 lines
Quoted 14 lines
include/tst_test_macros.h +2 -0
+
+#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.
*/

include/tst_test_macros.h +0 -0
@@ -301,10 +338,8 @@ const char *tst_errno_names(char *buf, const int
 *exp_errs, int exp_errs_cnt);> 
 	} while (0)

include/tst_test_macros.h const char *tst_errno_names(char *buf, const int

Quoted 10 lines
include/tst_test_macros.h +1 -3
 
 #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

Quoted 7 lines

#define TST_EXP_FAIL_PTR_VOID(SCALL, EXP_ERR, ...)
\>

include/tst_test_macros.h +0 -0
 	do {                                                                   \
@@ -314,10 +349,8 @@ const char *tst_errno_names(char *buf, const int
 *exp_errs, int exp_errs_cnt);> 
 	} while (0)

include/tst_test_macros.h const char *tst_errno_names(char *buf, const int

Quoted 10 lines
include/tst_test_macros.h +1 -3
 
 #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

Quoted 8 lines

Kind regards,
Petr

Quoted 3 lines
 #define TST_EXP_FAIL2(SCALL, EXP_ERR, ...)                               
      \>  

do { \

Regards,
Avinesh

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

PATCH v2 2/3 sbrk01.c: Use TST_EXP_PASS_PTR_VOID

In reply to Wei Gao via ltp
---
 testcases/kernel/syscalls/sbrk/sbrk01.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
testcases/kernel/syscalls/sbrk/sbrk01.c +2 -6
index bb78d9a7b..39e92094b 100644
@@ -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 = {
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v2 2/3
#7 lore raw

Re: [LTP] [PATCH v2 2/3] sbrk01.c: Use TST_EXP_PASS_PTR_VOID

Hi Wei,

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#8 lore raw

PATCH v2 3/3 sbrk02.c: Use TST_EXP_FAIL_PTR_VOID

In reply to Wei Gao via ltp
---
 testcases/kernel/syscalls/sbrk/sbrk02.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)
testcases/kernel/syscalls/sbrk/sbrk02.c +2 -15
index dc344577e..08cbdf367 100644
@@ -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)
Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v2 3/3
#9 lore raw

Re: [LTP] [PATCH v2 3/3] sbrk02.c: Use TST_EXP_FAIL_PTR_VOID

Hi Wei,

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#10 lore raw

Re: [LTP] [PATCH v2 0/3] lib: Add TST_EXP_PASS_PTR_{NULL, VOID} macros

In reply to Wei Gao via ltp

Hi,

pushed!

Andrea

Quoted 10 lines · Wei Gao via 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(-)
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp