add ELOOP, EROFS in creat06.c
Signed-off-by: Zeng Linggang <[email protected]>
---
runtest/ltplite | 2 +-
runtest/stress.part3 | 2 +-
runtest/syscalls | 2 +-
testcases/kernel/syscalls/creat/creat06.c | 65 ++++++++++++++++++++++++++++++-
4 files changed, 66 insertions(+), 5 deletions(-)
diff --git a/runtest/ltplite b/runtest/ltplite
index 2382dec..5d70057 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -140,7 +140,7 @@ creat01 creat01
creat03 creat03
creat04 creat04
creat05 creat05
-creat06 creat06
+creat06 creat06 -D DEVICE -T DEVICE_FS_TYPE
creat07 creat07
creat08 creat08
creat09 creat09
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index 16247e9..277dd57 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -81,7 +81,7 @@ creat01 creat01
creat03 creat03
creat04 creat04
creat05 creat05
-creat06 creat06
+creat06 creat06 -D DEVICE -T DEVICE_FS_TYPE
creat07 creat07
creat08 creat08
creat09 creat09
diff --git a/runtest/syscalls b/runtest/syscalls
index 12bae10..1b860f7 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -98,7 +98,7 @@ creat01 creat01
creat03 creat03
creat04 creat04
creat05 creat05
-creat06 creat06
+creat06 creat06 -D DEVICE -T DEVICE_FS_TYPE
creat07 creat07
creat08 creat08
creat09 creat09
diff --git a/testcases/kernel/syscalls/creat/creat06.c
b/testcases/kernel/syscalls/creat/creat06.c
index 2b1a9ec..567db45 100644
--- a/testcases/kernel/syscalls/creat/creat06.c
+++ b/testcases/kernel/syscalls/creat/creat06.c
@@ -29,6 +29,8 @@
* 4. ENOTDIR
* 5. EFAULT
* 6. EACCES
+ * 7. EROFS
+ * 8. ELOOP
*
* ALGORITHM
* 1. Attempt to creat(2) an existing directory, and test for
@@ -43,6 +45,10 @@
* and test for EFAULT
* 6. Attempt to creat(2) a file in a directory with no
* execute permission and test for EACCES
+ * 7. Attempt to creat(2) a file in a Read-only file system
+ * and test for EROFS
+ * 8. Attempt to creat(2) a file which links the other file that
+ * links the former and test for ELOOP
*
* USAGE: <for command-line>
* creat06 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
@@ -68,6 +74,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <sys/mount.h>
#include "test.h"
#include "usctest.h"
#include "safe_macros.h"
@@ -76,17 +83,30 @@
#define NO_DIR "testfile/testdir"
#define NOT_DIR "file1/testdir"
#define TEST6_FILE "dir6/file6"
+#define TEST7_FILE "mntpoint/tmp"
+#define TEST8_FILE "file8"
#define MODE1 0444
#define MODE2 0666
static void setup(void);
static void cleanup(void);
+static void test8_setup(void);
+static void help(void);
#if !defined(UCLINUX)
static void bad_addr_setup(int);
#endif
static char long_name[PATH_MAX+2];
+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 *fname;
int mode;
@@ -101,12 +121,14 @@ static struct test_case_t {
{(char *)-1, MODE1, EFAULT, bad_addr_setup},
#endif
{TEST6_FILE, MODE1, EACCES, NULL},
+ {TEST7_FILE, MODE1, EROFS, NULL},
+ {TEST8_FILE, MODE1, ELOOP, test8_setup},
};
char *TCID = "creat06";
int TST_TOTAL = ARRAY_SIZE(TC);
static int exp_enos[] = { EISDIR, ENAMETOOLONG, ENOENT, ENOTDIR,
- EFAULT, EACCES, 0 };
+ EFAULT, EACCES, EROFS, ELOOP, 0 };
int main(int ac, char **av)
{
@@ -114,9 +136,16 @@ 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);
+ if (!dflag) {
+ tst_brkm(TBROK, NULL,
+ "you must specify the device used for mounting with "
+ "-D option");
+ }
+
setup();
TEST_EXP_ENOS(exp_enos);
@@ -175,6 +204,21 @@ static void setup(void)
SAFE_TOUCH(cleanup, "file1", MODE1, NULL);
SAFE_MKDIR(cleanup, "dir6", MODE2);
+
+ SAFE_SETEUID(cleanup, 0);
+
+ tst_mkfs(NULL, device, fstype, NULL);
+ SAFE_MKDIR(cleanup, "mntpoint", MODE2);
+ if (mount(device, "mntpoint", fstype, MS_RDONLY, NULL) < 0) {
+ tst_brkm(TBROK | TERRNO, cleanup,
+ "mount device:%s failed", device);
+ }
+ mount_flag = 1;
+
+ SAFE_SYMLINK(cleanup, TEST8_FILE, "test_file_eloop2");
+ SAFE_SYMLINK(cleanup, "test_file_eloop2", TEST8_FILE);
+
+ SAFE_SETEUID(cleanup, ltpuser->pw_uid);
}
#if !defined(UCLINUX)
@@ -185,9 +229,26 @@ static void bad_addr_setup(int i)
}
#endif
+static void test8_setup(void)
+{
+ SAFE_SETEUID(cleanup, 0);
+}
+
static void cleanup(void)
{
TEST_CLEANUP;
+ 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=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list