* [LTP] [PATCH 1/2] link05: Return on link() failure @ 2023-11-08 7:49 Petr Vorel 2023-11-08 7:49 ` [LTP] [PATCH 2/2] link05: Use constant for number of links Petr Vorel 2024-02-08 13:25 ` [LTP] [PATCH 1/2] link05: Return on link() failure Andrea Cervesato via ltp 0 siblings, 2 replies; 5+ messages in thread From: Petr Vorel @ 2023-11-08 7:49 UTC (permalink / raw) To: ltp; +Cc: tangmeng If link() fails to be created, the following stat() failed: link05.c:39: TBROK: stat(lkfile_1391822_1,0x7ffd61e5f000) failed: ENOENT (2) Therefore skip testing and improve the error message: 5: link(lkfile_1404879, lkfile_1404879_5) failed: ENOENT (2) Also fix cnt and nlinks condition. Signed-off-by: Petr Vorel <pvorel@suse.cz> --- @Xu, please merge your "link05: Convert docs to docparse" patchset [1] first, I'll rebase my afterwards. Kind regards, Petr [1] https://lore.kernel.org/ltp/20231108053122.GA1383908@pevik/ testcases/kernel/syscalls/link/link05.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/testcases/kernel/syscalls/link/link05.c b/testcases/kernel/syscalls/link/link05.c index 9b81ef3fd..1d708c6f6 100644 --- a/testcases/kernel/syscalls/link/link05.c +++ b/testcases/kernel/syscalls/link/link05.c @@ -22,13 +22,16 @@ static int nlinks = 1000; static void verify_link(void) { - int cnt; + int cnt = 0, created; char lname[1024]; struct stat fbuf, lbuf; - for (cnt = 1; cnt < nlinks; cnt++) { - sprintf(lname, "%s_%d", fname, cnt); - TST_EXP_PASS_SILENT(link(fname, lname), "link(%s, %s)", fname, lname); + for (created = 1; created < nlinks; created++) { + sprintf(lname, "%s_%d", fname, created); + TST_EXP_PASS_SILENT(link(fname, lname), "%d: link(%s, %s)", created, + fname, lname); + if (!TST_PASS) + goto cleanup; } SAFE_STAT(fname, &fbuf); @@ -48,13 +51,14 @@ static void verify_link(void) } } - if (cnt >= nlinks) { + if (cnt == nlinks) { tst_res(TPASS, "link(%s, %s[1-%d]) ret %ld for %d files, stat linkcounts match %d", fname, fname, nlinks, TST_RET, nlinks, (int)fbuf.st_nlink); } - for (cnt = 1; cnt < nlinks; cnt++) { +cleanup: + for (cnt = 1; cnt < created; cnt++) { sprintf(lname, "%s_%d", fname, cnt); SAFE_UNLINK(lname); } -- 2.42.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [LTP] [PATCH 2/2] link05: Use constant for number of links 2023-11-08 7:49 [LTP] [PATCH 1/2] link05: Return on link() failure Petr Vorel @ 2023-11-08 7:49 ` Petr Vorel 2024-02-08 13:25 ` Andrea Cervesato via ltp 2024-02-08 13:25 ` [LTP] [PATCH 1/2] link05: Return on link() failure Andrea Cervesato via ltp 1 sibling, 1 reply; 5+ messages in thread From: Petr Vorel @ 2023-11-08 7:49 UTC (permalink / raw) To: ltp; +Cc: tangmeng No need to create variable, when number of links is not changed. Fixes: d908fd870 ("link/link05: Convert to new API") Signed-off-by: Petr Vorel <pvorel@suse.cz> --- testcases/kernel/syscalls/link/link05.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/testcases/kernel/syscalls/link/link05.c b/testcases/kernel/syscalls/link/link05.c index 1d708c6f6..a188da18d 100644 --- a/testcases/kernel/syscalls/link/link05.c +++ b/testcases/kernel/syscalls/link/link05.c @@ -15,18 +15,17 @@ #include "tst_test.h" #define BASENAME "lkfile" +#define NLINKS 1000 static char fname[255]; -static int nlinks = 1000; - static void verify_link(void) { int cnt = 0, created; char lname[1024]; struct stat fbuf, lbuf; - for (created = 1; created < nlinks; created++) { + for (created = 1; created < NLINKS; created++) { sprintf(lname, "%s_%d", fname, created); TST_EXP_PASS_SILENT(link(fname, lname), "%d: link(%s, %s)", created, fname, lname); @@ -36,7 +35,7 @@ static void verify_link(void) SAFE_STAT(fname, &fbuf); - for (cnt = 1; cnt < nlinks; cnt++) { + for (cnt = 1; cnt < NLINKS; cnt++) { sprintf(lname, "%s_%d", fname, cnt); SAFE_STAT(lname, &lbuf); @@ -45,16 +44,16 @@ static void verify_link(void) tst_res(TFAIL, "link(%s, %s[1-%d]) ret %ld for %d files, stat values do not match %d %d", - fname, fname, nlinks, TST_RET, nlinks, + fname, fname, NLINKS, TST_RET, NLINKS, (int)fbuf.st_nlink, (int)lbuf.st_nlink); break; } } - if (cnt == nlinks) { + if (cnt == NLINKS) { tst_res(TPASS, "link(%s, %s[1-%d]) ret %ld for %d files, stat linkcounts match %d", - fname, fname, nlinks, TST_RET, nlinks, (int)fbuf.st_nlink); + fname, fname, NLINKS, TST_RET, NLINKS, (int)fbuf.st_nlink); } cleanup: -- 2.42.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH 2/2] link05: Use constant for number of links 2023-11-08 7:49 ` [LTP] [PATCH 2/2] link05: Use constant for number of links Petr Vorel @ 2024-02-08 13:25 ` Andrea Cervesato via ltp 2024-02-19 21:29 ` Petr Vorel 0 siblings, 1 reply; 5+ messages in thread From: Andrea Cervesato via ltp @ 2024-02-08 13:25 UTC (permalink / raw) To: ltp Hi! LGTM Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com> Regards, Andrea On 11/8/23 08:49, Petr Vorel wrote: > No need to create variable, when number of links is not changed. > > Fixes: d908fd870 ("link/link05: Convert to new API") > Signed-off-by: Petr Vorel <pvorel@suse.cz> > --- > testcases/kernel/syscalls/link/link05.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > > diff --git a/testcases/kernel/syscalls/link/link05.c > b/testcases/kernel/syscalls/link/link05.c > index 1d708c6f6..a188da18d 100644 > --- a/testcases/kernel/syscalls/link/link05.c > +++ b/testcases/kernel/syscalls/link/link05.c > @@ -15,18 +15,17 @@ > #include "tst_test.h" > > #define BASENAME "lkfile" > +#define NLINKS 1000 > > static char fname[255]; > > -static int nlinks = 1000; > - > static void verify_link(void) > { > int cnt = 0, created; > char lname[1024]; > struct stat fbuf, lbuf; > > - for (created = 1; created < nlinks; created++) { > + for (created = 1; created < NLINKS; created++) { > sprintf(lname, "%s_%d", fname, created); > TST_EXP_PASS_SILENT(link(fname, lname), "%d: link(%s, %s)", > created, > fname, lname); > @@ -36,7 +35,7 @@ static void verify_link(void) > > SAFE_STAT(fname, &fbuf); > > - for (cnt = 1; cnt < nlinks; cnt++) { > + for (cnt = 1; cnt < NLINKS; cnt++) { > sprintf(lname, "%s_%d", fname, cnt); > > SAFE_STAT(lname, &lbuf); > @@ -45,16 +44,16 @@ static void verify_link(void) > > tst_res(TFAIL, > "link(%s, %s[1-%d]) ret %ld for %d files, stat values > do not match %d %d", > - fname, fname, nlinks, TST_RET, nlinks, > + fname, fname, NLINKS, TST_RET, NLINKS, > (int)fbuf.st_nlink, (int)lbuf.st_nlink); > break; > } > } > > - if (cnt == nlinks) { > + if (cnt == NLINKS) { > tst_res(TPASS, > "link(%s, %s[1-%d]) ret %ld for %d files, stat linkcounts > match %d", > - fname, fname, nlinks, TST_RET, nlinks, (int)fbuf.st_nlink); > + fname, fname, NLINKS, TST_RET, NLINKS, (int)fbuf.st_nlink); > } > > cleanup: -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH 2/2] link05: Use constant for number of links 2024-02-08 13:25 ` Andrea Cervesato via ltp @ 2024-02-19 21:29 ` Petr Vorel 0 siblings, 0 replies; 5+ messages in thread From: Petr Vorel @ 2024-02-19 21:29 UTC (permalink / raw) To: Andrea Cervesato; +Cc: ltp Hi Andrea, > Hi! > LGTM > Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com> Thanks for your review, merged. Could you please use "reply to all" when posting your review? That way you reply directly to the autor (and possibly other people in the thread), which speedups the process (I guess I'm not the only one who expects to get comments directly, I find this just by change). Thank you! Kind regards, Petr > Regards, > Andrea -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH 1/2] link05: Return on link() failure 2023-11-08 7:49 [LTP] [PATCH 1/2] link05: Return on link() failure Petr Vorel 2023-11-08 7:49 ` [LTP] [PATCH 2/2] link05: Use constant for number of links Petr Vorel @ 2024-02-08 13:25 ` Andrea Cervesato via ltp 1 sibling, 0 replies; 5+ messages in thread From: Andrea Cervesato via ltp @ 2024-02-08 13:25 UTC (permalink / raw) To: ltp Hi! LGTM Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com> Regards, Andrea On 11/8/23 08:49, Petr Vorel wrote: > If link() fails to be created, the following stat() failed: > > link05.c:39: TBROK: stat(lkfile_1391822_1,0x7ffd61e5f000) failed: > ENOENT (2) > > Therefore skip testing and improve the error message: > 5: link(lkfile_1404879, lkfile_1404879_5) failed: ENOENT (2) > > Also fix cnt and nlinks condition. > > Signed-off-by: Petr Vorel <pvorel@suse.cz> > --- > @Xu, please merge your "link05: Convert docs to docparse" patchset [1] > first, I'll rebase my afterwards. > > Kind regards, > Petr > > [1] https://lore.kernel.org/ltp/20231108053122.GA1383908@pevik/ > > testcases/kernel/syscalls/link/link05.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/testcases/kernel/syscalls/link/link05.c > b/testcases/kernel/syscalls/link/link05.c > index 9b81ef3fd..1d708c6f6 100644 > --- a/testcases/kernel/syscalls/link/link05.c > +++ b/testcases/kernel/syscalls/link/link05.c > @@ -22,13 +22,16 @@ static int nlinks = 1000; > > static void verify_link(void) > { > - int cnt; > + int cnt = 0, created; > char lname[1024]; > struct stat fbuf, lbuf; > > - for (cnt = 1; cnt < nlinks; cnt++) { > - sprintf(lname, "%s_%d", fname, cnt); > - TST_EXP_PASS_SILENT(link(fname, lname), "link(%s, %s)", > fname, lname); > + for (created = 1; created < nlinks; created++) { > + sprintf(lname, "%s_%d", fname, created); > + TST_EXP_PASS_SILENT(link(fname, lname), "%d: link(%s, %s)", > created, > + fname, lname); > + if (!TST_PASS) > + goto cleanup; > } > > SAFE_STAT(fname, &fbuf); > @@ -48,13 +51,14 @@ static void verify_link(void) > } > } > > - if (cnt >= nlinks) { > + if (cnt == nlinks) { > tst_res(TPASS, > "link(%s, %s[1-%d]) ret %ld for %d files, stat linkcounts > match %d", > fname, fname, nlinks, TST_RET, nlinks, (int)fbuf.st_nlink); > } > > - for (cnt = 1; cnt < nlinks; cnt++) { > +cleanup: > + for (cnt = 1; cnt < created; cnt++) { > sprintf(lname, "%s_%d", fname, cnt); > SAFE_UNLINK(lname); > } -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-19 21:29 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-11-08 7:49 [LTP] [PATCH 1/2] link05: Return on link() failure Petr Vorel 2023-11-08 7:49 ` [LTP] [PATCH 2/2] link05: Use constant for number of links Petr Vorel 2024-02-08 13:25 ` Andrea Cervesato via ltp 2024-02-19 21:29 ` Petr Vorel 2024-02-08 13:25 ` [LTP] [PATCH 1/2] link05: Return on link() failure Andrea Cervesato via ltp
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox