All of lore.kernel.org
 help / color / mirror / Atom feed
* [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

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