All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] tst_test_macros.h: Add TST_EXP_VAL macro
@ 2021-08-27  2:30 zhanglianjie
  2021-08-27  9:27 ` Li Wang
  0 siblings, 1 reply; 3+ messages in thread
From: zhanglianjie @ 2021-08-27  2:30 UTC (permalink / raw)
  To: ltp

Add TST_EXP_VAL to determine whether the return value
is equal to the given value.

Signed-off-by: zhanglianjie <zhanglianjie@uniontech.com>

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index 50598aa15..d23455362 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -132,6 +132,34 @@ extern void *TST_RET_PTR;
 			TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__);     \
 	} while (0)                                                            \

+
+#define TST_EXP_VAL_SILENT_(SCALL, SSCALL, VAL, ...)                    \
+	do {                                                                \
+		TEST(SCALL);                                                    \
+                                                                        \
+		TST_PASS = 0;                                                   \
+                                                                        \
+		if (TST_RET != VAL) {                                           \
+			TST_MSGP_(TFAIL | TTERRNO, " retval not %ld",               \
+			          (long )VAL, SSCALL, ##__VA_ARGS__);               \
+			break;                                                      \
+		}                                                               \
+                                                                        \
+		TST_PASS = 1;                                                   \
+                                                                        \
+	} while (0)
+
+#define TST_EXP_VAL_SILENT(SCALL, VAL, ...) TST_EXP_VAL_SILENT_(SCALL, #SCALL, VAL, ##__VA_ARGS__)
+
+#define TST_EXP_VAL(SCALL, VAL, ...)                                    \
+	do {                                                                \
+		TST_EXP_VAL_SILENT(SCALL, VAL, ##__VA_ARGS__);                  \
+                                                                        \
+		if (TST_PASS)                                                   \
+			TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__);          \
+                                                                        \
+	} while(0)
+
 #define TST_EXP_FAIL_(PASS_COND, SCALL, SSCALL, ERRNO, ...)                    \
 	do {                                                                   \
 		TEST(SCALL);                                                   \
--
2.20.1




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

* [LTP] [PATCH] tst_test_macros.h: Add TST_EXP_VAL macro
  2021-08-27  2:30 [LTP] [PATCH] tst_test_macros.h: Add TST_EXP_VAL macro zhanglianjie
@ 2021-08-27  9:27 ` Li Wang
  2021-08-30  6:35   ` zhanglianjie
  0 siblings, 1 reply; 3+ messages in thread
From: Li Wang @ 2021-08-27  9:27 UTC (permalink / raw)
  To: ltp

Hi Lianjie,

Some queries:

Do we have test scenarios for making use of these macros?

And can you write a test to verify the macros you added at the same time?
(just like what we had done in test_macros0*.c)

Btw, you should keep the code indent consistent with the original.
(especially for backlash \)


On Fri, Aug 27, 2021 at 10:31 AM zhanglianjie <zhanglianjie@uniontech.com>
wrote:

> Add TST_EXP_VAL to determine whether the return value
> is equal to the given value.
>
> Signed-off-by: zhanglianjie <zhanglianjie@uniontech.com>
>
> diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
> index 50598aa15..d23455362 100644
> --- a/include/tst_test_macros.h
> +++ b/include/tst_test_macros.h
> @@ -132,6 +132,34 @@ extern void *TST_RET_PTR;
>                         TST_MSG_(TPASS, " passed", #SCALL,
> ##__VA_ARGS__);     \
>         } while (0)
>     \
>
> +
> +#define TST_EXP_VAL_SILENT_(SCALL, SSCALL, VAL, ...)                    \
> +       do {
>   \
> +               TEST(SCALL);
>       \
> +                                                                        \
> +               TST_PASS = 0;
>      \
> +                                                                        \
> +               if (TST_RET != VAL) {
>      \
> +                       TST_MSGP_(TFAIL | TTERRNO, " retval not %ld",
>          \
> +                                 (long )VAL, SSCALL, ##__VA_ARGS__);
>          \
> +                       break;
>           \
> +               }
>      \
> +                                                                        \
> +               TST_PASS = 1;
>      \
> +                                                                        \
> +       } while (0)
> +
> +#define TST_EXP_VAL_SILENT(SCALL, VAL, ...) TST_EXP_VAL_SILENT_(SCALL,
> #SCALL, VAL, ##__VA_ARGS__)
> +
> +#define TST_EXP_VAL(SCALL, VAL, ...)                                    \
> +       do {
>   \
> +               TST_EXP_VAL_SILENT(SCALL, VAL, ##__VA_ARGS__);
>       \
> +                                                                        \
> +               if (TST_PASS)
>      \
> +                       TST_MSG_(TPASS, " passed", #SCALL,
> ##__VA_ARGS__);          \
> +                                                                        \
> +       } while(0)
> +
>  #define TST_EXP_FAIL_(PASS_COND, SCALL, SSCALL, ERRNO, ...)
>       \
>         do {
>      \
>                 TEST(SCALL);
>      \
> --
> 2.20.1
>
>
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210827/0939a580/attachment-0001.htm>

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

* [LTP] [PATCH] tst_test_macros.h: Add TST_EXP_VAL macro
  2021-08-27  9:27 ` Li Wang
@ 2021-08-30  6:35   ` zhanglianjie
  0 siblings, 0 replies; 3+ messages in thread
From: zhanglianjie @ 2021-08-30  6:35 UTC (permalink / raw)
  To: ltp

Hi,

For example, it is necessary to determine whether TST_RET and child_pid 
are equal :

TST_EXP_POSITIVE(ltp_clone(SIGCHLD, child_fn, NULL, CHILD_STACK_SIZE, 
 

               child_stack));

TST_EXP_PASS(!(TST_RET == child_pid), "pid(%d)", child_pid);

Can be changed to:

TST_EXP_VAL(TST_RET, child_pid);



On 2021-08-27 17:27, Li Wang wrote:
> Hi Lianjie,
> 
> Some queries:
> 
> Do we have test scenarios?for making use of these macros?
> 
> And can you write a test to verify the macros you added at the same time?
> (just like what we had done in test_macros0*.c)
> 
> Btw, you should keep the code indent consistent with the original.
> (especially for backlash \)
I will resubmit and add a test_macros0*.c.
> 
> 
> On Fri, Aug 27, 2021 at 10:31 AM zhanglianjie 
> <zhanglianjie@uniontech.com <mailto:zhanglianjie@uniontech.com>> wrote:
> 
>     Add TST_EXP_VAL to determine whether the return value
>     is equal to the given value.
> 
>     Signed-off-by: zhanglianjie <zhanglianjie@uniontech.com
>     <mailto:zhanglianjie@uniontech.com>>
> 
>     diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
>     index 50598aa15..d23455362 100644
>     --- a/include/tst_test_macros.h
>     +++ b/include/tst_test_macros.h
>     @@ -132,6 +132,34 @@ extern void *TST_RET_PTR;
>      ? ? ? ? ? ? ? ? ? ? ? ? TST_MSG_(TPASS, " passed", #SCALL,
>     ##__VA_ARGS__);? ? ?\
>      ? ? ? ? } while (0)                                               
>      ? ? ? ? ? ? \
> 
>     +
>     +#define TST_EXP_VAL_SILENT_(SCALL, SSCALL, VAL, ...)               
>      ? ? \
>     +? ? ? ?do {                                                       
>      ? ? ? ? \
>     +? ? ? ? ? ? ? ?TEST(SCALL);                                       
>      ? ? ? ? ? ? \
>     +                                                                   
>      ? ? \
>     +? ? ? ? ? ? ? ?TST_PASS = 0;                                       
>      ? ? ? ? ? ?\
>     +                                                                   
>      ? ? \
>     +? ? ? ? ? ? ? ?if (TST_RET != VAL) {                               
>      ? ? ? ? ? ?\
>     +? ? ? ? ? ? ? ? ? ? ? ?TST_MSGP_(TFAIL | TTERRNO, " retval not
>     %ld",? ? ? ? ? ? ? ?\
>     +? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?(long )VAL, SSCALL,
>     ##__VA_ARGS__);? ? ? ? ? ? ? ?\
>     +? ? ? ? ? ? ? ? ? ? ? ?break;                                     
>      ? ? ? ? ? ? ? ? \
>     +? ? ? ? ? ? ? ?}                                                   
>      ? ? ? ? ? ?\
>     +                                                                   
>      ? ? \
>     +? ? ? ? ? ? ? ?TST_PASS = 1;                                       
>      ? ? ? ? ? ?\
>     +                                                                   
>      ? ? \
>     +? ? ? ?} while (0)
>     +
>     +#define TST_EXP_VAL_SILENT(SCALL, VAL, ...)
>     TST_EXP_VAL_SILENT_(SCALL, #SCALL, VAL, ##__VA_ARGS__)
>     +
>     +#define TST_EXP_VAL(SCALL, VAL, ...)                               
>      ? ? \
>     +? ? ? ?do {                                                       
>      ? ? ? ? \
>     +? ? ? ? ? ? ? ?TST_EXP_VAL_SILENT(SCALL, VAL, ##__VA_ARGS__);     
>      ? ? ? ? ? ? \
>     +                                                                   
>      ? ? \
>     +? ? ? ? ? ? ? ?if (TST_PASS)                                       
>      ? ? ? ? ? ?\
>     +? ? ? ? ? ? ? ? ? ? ? ?TST_MSG_(TPASS, " passed", #SCALL,
>     ##__VA_ARGS__);? ? ? ? ? \
>     +                                                                   
>      ? ? \
>     +? ? ? ?} while(0)
>     +
>      ?#define TST_EXP_FAIL_(PASS_COND, SCALL, SSCALL, ERRNO, ...)       
>      ? ? ? ? ? ? \
>      ? ? ? ? do {                                                       
>      ? ? ? ? ? ?\
>      ? ? ? ? ? ? ? ? TEST(SCALL);                                       
>      ? ? ? ? ? ?\
>     --
>     2.20.1
> 
> 
> 
> 
>     -- 
>     Mailing list info: https://lists.linux.it/listinfo/ltp
> 
> 
> 
> -- 
> Regards,
> Li Wang

-- 
Regards,
Zhang Lianjie



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

end of thread, other threads:[~2021-08-30  6:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27  2:30 [LTP] [PATCH] tst_test_macros.h: Add TST_EXP_VAL macro zhanglianjie
2021-08-27  9:27 ` Li Wang
2021-08-30  6:35   ` zhanglianjie

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.