Add EFBIG test in fallocate02.c
Signed-off-by: Zeng Linggang <[email protected]>
---
runtest/syscalls | 2 +-
testcases/kernel/syscalls/fallocate/fallocate02.c | 52 +++++++++++++++++++++--
2 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/runtest/syscalls b/runtest/syscalls
index 12bae10..e561175 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -150,7 +150,7 @@ faccessat01 faccessat01
#fallocate test cases
fallocate01 fallocate01
-fallocate02 fallocate02
+fallocate02 fallocate02 -D DEVICE
fallocate03 fallocate03
#posix_fadvise test cases
diff --git a/testcases/kernel/syscalls/fallocate/fallocate02.c
b/testcases/kernel/syscalls/fallocate/fallocate02.c
index 8838cff..84967a1 100644
--- a/testcases/kernel/syscalls/fallocate/fallocate02.c
+++ b/testcases/kernel/syscalls/fallocate/fallocate02.c
@@ -34,6 +34,7 @@
#include <fcntl.h>
#include <inttypes.h>
#include <sys/utsname.h>
+#include <sys/mount.h>
#include "test.h"
#include "usctest.h"
@@ -47,15 +48,31 @@
#define DEFAULT_TEST_MODE 1
#endif
#define OFFSET 12
+/*
+ * block_size is 1024, then the maximum file size is MAX_FILE * block_size: 4T
+ * block_size is 4096, then the maximum file size is MAX_FILE * block_size: 16T
+ */
+#define MAX_FILE (4L*1024*1024*1024)
+#define DIR_MODE (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
+ S_IXGRP|S_IROTH|S_IXOTH)
#define FNAMER "test_file1"
#define FNAMEW "test_file2"
static void setup(void);
static void cleanup(void);
+static void help(void);
static int fdw;
static int fdr;
static int block_size;
+static char *device;
+static int dflag;
+static int mount_flag;
+
+static option_t options[] = {
+ {"D:", &dflag, &device},
+ {NULL, NULL, NULL}
+};
static struct test_data_t {
int *fd;
@@ -72,6 +89,8 @@ static struct test_data_t {
{&fdw, FNAMEW, DEFAULT_TEST_MODE, BLOCKS_WRITTEN, -1, EINVAL},
{&fdw, FNAMEW, DEFAULT_TEST_MODE, -(BLOCKS_WRITTEN+OFFSET), 1, EINVAL},
{&fdw, FNAMEW, DEFAULT_TEST_MODE, BLOCKS_WRITTEN-OFFSET, 1, 0},
+ {&fdw, FNAMEW, DEFAULT_TEST_MODE, MAX_FILE, 1, EFBIG},
+ {&fdw, FNAMEW, DEFAULT_TEST_MODE, 0, MAX_FILE, EFBIG},
};
TCID_DEFINE(fallocate02);
@@ -83,10 +102,17 @@ int main(int ac, char **av)
int i;
char *msg;
- 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);
+ /* 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();
for (lc = 0; TEST_LOOPING(lc); lc++) {
@@ -141,9 +167,17 @@ static void setup(void)
tst_tmpdir();
- fdr = SAFE_OPEN(cleanup, FNAMER, O_RDONLY | O_CREAT, S_IRUSR);
+ tst_mkfs(NULL, device, "ext4", NULL);
+ SAFE_MKDIR(cleanup, "mntpoint", DIR_MODE);
+ if (mount(device, "mntpoint", "ext4", 0, NULL) < 0) {
+ tst_brkm(TBROK | TERRNO, cleanup,
+ "mount device:%s failed", device);
+ }
+ mount_flag = 1;
- fdw = SAFE_OPEN(cleanup, FNAMEW, O_RDWR | O_CREAT, S_IRWXU);
+ fdr = SAFE_OPEN(cleanup, "mntpoint/"FNAMER,
+ O_RDONLY | O_CREAT, S_IRUSR);
+ fdw = SAFE_OPEN(cleanup, "mntpoint/"FNAMEW, O_RDWR | O_CREAT, S_IRWXU);
SAFE_FSTAT(cleanup, fdr, &file_stat);
@@ -156,5 +190,17 @@ static void cleanup(void)
SAFE_CLOSE(NULL, fdr);
+ 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 ext4.\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