Add EROFS error number test for fchown(2)
and add '-D option' for fchown04
Signed-off-by: Zeng Linggang <[email protected]>
---
runtest/ltplite | 2 +-
runtest/stress.part3 | 2 +-
runtest/syscalls | 4 +--
testcases/kernel/syscalls/fchown/fchown04.c | 56 +++++++++++++++++++++++++++--
4 files changed, 58 insertions(+), 6 deletions(-)
diff --git a/runtest/ltplite b/runtest/ltplite
index c90bc48..c553746 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -189,7 +189,7 @@ fchmod07 fchmod07
fchown01 fchown01
fchown02 fchown02
fchown03 cp -p $LTPROOT/testcases/bin/change_owner $TMPDIR;fchown03
-fchown04 export change_owner=$LTPROOT/testcases/bin/change_owner;fchown04
+fchown04 fchown04 -D DEVICE -T DEVICE_FS_TYPE
fchown05 fchown05
fcntl01 fcntl01
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index eac28d0..90cd030 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -130,7 +130,7 @@ fchmod07 fchmod07
fchown01 fchown01
fchown02 fchown02
fchown03 cp -p $LTPROOT/testcases/bin/change_owner $TMPDIR;fchown03
-fchown04 export change_owner=$LTPROOT/testcases/bin/change_owner;fchown04
+fchown04 fchown04 -D DEVICE -T DEVICE_FS_TYPE
fchown05 fchown05
fcntl01 fcntl01
diff --git a/runtest/syscalls b/runtest/syscalls
index c5bbe8f..d7b93f2 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -185,8 +185,8 @@ fchown02 fchown02
fchown02_16 fchown02_16
fchown03 fchown03
fchown03_16 fchown03_16
-fchown04 fchown04
-fchown04_16 fchown04_16
+fchown04 fchown04 -D DEVICE -T DEVICE_FS_TYPE
+fchown04_16 fchown04_16 -D DEVICE -T DEVICE_FS_TYPE
fchown05 fchown05
fchown05_16 fchown05_16
diff --git a/testcases/kernel/syscalls/fchown/fchown04.c
b/testcases/kernel/syscalls/fchown/fchown04.c
index f5772e3..dd7f16a 100644
--- a/testcases/kernel/syscalls/fchown/fchown04.c
+++ b/testcases/kernel/syscalls/fchown/fchown04.c
@@ -33,14 +33,28 @@
#include <pwd.h>
#include <sys/types.h>
#include <sys/stat.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)
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 {
int *fd;
@@ -48,14 +62,16 @@ static struct test_case_t {
} test_cases[] = {
{&fd1, EPERM},
{&fd2, EBADF},
+ {&fd3, EROFS},
};
char *TCID = "fchown04";
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)
{
@@ -65,10 +81,16 @@ int main(int ac, char **av)
uid_t user_id;
gid_t group_id;
- msg = parse_opts(ac, av, NULL, NULL);
+ msg = parse_opts(ac, av, options, help);
if (msg != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ if (!dflag) {
+ tst_brkm(TBROK, NULL,
+ "you must specify the device used for mounting with "
+ "-D option");
+ }
+
setup();
TEST_EXP_ENOS(exp_enos);
@@ -121,6 +143,22 @@ static void setup(void)
fd1 = SAFE_OPEN(cleanup, "tfile_1", O_RDWR | O_CREAT, 0666);
+ 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;
+ SAFE_TOUCH(cleanup, "mntpoint/tfile_3", 0644, NULL);
+ 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);
+
fd2 = SAFE_OPEN(cleanup, "tfile_2", O_RDWR | O_CREAT, 0666);
SAFE_CLOSE(cleanup, fd2);
@@ -136,5 +174,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
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list