Skip to contentSkip to conversation

Add link01 test

PATCH In review Andrea Cervesato 2 participants 2 messages Jan 19, 2024 – Feb 20, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add link01 test

From: Andrea Cervesato <[email protected]>

This test verifies that link() is working correctly on symlink() generated files, renaming the symbolic link and checking that stat() information are preserved.

---
 runtest/syscalls                        |  2 +-
 testcases/kernel/syscalls/link/link01.c | 47 +++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 testcases/kernel/syscalls/link/link01.c
runtest/syscalls +1 -1
index 68460de0b..00a0dd87e 100644
@@ -692,7 +692,7 @@ lchown03_16 lchown03_16
 lgetxattr01 lgetxattr01
 lgetxattr02 lgetxattr02
 
-link01 symlink01 -T link01
+link01 link01
 link02 link02
 link04 link04
 link05 link05
testcases/kernel/syscalls/link/link01.c new file +47 -0

47 lines not on this page · raw message

Signature · 5 lines
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi!
please ignore this patch since the test case is covered by link02 already.

Andrea

Quoted 79 lines · Andrea Cervesato

From: Andrea Cervesato <[email protected]>

This test verifies that link() is working correctly on symlink() generated files, renaming the symbolic link and checking that stat() information are preserved.

---
  runtest/syscalls                        |  2 +-
  testcases/kernel/syscalls/link/link01.c | 47 +++++++++++++++++++++++++
  2 files changed, 48 insertions(+), 1 deletion(-)

create mode 100644 testcases/kernel/syscalls/link/link01.c

runtest/syscalls +1 -1
index 68460de0b..00a0dd87e 100644
@@ -692,7 +692,7 @@ lchown03_16 lchown03_16
  lgetxattr01 lgetxattr01
  lgetxattr02 lgetxattr02
 
-link01 symlink01 -T link01
+link01 link01
  link02 link02
  link04 link04
  link05 link05
testcases/kernel/syscalls/link/link01.c new file +47 -0
new file mode 100644
index 000000000..e1cda7054
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
+ *    Author: David Fenner
+ *    Copilot: Jon Hendrickson
+ * Copyright (C) 2024 Andrea Cervesato [email protected]
+ */
+
+/*\
+ * [Description]
+ *
+ * This test verifies that link() is working correctly on symlink()
+ * generated files, renaming the symbolic link and checking that
+ * stat() information are preserved.
+ */
+
+#include "tst_test.h"
+
+static void run(void)
+{
+	struct stat oldlink_stat;
+	struct stat newlink_stat;
+	char *symname0 = "my_symlink0";
+	char *symname1 = "my_symlink1";
+
+	SAFE_SYMLINK(tst_get_tmpdir(), symname0);
+	SAFE_STAT(symname0, &oldlink_stat);
+
+	SAFE_LINK(symname0, symname1);
+	SAFE_STAT(symname1, &newlink_stat);
+
+	TST_EXP_EQ_LI(oldlink_stat.st_ino, newlink_stat.st_ino);
+	TST_EXP_EQ_LI(oldlink_stat.st_nlink, newlink_stat.st_nlink);
+
+	if (TST_RET == -1) {
+		SAFE_UNLINK(symname0);
+		remove(symname1);
+	} else {
+		SAFE_UNLINK(symname1);
+		remove(symname0);
+	}
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.needs_tmpdir = 1,
+};
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp