add EROFS test in fchmod06.c
Signed-off-by: Zeng Linggang <[email protected]>
---
runtest/ltplite | 2 +-
runtest/stress.part3 | 2 +-
runtest/syscalls | 2 +-
testcases/kernel/syscalls/fchmod/fchmod06.c | 64 ++++++++++++++++++++++++++++-
4 files changed, 65 insertions(+), 5 deletions(-)
diff --git a/runtest/ltplite b/runtest/ltplite
index 2382dec..253d91e 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -183,7 +183,7 @@ fchmod02 fchmod02
fchmod03 fchmod03
fchmod04 fchmod04
fchmod05 cp -p $LTPROOT/testcases/bin/change_owner $TMPDIR;fchmod05
-fchmod06 cp -p $LTPROOT/testcases/bin/change_owner $TMPDIR;fchmod06
+fchmod06 cp -p $LTPROOT/testcases/bin/change_owner $TMPDIR;fchmod06 -D DEVICE
-T DEVICE_FS_TYPE
fchmod07 fchmod07
fchown01 fchown01
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index 16247e9..5eca4f0 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -124,7 +124,7 @@ fchmod02 fchmod02
fchmod03 fchmod03
fchmod04 fchmod04
fchmod05 cp -p $LTPROOT/testcases/bin/change_owner $TMPDIR;fchmod05
-fchmod06 cp -p $LTPROOT/testcases/bin/change_owner $TMPDIR;fchmod06
+fchmod06 cp -p $LTPROOT/testcases/bin/change_owner $TMPDIR;fchmod06 -D DEVICE
-T DEVICE_FS_TYPE
fchmod07 fchmod07
fchown01 fchown01
diff --git a/runtest/syscalls b/runtest/syscalls
index 12bae10..adc5b6f 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -172,7 +172,7 @@ fchmod02 fchmod02
fchmod03 fchmod03
fchmod04 fchmod04
fchmod05 fchmod05
-fchmod06 fchmod06
+fchmod06 fchmod06 -D DEVICE -T DEVICE_FS_TYPE
fchmod07 fchmod07
#fchmodat test cases
diff --git a/testcases/kernel/syscalls/fchmod/fchmod06.c
b/testcases/kernel/syscalls/fchmod/fchmod06.c
index 93895a0..9608673 100644
--- a/testcases/kernel/syscalls/fchmod/fchmod06.c
+++ b/testcases/kernel/syscalls/fchmod/fchmod06.c
@@ -38,6 +38,7 @@
#include <unistd.h>
#include <grp.h>
#include <pwd.h>
+#include <sys/mount.h>
#include "test.h"
#include "usctest.h"
@@ -45,6 +46,17 @@
static int fd1;
static int fd2;
+static int fd3;
+static char *fstype = "ext2";
+static char *device;
+static int dflag;
+static int mount_flag;
+
+static option_t options[] = {
+ {"T:", NULL, &fstype},
+ {"D:", &dflag, &device},
+ {NULL, NULL, NULL}
+};
static struct test_case_t {
char *name;
@@ -54,14 +66,16 @@ static struct test_case_t {
} test_cases[] = {
{"EPERM", &fd1, 0644, EPERM},
{"EBADF", &fd2, 0644, EBADF},
+ {"EROFS", &fd3, 0644, EROFS},
};
char *TCID = "fchmod06";
int TST_TOTAL = ARRAY_SIZE(test_cases);
-static int exp_enos[] = { EPERM, EBADF, 0 };
+static int exp_enos[] = { EPERM, EBADF, EROFS, 0 };
static void setup(void);
static void cleanup(void);
+static void help(void);
int main(int ac, char **av)
{
@@ -69,9 +83,17 @@ int main(int ac, char **av)
char *msg;
int i;
- if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
+ msg = parse_opts(ac, av, 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);
@@ -122,6 +144,30 @@ static void setup(void)
tst_tmpdir();
+ tst_mkfs(NULL, device, fstype, NULL);
+
+ SAFE_MKDIR(cleanup, "mntpoint", 0755);
+
+ 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 */
+ fd3 = SAFE_CREAT(cleanup, "mntpoint/tfile_3", 0644);
+
+ SAFE_CLOSE(cleanup, fd3);
+
+ if (mount(device, "mntpoint", fstype,
+ MS_REMOUNT | MS_RDONLY, NULL) < 0) {
+ tst_brkm(TBROK | TERRNO, cleanup,
+ "mount device:%s failed", device);
+ }
+ mount_flag = 1;
+
+ fd3 = SAFE_OPEN(cleanup, "mntpoint/tfile_3", O_RDONLY);
+
fd1 = SAFE_OPEN(cleanup, "tfile_1", O_RDWR | O_CREAT, 0666);
fd2 = SAFE_OPEN(cleanup, "tfile_2", O_RDWR | O_CREAT, 0666);
@@ -141,5 +187,19 @@ static void cleanup(void)
SAFE_CLOSE(NULL, fd1);
+ SAFE_CLOSE(NULL, fd3);
+
+ 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
------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list