From: Andrea Cervesato <andrea.cervesato@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 4/5] Add chmod08 test
Date: Tue, 02 Jul 2024 16:12:50 +0200 [thread overview]
Message-ID: <20240702-stat04-v1-4-e27d9953210d@suse.com> (raw)
In-Reply-To: <20240702-stat04-v1-0-e27d9953210d@suse.com>
From: Andrea Cervesato <andrea.cervesato@suse.com>
This test has been extracted from symlink01 and it verifies that
chmod() is working correctly on symlink() generated files.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
runtest/syscalls | 1 +
testcases/kernel/syscalls/chmod/.gitignore | 1 +
testcases/kernel/syscalls/chmod/chmod08.c | 45 ++++++++++++++++++++++++++++++
3 files changed, 47 insertions(+)
diff --git a/runtest/syscalls b/runtest/syscalls
index d78b6822b..928e75f9b 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -72,6 +72,7 @@ chmod03 chmod03
chmod05 chmod05
chmod06 chmod06
chmod07 chmod07
+chmod08 chmod08
chown01 chown01
chown01_16 chown01_16
diff --git a/testcases/kernel/syscalls/chmod/.gitignore b/testcases/kernel/syscalls/chmod/.gitignore
index 27ddfce16..f295f4dcb 100644
--- a/testcases/kernel/syscalls/chmod/.gitignore
+++ b/testcases/kernel/syscalls/chmod/.gitignore
@@ -3,3 +3,4 @@
/chmod05
/chmod06
/chmod07
+/chmod08
diff --git a/testcases/kernel/syscalls/chmod/chmod08.c b/testcases/kernel/syscalls/chmod/chmod08.c
new file mode 100644
index 000000000..7ef396348
--- /dev/null
+++ b/testcases/kernel/syscalls/chmod/chmod08.c
@@ -0,0 +1,45 @@
+// 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 andrea.cervesato@suse.com
+ */
+
+/*\
+ * [Description]
+ *
+ * This test verifies that chmod() is working correctly on symlink()
+ * generated files.
+ */
+
+#include "tst_test.h"
+
+#define PERMS 01777
+#define TESTFILE "myobject"
+
+static void run(void)
+{
+ char *symname = "my_symlink0";
+ struct stat oldsym_stat;
+ struct stat newsym_stat;
+
+ SAFE_TOUCH(TESTFILE, 0644, NULL);
+ SAFE_SYMLINK(TESTFILE, symname);
+ SAFE_STAT(symname, &oldsym_stat);
+
+ TST_EXP_PASS(chmod(symname, PERMS));
+ SAFE_STAT(symname, &newsym_stat);
+
+ TST_EXP_EQ_LI(newsym_stat.st_mode & PERMS, PERMS);
+ TST_EXP_EXPR(oldsym_stat.st_mode != newsym_stat.st_mode,
+ "file mode has changed");
+
+ SAFE_UNLINK(symname);
+ SAFE_UNLINK(TESTFILE);
+}
+
+static struct tst_test test = {
+ .test_all = run,
+ .needs_tmpdir = 1,
+};
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-07-02 14:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-02 14:12 [LTP] [PATCH 0/5] symlink01 split Andrea Cervesato
2024-07-02 14:12 ` [LTP] [PATCH 1/5] Add stat04 test Andrea Cervesato
2024-07-04 7:06 ` Li Wang
2024-07-04 9:17 ` Cyril Hrubis
2024-07-04 9:23 ` Cyril Hrubis
2024-07-04 11:27 ` Li Wang
2024-07-04 11:55 ` Cyril Hrubis
2024-07-04 12:02 ` Li Wang
2024-07-02 14:12 ` [LTP] [PATCH 2/5] Fix TST_EXP_EXTR() stringification Andrea Cervesato
2024-07-04 7:11 ` Li Wang
2024-07-04 9:19 ` Cyril Hrubis
2024-07-02 14:12 ` [LTP] [PATCH 3/5] Add lstat03 test Andrea Cervesato
2024-07-04 6:36 ` Li Wang
2024-07-04 6:56 ` Li Wang
2024-07-02 14:12 ` Andrea Cervesato [this message]
2024-07-04 7:12 ` [LTP] [PATCH 4/5] Add chmod08 test Li Wang
2024-07-02 14:12 ` [LTP] [PATCH 5/5] Add open15 test Andrea Cervesato
2024-07-04 7:18 ` Li Wang
2024-07-04 7:32 ` Li Wang
2024-07-09 10:31 ` Andrea Cervesato via ltp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240702-stat04-v1-4-e27d9953210d@suse.com \
--to=andrea.cervesato@suse.de \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox