mkdir09: rewrite in new LTP API
v2 cover mkdir09: rewrite in new LTP API
Changes:
- 'use all_filesystems = 1'
This gives us back reproducer we used to have before statx04 rewrite for commit 07bfa4415ab6 ("fat: work around race with userspace's read via blockdev while mounting")
- fix description comment
- comments moved before functions
- separate loop with SAFE_MKDIR moved to setup
- introduce TST_EXP_FAIL_SILENT (patch 1/2)
- used TST_EXP_PASS_SILENT in test2 and test3
- fixed TPASS message in test2 to say "remove dirs"
Jan Stancek (2):
tst_test_macros: add TST_EXP_FAIL_SILENT
syscalls/mkdir09: rewrite in new LTP API
doc/c-test-api.txt | 3 + include/tst_test_macros.h | 15 +- testcases/kernel/syscalls/mkdir/Makefile | 2 + testcases/kernel/syscalls/mkdir/mkdir09.c | 494 ++++------------------ 4 files changed, 106 insertions(+), 408 deletions(-)
Signature · 5 lines
2.27.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/2 tst_test_macros: add TST_EXP_FAIL_SILENT
This variant does not print TPASS messages when
SCALL fails as expected.
--- doc/c-test-api.txt | 3 +++ include/tst_test_macros.h | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-)
doc/c-test-api.txt +3 -0
@@ -298,6 +298,9 @@ The 'TST_EXP_FAIL2()' is the same as 'TST_EXP_FAIL()' except the return value is expected to be non-negative integer if call passes. These macros build upon the +TEST()+ macro and associated variables. +'TST_EXP_FAIL_SILENT()' and 'TST_EXP_FAIL2_SILENT()' variants are less verbose +and do not print TPASS messages when SCALL fails as expected. + [source,c] ------------------------------------------------------------------------------- TEST(socket(AF_INET, SOCK_RAW, 1));
include/tst_test_macros.h +10 -5
@@ -163,7 +163,7 @@ extern void *TST_RET_PTR; TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \ } while (0) \ -#define TST_EXP_FAIL_ (PASS_COND ,SCALL ,SSCALL ,ERRNO , ...) \ +#define TST_EXP_FAIL_ (SILENT ,PASS_COND ,SCALL ,SSCALL ,ERRNO , ...) \ do { \ TEST(SCALL); \ \
@@ -181,8 +181,9 @@ extern void *TST_RET_PTR; } \ \if (TST_ERR == (ERRNO )) { \ -TST_MSG_ (TPASS |TTERRNO ," " , \ - SSCALL, ##__VA_ARGS__); \ +if (!SILENT ) \ +TST_MSG_ (TPASS |TTERRNO ," " , \ + SSCALL, ##__VA_ARGS__); \TST_PASS =1 ; \ }else { \ TST_MSGP_(TFAIL | TTERRNO, " expected %s", \
@@ -191,9 +192,13 @@ extern void *TST_RET_PTR; } \ } while (0) -#define TST_EXP_FAIL (SCALL ,ERRNO , ...) TST_EXP_FAIL_(TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__) +#define TST_EXP_FAIL (SCALL ,ERRNO , ...) TST_EXP_FAIL_(0, TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__) -#define TST_EXP_FAIL2 (SCALL ,ERRNO , ...) TST_EXP_FAIL_(TST_RET >= 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__) +#define TST_EXP_FAIL2 (SCALL ,ERRNO , ...) TST_EXP_FAIL_(0, TST_RET >= 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__) + +#define TST_EXP_FAIL_SILENT (SCALL ,ERRNO , ...) TST_EXP_FAIL_(1, TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__) + +#define TST_EXP_FAIL2_SILENT (SCALL ,ERRNO , ...) TST_EXP_FAIL_(1, TST_RET >= 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)#define TST_EXP_EXPR (EXPR ,FMT , ...) \ tst_res_(__FILE__, __LINE__, (EXPR) ? TPASS : TFAIL, "Expect: " FMT, ##__VA_ARGS__);
Signature · 5 lines
2.27.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 2/2 syscalls/mkdir09: rewrite in new LTP API
In reply to Jan Stancek'jump' variable is not initialized, which I suspect is behind rare failures of this test. The original test is using longjmp, processes and signals to sychronize couple processes that exercise mkdir/rmdir calls.
Rewrite it using threads and new LTP API, drop all parameters, because no runtest is using them, and make new default test time just 1 second.
--- testcases/kernel/syscalls/mkdir/Makefile | 2 + testcases/kernel/syscalls/mkdir/mkdir09.c | 494 ++++------------------ 2 files changed, 93 insertions(+), 403 deletions(-)
testcases/kernel/syscalls/mkdir/Makefile +2 -0
@@ -3,6 +3,8 @@ top_srcdir ?= ../../../.. +mkdir09: CFLAGS += -pthread + include $(top_srcdir)/include/mk/testcases.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/mkdir/mkdir09.c +91 -403
551 lines not on this page · raw message
Signature · 5 lines
2.27.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 1/2] tst_test_macros: add TST_EXP_FAIL_SILENT
In reply to Jan StancekQuoted 40 lines · Jan Stancek
This variant does not print TPASS messages when
SCALL fails as expected.Signed-off-by Jan Stancek <[email protected]>--- doc/c-test-api.txt | 3 +++ include/tst_test_macros.h | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-)doc/c-test-api.txt +0
-0@@ -298,6 +298,9 @@ The 'TST_EXP_FAIL2()' is the same as 'TST_EXP_FAIL()'except the return value is
expected to be non-negative integer if call passes. These macros build
upon the
+TEST()+ macro and associated variables.+'TST_EXP_FAIL_SILENT()' and '
TST_EXP_FAIL2_SILENT()' variants are less verbosedoc/c-test-api.txt +2
-0+and do not print TPASS messages when SCALL fails as expected. + [source,c] ------------------------------------------------------------------------------- TEST(socket(AF_INET, SOCK_RAW, 1));include/tst_test_macros.h +1
-1@@ -163,7 +163,7 @@ extern void *TST_RET_PTR; TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \ } while (0) \ -#define TST_EXP_FAIL_ (PASS_COND ,SCALL ,SSCALL ,ERRNO , ...) \ +#define TST_EXP_FAIL_ (SILENT ,PASS_COND ,SCALL ,SSCALL ,ERRNO , ...)
Quoted 2 lines
\
I think maybe the better way is to define TST_EXP_FAIL_SILENT_ but not add a new SILENT parameter. So that it keeps consistent with the existing TST_EXP_PASS_SILENT_ macros.
How about this:
(changed base on your patch)
include/tst_test_macros.h +1 -1
@@ -163,7 +163,7 @@ extern void *TST_RET_PTR; TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \ } while (0) \ -#define TST_EXP_FAIL_ (SILENT ,PASS_COND ,SCALL ,SSCALL ,ERRNO , ...) \ +#define TST_EXP_FAIL_SILENT_ (PASS_COND ,SCALL ,SSCALL ,ERRNO , ...)
\
do {
\
TEST(SCALL);
\\
@@ -181,9 +181,6 @@ extern void *TST_RET_PTR;
}\
\
if (TST_ERR == (ERRNO)) {
\
- if (!SILENT)
\
- TST_MSG_(TPASS | TTERRNO, " ",
\
- SSCALL, ##__VA_ARGS__);
\
TST_PASS = 1;
\
} else {
\
TST_MSGP_(TFAIL | TTERRNO, " expected %s",
\
@@ -192,13 +189,23 @@ extern void *TST_RET_PTR;
}
\
} while (0)-#define TST_EXP_FAIL(SCALL, ERRNO, ...) TST_EXP_FAIL_(0, TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
+#define TST_EXP_FAIL(SCALL, ERRNO, ...)
\
+ do {
\+ TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL, ERRNO,
##__VA_ARGS__); \
+ if (TST_PASS)
\
+ TST_MSG_(TPASS | TTERRNO, " ", #SCALL,
##__VA_ARGS__); \
+ } while (0)
-#define TST_EXP_FAIL2(SCALL, ERRNO, ...) TST_EXP_FAIL_(0, TST_RET >= 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
+#define TST_EXP_FAIL2(SCALL, ERRNO, ...)
\
+ do {
\+ TST_EXP_FAIL_SILENT_(TST_RET >= 0, 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_(1, TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
+#define TST_EXP_FAIL_SILENT(SCALL, ERRNO, ...) TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__) \
-#define TST_EXP_FAIL2_SILENT(SCALL, ERRNO, ...) TST_EXP_FAIL_(1, TST_RET
Quoted 1 line
= 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__)
+#define TST_EXP_FAIL2_SILENT(SCALL, ERRNO, ...) TST_EXP_FAIL_SILENT_(TST_RET >= 0, SCALL, #SCALL, ERRNO, ##__VA_ARGS__) \
#define TST_EXP_EXPR(EXPR, FMT, ...)
\
tst_res_(__FILE__, __LINE__, (EXPR) ? TPASS : TFAIL, "Expect: "FMT, ##__VA_ARGS__);
Signature · 2 lines
Regards, Li Wang
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 2/2] syscalls/mkdir09: rewrite in new LTP API
In reply to Jan StancekQuoted 9 lines · Jan Stancek
(quoted diff) +3
-0+#include "tst_test.h" +#include "tst_safe_pthread.h" +#define MNTPOINT "mntpoint" #define MODE_RWX 07770
Review
Quoted 10 lines
(quoted diff) +4
-1+#define DIR_NAME MNTPOINT "/X.%d" +#define DIR_NAME_GROUP MNTPOINT "/X.%d.%d" +#define NCHILD 3 static int child_groups = 2; -static int test_time = 5; +static int test_time = 1; static int nfiles = 5;
I think initialize 'nfiles' to 10 will be better.
As we can see the test3 starts from 'j=2' and only creates one directory for testing, but the comment says many directories. Also, it will test more dirs in test1 and test2.
Otherwise, this patch looks pretty good.
Signature · 2 lines
Regards, Li Wang
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 1/2] tst_test_macros: add TST_EXP_FAIL_SILENT
In reply to Li WangQuoted 36 lines · Li Wang
Quoted 32 lines · Jan Stancek
This variant does not print TPASS messages when
SCALL fails as expected.Signed-off-by Jan Stancek <[email protected]>--- doc/c-test-api.txt | 3 +++ include/tst_test_macros.h | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-)doc/c-test-api.txt +3
-0@@ -298,6 +298,9 @@ The 'TST_EXP_FAIL2()' is the same as 'TST_EXP_FAIL()' except the return value is expected to be non-negative integer if call passes. These macros build upon the +TEST()+ macro and associated variables. +'TST_EXP_FAIL_SILENT()' and 'TST_EXP_FAIL2_SILENT()' variants are less verbose +and do not print TPASS messages when SCALL fails as expected. + [source,c] ------------------------------------------------------------------------------- TEST(socket(AF_INET, SOCK_RAW, 1));include/tst_test_macros.h +0
-0@@ -163,7 +163,7 @@ extern void *TST_RET_PTR; TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \ }while (0 ) \
Quoted 7 lines
include/tst_test_macros.h extern void *TST_RET_PTR; · line 166
Quoted 2 lines
include/tst_test_macros.h +1
-1-#define TST_EXP_FAIL_ (PASS_COND ,SCALL ,SSCALL ,ERRNO , ...) \ +#define TST_EXP_FAIL_ (SILENT ,PASS_COND ,SCALL ,SSCALL ,ERRNO , ...) \I think maybe the better way is to define
TST_EXP_FAIL_SILENT_but not add a new SILENT parameter. So that it keeps consistent with the existingTST_EXP_PASS_SILENT_macros.
It looked like smaller change, but I can update it (Along with the suggestion to create/delete more directories)
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 2/2] syscalls/mkdir09: rewrite in new LTP API
In reply to Jan StancekHi!
testcases/kernel/syscalls/mkdir/mkdir09.c line 363
Quoted 13 lines
testcases/kernel/syscalls/mkdir/mkdir09.c +5
-6+/* +* Child routine which attempts to remove directories from the +* test directory which do not exist. +*/ +static void test2 (int child_num) { -/* Child routine which attempts to remove directories from the -* test directory which do not exist. Runs until a SIGTERM -* signal is received. Exits with an error if the proper -* error is not detected or if the remove operation is -* successful. -*/
This empty line here looks a bit strange and the same for the test3(). Other than that and the suggestion from Li it looks good.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2 2/2] syscalls/mkdir09: rewrite in new LTP API
Quoted 19 lines · Cyril Hrubis
Hi!
testcases/kernel/syscalls/mkdir/mkdir09.c line 363
Quoted 13 lines
testcases/kernel/syscalls/mkdir/mkdir09.c +5
-6+/* +* Child routine which attempts to remove directories from the +* test directory which do not exist. +*/ +static void test2 (int child_num) { -/* Child routine which attempts to remove directories from the -* test directory which do not exist. Runs until a SIGTERM -* signal is received. Exits with an error if the proper -* error is not detected or if the remove operation is -* successful. -*/ This empty line here looks a bit strange and the same for the
test3(). Other than that and the suggestion from Li it looks good.
Quoted 1 line
Reviewed-by Cyril Hrubis <[email protected]>
Thanks, pushed with suggested changes.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp