Skip to contentSkip to conversation

tst_test_macros: Add test_macros06 tests

PATCH New zhanglianjie 3 participants 6 messages Aug 30, 2021 – Aug 31, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tst_test_macros: Add test_macros06 tests

Test the TST_EXP_VAL and TST_EXP_VAL_SILENT macros.

lib/newlib_tests/.gitignore +1 -0
index a0bad78c1..cf467b5a0 100644
@@ -42,6 +42,7 @@ test_macros02
 test_macros03
 test_macros04
 test_macros05
+test_macros06
 tst_fuzzy_sync01
 tst_fuzzy_sync02
 tst_fuzzy_sync03
lib/newlib_tests/test_macros06.c new file +40 -0
new file mode 100644
index 000000000..626f233d2
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2021 zhanglianjie <[email protected]>
+ */
+
+/*
+ * Test TST_EXP_VAL and TST_EXP_VAL_SILENT macro.
+ */
+
+#include "tst_test.h"
+
+static int fail_val(void)
+{
+	errno = EINVAL;
+	return 42;
+}
+
+static int pass_val(void)
+{
+	return 42;
+}
+
+static void do_test(void)
+{
+	tst_res(TINFO, "Testing TST_EXP_VAL macro");
+	TST_EXP_VAL(fail_val(), 40, "fail_val()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_VAL(pass_val(), 42, "fail_val()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+
+	tst_res(TINFO, "Testing TST_EXP_PID_SILENT macro");
+	TST_EXP_VAL_SILENT(fail_val(), 40, "fail_val()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+	TST_EXP_VAL_SILENT(pass_val(), 42, "%s", "pass_val()");
+	tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+}
+
+static struct tst_test test = {
+	.test_all = do_test,
+};

--
2.20.1

#1 lore raw

PATCH 1/1 tst_test_macros: Add test_macros06 tests

Quoted 4 lines · zhanglianjie

Test the TST_EXP_VAL and TST_EXP_VAL_SILENT macros.

Quoted 70 lines
lib/newlib_tests/.gitignore +1 -0
index a0bad78c1..cf467b5a0 100644
@@ -42,6 +42,7 @@ test_macros02
 test_macros03
 test_macros04
 test_macros05
+test_macros06
 tst_fuzzy_sync01
 tst_fuzzy_sync02
 tst_fuzzy_sync03
lib/newlib_tests/test_macros06.c new file +40 -1
new file mode 100644
index 000000000..626f233d2
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2021 zhanglianjie <[email protected]>
+ */
+
+/*
+ * Test TST_EXP_VAL and TST_EXP_VAL_SILENT macro.
+ */
+
+#include "tst_test.h"
+
+static int fail_val(void)
+{
+       errno = EINVAL;
+       return 42;
+}
+
+static int pass_val(void)
+{
+       return 42;
+}
+
+static void do_test(void)
+{
+       tst_res(TINFO, "Testing TST_EXP_VAL macro");
+       TST_EXP_VAL(fail_val(), 40, "fail_val()");
+       tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+       TST_EXP_VAL(pass_val(), 42, "fail_val()");
+       tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+
+       tst_res(TINFO, "Testing TST_EXP_PID_SILENT macro");
+       TST_EXP_VAL_SILENT(fail_val(), 40, "fail_val()");
+       tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+       TST_EXP_VAL_SILENT(pass_val(), 42, "%s", "pass_val()");
+       tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+}
+
+static struct tst_test test = {
+       .test_all = do_test,
+};
--

2.20.1

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

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210830/92d213ab/attachment-0001.htm>
#2 lore raw

PATCH 1/1 tst_test_macros: Add test_macros06 tests

In reply to zhanglianjie
Quoted 42 lines · zhanglianjie

Test the TST_EXP_VAL and TST_EXP_VAL_SILENT macros.

lib/newlib_tests/.gitignore +1 -0
index a0bad78c1..cf467b5a0 100644
@@ -42,6 +42,7 @@ test_macros02
 test_macros03
 test_macros04
 test_macros05
+test_macros06
 tst_fuzzy_sync01
 tst_fuzzy_sync02
 tst_fuzzy_sync03
lib/newlib_tests/test_macros06.c new file +18 -0
new file mode 100644
index 000000000..626f233d2
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2021 zhanglianjie <[email protected]>
+ */
+
+/*
+ * Test TST_EXP_VAL and TST_EXP_VAL_SILENT macro.
+ */
+
+#include "tst_test.h"
+
+static int fail_val(void)
+{
+       errno = EINVAL;
+       return 42;
+}
+
+static int pass_val(void)

lib/newlib_tests/test_macros06.c line 28

Quoted 10 lines
lib/newlib_tests/test_macros06.c new file +10 -0
+{
+       return 42;
+}
+
+static void do_test(void)
+{
+       tst_res(TINFO, "Testing TST_EXP_VAL macro");
+       TST_EXP_VAL(fail_val(), 40, "fail_val()");
+       tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+       TST_EXP_VAL(pass_val(), 42, "fail_val()");

Err, the last function name should be corrected to "pass_val()" or delete it like test_macros05.

Someone who merges this can help fix it.

Quoted 22 lines
lib/newlib_tests/test_macros06.c new file +12 -1
+       tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+
+       tst_res(TINFO, "Testing TST_EXP_PID_SILENT macro");
+       TST_EXP_VAL_SILENT(fail_val(), 40, "fail_val()");
+       tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+       TST_EXP_VAL_SILENT(pass_val(), 42, "%s", "pass_val()");
+       tst_res(TINFO, "TST_PASS = %i", TST_PASS);
+}
+
+static struct tst_test test = {
+       .test_all = do_test,
+};
--

2.20.1

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

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210830/86b6330b/attachment.htm>
#3 lore raw

PATCH 1/1 tst_test_macros: Add test_macros06 tests

Hi,
I will fix it, thanks for your review.

Quoted 91 lines · Li Wang

On Mon, Aug 30, 2021 at 3:36 PM zhanglianjie <[email protected] <mailto:[email protected]>> wrote:

    Test the TST_EXP_VAL and TST_EXP_VAL_SILENT macros.

    Signed-off-by: zhanglianjie <[email protected]
    <mailto:[email protected]>>

    diff --git a/lib/newlib_tests/.gitignore b/lib/newlib_tests/.gitignore
    index a0bad78c1..cf467b5a0 100644
    --- a/lib/newlib_tests/.gitignore
    +++ b/lib/newlib_tests/.gitignore
    @@ -42,6 +42,7 @@ test_macros02
     ?test_macros03
     ?test_macros04
     ?test_macros05
    +test_macros06
     ?tst_fuzzy_sync01
     ?tst_fuzzy_sync02
     ?tst_fuzzy_sync03
    diff --git a/lib/newlib_tests/test_macros06.c
    b/lib/newlib_tests/test_macros06.c
    new file mode 100644
    index 000000000..626f233d2
    --- /dev/null
    +++ b/lib/newlib_tests/test_macros06.c
    @@ -0,0 +1,40 @@
    +// SPDX-License-Identifier: GPL-2.0-or-later
    +/*
    + * Copyright (c) 2021 zhanglianjie <[email protected]
    <mailto:[email protected]>>
    + */
    +
    +/*
    + * Test TST_EXP_VAL and TST_EXP_VAL_SILENT macro.
    + */
    +
    +#include "tst_test.h"
    +
    +static int fail_val(void)
    +{
    +? ? ? ?errno = EINVAL;
    +? ? ? ?return 42;
    +}
    +
    +static int pass_val(void)
    +{
    +? ? ? ?return 42;
    +}
    +
    +static void do_test(void)
    +{
    +? ? ? ?tst_res(TINFO, "Testing TST_EXP_VAL macro");
    +? ? ? ?TST_EXP_VAL(fail_val(), 40, "fail_val()");
    +? ? ? ?tst_res(TINFO, "TST_PASS = %i", TST_PASS);
    +? ? ? ?TST_EXP_VAL(pass_val(), 42, "fail_val()");

Err, the last function name should be corrected to "pass_val()" or delete it like test_macros05.

Someone who merges this can help fix it.

    +? ? ? ?tst_res(TINFO, "TST_PASS = %i", TST_PASS);
    +
    +? ? ? ?tst_res(TINFO, "Testing TST_EXP_PID_SILENT macro");
    +? ? ? ?TST_EXP_VAL_SILENT(fail_val(), 40, "fail_val()");
    +? ? ? ?tst_res(TINFO, "TST_PASS = %i", TST_PASS);
    +? ? ? ?TST_EXP_VAL_SILENT(pass_val(), 42, "%s", "pass_val()");
    +? ? ? ?tst_res(TINFO, "TST_PASS = %i", TST_PASS);
    +}
    +
    +static struct tst_test test = {
    +? ? ? ?.test_all = do_test,
    +};
    --
    2.20.1




    -- 
    Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Regards,
Li Wang
Signature · 2 lines
Regards,
Zhang Lianjie
#5 lore raw

PATCH 1/1 tst_test_macros: Add test_macros06 tests

Hi,
Yes, I will submit the patch, thank you.

Quoted 3 lines · Cyril Hrubis

Hi!
Can we please add the macro expansion test to the test_macros05 as well?

Signature · 2 lines
Regards,
Zhang Lianjie