|
From: Cyril H. <su...@li...> - 2013-11-04 13:51:15
|
The branch, master, has been updated
via 508c3038734488b0e818a7442d4c52bd51a2fa7b (commit)
via e052e107bef9ff2b32a79d636d14ae5cf4194f23 (commit)
from bf30042a0362d03fbada0332e7e22191bf1525ee (commit)
- Log -----------------------------------------------------------------
commit 508c3038734488b0e818a7442d4c52bd51a2fa7b
Author: Cyril Hrubis <ch...@su...>
Date: Mon Nov 4 14:37:09 2013 +0100
acct01: Fix runtest files.
I've missed these when I was rebasing the acct01 patch.
Signed-off-by: Cyril Hrubis <ch...@su...>
commit e052e107bef9ff2b32a79d636d14ae5cf4194f23
Author: Zeng Linggang <zen...@cn...>
Date: Thu Oct 31 16:47:28 2013 +0800
acct/acct01.c: Add ELOOP ENAMETOOLONG EROFS
Add ELOOP, ENAMETOOLONG, EROFS error number test in acct01.c for acct(2)
Signed-off-by: Zeng Linggang <zen...@cn...>
-----------------------------------------------------------------------
Summary of changes:
runtest/ltplite | 2 +-
runtest/stress.part3 | 2 +-
runtest/syscalls | 2 +-
testcases/kernel/syscalls/acct/acct01.c | 73 ++++++++++++++++++++++++++++++-
4 files changed, 75 insertions(+), 4 deletions(-)
diff --git a/runtest/ltplite b/runtest/ltplite
index a6f57e2..f0738c7 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -67,7 +67,7 @@ access03 access03
access04 access04
access05 access05
-acct01 acct01
+acct01 acct01 -D DEVICE -T DEVICE_FS_TYPE
adjtimex01 adjtimex01
adjtimex02 adjtimex02
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index 2962cc4..951b00e 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -9,7 +9,7 @@ access03 access03
access04 access04
access05 access05
-acct01 acct01
+acct01 acct01 -D DEVICE -T DEVICE_FS_TYPE
adjtimex01 adjtimex01
adjtimex02 adjtimex02
diff --git a/runtest/syscalls b/runtest/syscalls
index b4bb201..e5a5508 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
add_key01 add_key01
add_key02 add_key02
diff --git a/testcases/kernel/syscalls/acct/acct01.c b/testcases/kernel/syscalls/acct/acct01.c
index 0fe973b..8236042 100644
--- a/testcases/kernel/syscalls/acct/acct01.c
+++ b/testcases/kernel/syscalls/acct/acct01.c
@@ -34,22 +34,41 @@
#include <stdio.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;
@@ -64,18 +83,33 @@ static struct test_case_t {
{TEST_FILE4, "ENOTDIR", ENOTDIR, NULL, NULL},
{TEST_FILE5, "EPERM", EPERM, setup2, cleanup2},
{NULL, "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);
static 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);
@@ -123,6 +157,31 @@ static void setup(void)
tst_brkm(TBROK | TERRNO, cleanup, "acct(NULL) failed");
}
}
+
+ /* 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 */
+ tst_mkfs(NULL, device, fstype, NULL);
+ SAFE_MKDIR(cleanup, "mntpoint", DIR_MODE);
+ 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;
}
static void acct_verify(int i)
@@ -141,6 +200,7 @@ static void acct_verify(int i)
test_cases[i].filename);
return;
}
+
if (TEST_ERRNO == test_cases[i].exp_errno) {
tst_resm(TPASS | TTERRNO, "acct failed as expected");
} else {
@@ -167,6 +227,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");
+}
hooks/post-receive
--
ltp
|