From: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
To: ltp-list@lists.sourceforge.net
Subject: [LTP] [PATCH] acct/acct01.c: Add ELOOP ENAMETOOLONG EROFS
Date: Tue, 22 Oct 2013 18:27:24 +0800 [thread overview]
Message-ID: <5266530C.5070604@cn.fujitsu.com> (raw)
Add ELOOP, ENAMETOOLONG, EROFS error number test in acct01.c for acct(2)
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
runtest/syscalls | 2 +-
testcases/kernel/syscalls/acct/acct01.c | 77 ++++++++++++++++++++++++++++++++-
2 files changed, 77 insertions(+), 2 deletions(-)
diff --git a/runtest/syscalls b/runtest/syscalls
index 09e5f7f..a3a65b6 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -10,7 +10,7 @@ access03 access03
access04 access04
access05 access05
-acct01 acct01
+acct01 acct01 -D DEVICE -T DEVICE_FS_TYPE
acct02 acct02
add_key01 add_key01
diff --git a/testcases/kernel/syscalls/acct/acct01.c b/testcases/kernel/syscalls/acct/acct01.c
index 062cc2b..1545df1 100644
--- a/testcases/kernel/syscalls/acct/acct01.c
+++ b/testcases/kernel/syscalls/acct/acct01.c
@@ -44,22 +44,41 @@
#include <stdio.h> /* needed by testhead.h */
#include <stdlib.h>
#include <unistd.h>
+#include <sys/mount.h>
#include "test.h"
#include "usctest.h"
#include "safe_macros.h"
+#define DIR_MODE (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
+ S_IXGRP|S_IROTH|S_IXOTH)
#define TEST_FILE1 "/"
#define TEST_FILE2 "/dev/null"
#define TEST_FILE3 "/tmp/does/not/exist"
#define TEST_FILE4 "/etc/fstab/"
#define TEST_FILE5 "./tmpfile"
+#define TEST_FILE6 "test_file_eloop1"
+#define TEST_FILE7 nametoolong
+#define TEST_FILE8 "mntpoint/tmp"
+
+static char nametoolong[PATH_MAX+2];
+static char *fstype = "ext2";
+static char *device;
+static int dflag;
+static int mount_flag;
static void setup(void);
static void cleanup(void);
static void setup2(void);
static void cleanup2(void);
static void acct_verify(int);
+static void help(void);
+
+static option_t options[] = {
+ {"T:", NULL, &fstype},
+ {"D:", &dflag, &device},
+ {NULL, NULL, NULL}
+};
static struct test_case_t {
char *filename;
@@ -73,18 +92,33 @@ static struct test_case_t {
{TEST_FILE3, "ENOENT", ENOENT, NULL, NULL},
{TEST_FILE4, "ENOTDIR", ENOTDIR, NULL, NULL},
{TEST_FILE5, "EPERM", EPERM, setup2, cleanup2},
+ {TEST_FILE6, "ELOOP", ELOOP, NULL, NULL},
+ {TEST_FILE7, "ENAMETOOLONG", ENAMETOOLONG, NULL, NULL},
+ {TEST_FILE8, "EROFS", EROFS, NULL, NULL},
};
char *TCID = "acct01";
int TST_TOTAL = ARRAY_SIZE(test_cases);
struct passwd *ltpuser;
-static int exp_enos[] = { EISDIR, EACCES, ENOENT, ENOTDIR, EPERM, 0 };
+static int exp_enos[] = { EISDIR, EACCES, ENOENT, ENOTDIR, EPERM,
+ ELOOP, ENAMETOOLONG, EROFS, 0 };
int main(int argc, char *argv[])
{
int lc;
+ char *msg;
int i;
+ msg = parse_opts(argc, argv, options, help);
+ if (msg != NULL)
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+ /* Check for mandatory option of the testcase */
+ if (!dflag) {
+ tst_brkm(TBROK, NULL, "you must specify the device used for "
+ "mounting with -D option");
+ }
+
setup();
TEST_EXP_ENOS(exp_enos);
@@ -101,10 +135,39 @@ int main(int argc, char *argv[])
static void setup(void)
{
+ int fd;
+
tst_require_root(NULL);
+ tst_mkfs(NULL, device, fstype, NULL);
+
tst_tmpdir();
+ SAFE_MKDIR(cleanup, "mntpoint", DIR_MODE);
+
+ /* ELOOP SETTING */
+ SAFE_SYMLINK(cleanup, TEST_FILE6, "test_file_eloop2");
+ SAFE_SYMLINK(cleanup, "test_file_eloop2", TEST_FILE6);
+
+ /* ENAMETOOLONG SETTING */
+ memset(nametoolong, 'a', PATH_MAX+1);
+
+ /* EROFS SETTING */
+ if (mount(device, "mntpoint", fstype, 0, NULL) < 0) {
+ tst_brkm(TBROK | TERRNO, cleanup,
+ "mount device:%s failed", device);
+ }
+ mount_flag = 1;
+ /* Create a file in the file system, then remount it as read-only */
+ fd = SAFE_CREAT(cleanup, TEST_FILE8, 0644);
+ SAFE_CLOSE(cleanup, fd);
+ if (mount(device, "mntpoint", fstype,
+ MS_REMOUNT | MS_RDONLY, NULL) < 0) {
+ tst_brkm(TBROK | TERRNO, cleanup,
+ "mount device:%s failed", device);
+ }
+ mount_flag = 1;
+
/* turn off acct, so we are in a known state */
if (acct(NULL) == -1) {
if (errno == ENOSYS) {
@@ -143,6 +206,7 @@ static void acct_verify(int i)
}
}
+/* EPERM SETTING */
static void setup2(void)
{
int fd;
@@ -169,6 +233,17 @@ static void cleanup(void)
if (acct(NULL) == -1)
tst_resm(TBROK | TERRNO, "acct(NULL) failed");
+ if (mount_flag && umount("mntpoint") < 0) {
+ tst_brkm(TBROK | TERRNO, NULL,
+ "umount device:%s failed", device);
+ }
tst_rmdir();
}
+
+static void help(void)
+{
+ printf("-T type : specifies the type of filesystem to be mounted. "
+ "Default ext2.\n");
+ printf("-D device : device used for mounting.\n");
+}
--
1.8.2.1
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next reply other threads:[~2013-10-22 10:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-22 10:27 Zeng Linggang [this message]
2013-10-23 12:52 ` [LTP] [PATCH] acct/acct01.c: Add ELOOP ENAMETOOLONG EROFS chrubis
2013-10-23 13:16 ` chrubis
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=5266530C.5070604@cn.fujitsu.com \
--to=zenglg.jy@cn.fujitsu.com \
--cc=ltp-list@lists.sourceforge.net \
/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 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.