* [LTP] [PATCH 1/2 v2] mount/mount03.c: clean up
@ 2013-07-08 5:17 DAN LI
2013-07-08 5:18 ` [LTP] [PATCH 2/2 v2] mount/mount03.c: Test feature MS_NOATIME of mount(2) DAN LI
2013-07-10 2:10 ` [LTP] [PATCH 1/2 v2] mount/mount03.c: clean up Wanlong Gao
0 siblings, 2 replies; 5+ messages in thread
From: DAN LI @ 2013-07-08 5:17 UTC (permalink / raw)
To: LTP list
Clean up mount03.c:
xxx func() -> xxx func(void)
clean up setup()
Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
---
testcases/kernel/syscalls/mount/mount03.c | 179 +++++-------------------------
1 file changed, 27 insertions(+), 152 deletions(-)
diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
index b1aa71f..a4c065a 100644
--- a/testcases/kernel/syscalls/mount/mount03.c
+++ b/testcases/kernel/syscalls/mount/mount03.c
@@ -16,15 +16,7 @@
*/
/*
- * EXECUTED BY : root / superuser
- *
- * TEST TITLE : Test for checking mount(2) flags
- *
- * TEST CASE TOTAL : 6
- *
- * AUTHOR : Nirmala Devi Dhanasekar <nirmala.devi@wipro.com>
- *
- * DESCRIPTION
+ * DESCRIPTION
* Check for basic mount(2) system call flags.
*
* Verify that mount(2) syscall passes for each flag setting and validate
@@ -35,30 +27,7 @@
* 4) MS_SYNCHRONOUS - writes are synced at once.
* 5) MS_REMOUNT - alter flags of a mounted FS.
* 6) MS_NOSUID - ignore suid and sgid bits.
- *
- * Setup:
- * Setup signal handling.
- * Create a mount point.
- * Pause for SIGUSR1 if option specified.
- *
- * Test:
- * Loop if the proper options are given.
- * Execute mount system call for each flag
- * Validate each flag setting. if validation fails
- * Delete the mount point.
- * Log the errno and Issue a FAIL message.
- * Delete the mount point.
- * Otherwise, Issue a PASS message.
- *
- * Cleanup:
- * Print errno log and/or timing stats if options given
- * Delete the temporary directory(s)/file(s) created.
- *
- * RESTRICTIONS
- * test must run with the -D option
- * test doesn't support -c option to run it in parallel, as mount
- * syscall is not supposed to run in parallel.
- *****************************************************************************/
+ */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
@@ -73,14 +42,15 @@
#include <fcntl.h>
#include <pwd.h>
#include <unistd.h>
+
#include "test.h"
#include "usctest.h"
+#include "safe_macros.h"
static void help(void);
static void setup(void);
static void cleanup(void);
static int test_rwflag(int, int);
-static int setup_uid(void);
char *TCID = "mount03";
int TST_TOTAL = 6;
@@ -92,9 +62,9 @@ int TST_TOTAL = 6;
S_IXGRP|S_IROTH|S_IXOTH)
#define SUID_MODE (S_ISUID|S_IRUSR|S_IXUSR|S_IXGRP|S_IXOTH)
-static char *fs_type;
+static const char *fs_type = "ext2";
-static char mntpoint[20];
+static const char mntpoint[] = "mntpoint";
static char *fstype;
static char *device;
static int tflag;
@@ -104,9 +74,7 @@ static int fildes;
static char write_buffer[BUFSIZ];
static char read_buffer[BUFSIZ];
static char path_name[PATH_MAX];
-static char testhome_path[PATH_MAX];
static char file[PATH_MAX];
-static char *cmd = "cp";
long rwflags[] = {
MS_RDONLY,
@@ -138,21 +106,9 @@ int main(int argc, char *argv[])
"you must specify the device used for mounting with -D "
"option");
- if (tflag) {
- fs_type = malloc(strlen(fstype) + 1);
- if (fs_type == NULL)
- tst_brkm(TBROK | TERRNO, NULL, "malloc failed");
+ if (tflag)
+ fs_type = fstype;
- fs_type[strlen(fstype)] = '\0';
- strncpy(fs_type, fstype, strlen(fstype));
- } else {
- fs_type = malloc(strlen(DEFAULT_FSTYPE) + 1);
- if (fs_type == NULL)
- tst_brkm(TBROK | TERRNO, NULL, "malloc failed");
-
- strncpy(fs_type, DEFAULT_FSTYPE, strlen(DEFAULT_FSTYPE));
- fs_type[strlen(DEFAULT_FSTYPE)] = '\0';
- }
if (STD_COPIES != 1) {
tst_resm(TINFO, "-c option has no effect for this testcase - "
@@ -169,11 +125,9 @@ int main(int argc, char *argv[])
for (i = 0; i < TST_TOTAL; ++i) {
- /* Call mount(2) */
TEST(mount(device, mntpoint, fs_type, rwflags[i],
NULL));
- /* check return code */
if (TEST_RETURN != 0) {
tst_resm(TFAIL | TTERRNO, "mount(2) failed");
continue;
@@ -203,12 +157,12 @@ int main(int argc, char *argv[])
* test_rwflag(int i, int cnt)
* Validate the mount system call for rwflags.
*/
-
int test_rwflag(int i, int cnt)
{
int ret, fd, pid, status;
char nobody_uid[] = "nobody";
struct passwd *ltpuser;
+ struct stat setuid_test_stat;
switch (i) {
case 0:
@@ -337,21 +291,23 @@ int test_rwflag(int i, int cnt)
case 5:
/* Validate MS_NOSUID flag of mount call */
- if (setup_uid() != 0) {
- tst_resm(TBROK | TERRNO, "setup_uid failed");
- return 1;
- }
+ snprintf(file, PATH_MAX, "%ssetuid_test", path_name);
+ SAFE_FILE_PRINTF(cleanup, file, "TEST FILE");
+
+ if (stat(file, &setuid_test_stat) < 0)
+ tst_brkm(TBROK, cleanup, "stat for setuid_test failed");
+
+ if (setuid_test_stat.st_mode != SUID_MODE &&
+ chmod(file, SUID_MODE) < 0)
+ tst_brkm(TBROK, cleanup,
+ "setuid for setuid_test failed");
+
pid = fork();
switch (pid) {
case -1:
tst_resm(TBROK | TERRNO, "fork failed");
return 1;
case 0:
- snprintf(file, PATH_MAX, "%ssetuid_test", path_name);
- if (chmod(file, SUID_MODE) != 0)
- tst_resm(TWARN, "chmod(%s, %#o) failed",
- file, SUID_MODE);
-
ltpuser = getpwnam(nobody_uid);
if (setreuid(ltpuser->pw_uid, ltpuser->pw_uid) == -1)
tst_resm(TWARN | TERRNO,
@@ -374,68 +330,18 @@ int test_rwflag(int i, int cnt)
return 0;
}
-/* setup_uid() - performs setup for NOUID test */
-int setup_uid()
+void setup(void)
{
- int pid, status;
- char command[PATH_MAX];
-
- pid = fork();
- switch (pid) {
- case -1:
- tst_resm(TWARN | TERRNO, "fork failed");
- return 1;
- case 0:
- /* Put command into string */
- sprintf(command, "%s %s %s", cmd, testhome_path, path_name);
-
- /* Run command to cp file to right spot */
- if (system(command) == 0)
- execlp(file, basename(file), NULL);
- else
- printf("call to %s failed\n", command);
-
- exit(1);
- default:
- waitpid(pid, &status, 0);
- if (WIFEXITED(status)) {
- return WEXITSTATUS(status);
- } else if (WIFSIGNALED(status)) {
- return WTERMSIG(status);
- } else {
- /* Should be 0. */
- assert(status == 0);
- return 0;
- }
- }
-}
-
-void setup()
-{
- int fd;
char path[PATH_MAX];
- char *test_home;
- struct stat setuid_test_stat;
tst_sig(FORK, DEF_HANDLER, cleanup);
- /* Check whether we are root */
- if (geteuid() != 0) {
- free(fs_type);
- tst_brkm(TBROK, NULL, "Test must be run as root");
- }
+ tst_require_root(NULL);
tst_tmpdir();
- test_home = get_current_dir_name();
-
- sprintf(mntpoint, "mnt_%d", getpid());
-
- if (mkdir(mntpoint, DIR_MODE))
- tst_brkm(TBROK | TERRNO, cleanup, "mkdir(%s, %#o) failed",
- mntpoint, DIR_MODE);
+ SAFE_MKDIR(cleanup, mntpoint, DIR_MODE);
- /* Get the current working directory of the process */
if (getcwd(path_name, sizeof(path_name)) == NULL)
tst_brkm(TBROK, cleanup, "getcwd failed");
@@ -443,53 +349,22 @@ void setup()
tst_brkm(TBROK, cleanup, "chmod(%s, %#o) failed",
path_name, DIR_MODE);
- snprintf(file, PATH_MAX, "%s/setuid_test", path_name);
- fd = open(file, O_CREAT | O_TRUNC, S_IRWXU);
- if (fd == -1)
- tst_brkm(TBROK, cleanup, "open file failed");
- close(fd);
-
- if (stat(file, &setuid_test_stat) < 0) {
- tst_brkm(TBROK, cleanup, "stat for setuid_test failed");
- } else {
- if ((setuid_test_stat.st_uid || setuid_test_stat.st_gid) &&
- chown(file, 0, 0) < 0)
- tst_brkm(TBROK, cleanup,
- "chown for setuid_test failed");
-
- if (setuid_test_stat.st_mode != SUID_MODE &&
- chmod(file, SUID_MODE) < 0)
- tst_brkm(TBROK, cleanup,
- "setuid for setuid_test failed");
- }
-
- /*
- * under temporary directory
- */
strncpy(path, path_name, PATH_MAX);
snprintf(path_name, PATH_MAX, "%s/%s/", path, mntpoint);
- strcpy(testhome_path, test_home);
- strcat(testhome_path, "/setuid_test");
TEST_PAUSE;
-
}
-void cleanup()
+void cleanup(void)
{
- free(fs_type);
-
TEST_CLEANUP;
tst_rmdir();
}
-/*
- * issue a help message
- */
-void help()
+void help(void)
{
- printf("-T type : specifies the type of filesystem to be mounted."
- " Default ext2.\n");
+ printf("-T type : specifies the type of filesystem to be mounted. "
+ "Default ext2.\n");
printf("-D device : device used for mounting.\n");
}
--
1.8.1
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 5+ messages in thread* [LTP] [PATCH 2/2 v2] mount/mount03.c: Test feature MS_NOATIME of mount(2)
2013-07-08 5:17 [LTP] [PATCH 1/2 v2] mount/mount03.c: clean up DAN LI
@ 2013-07-08 5:18 ` DAN LI
2013-07-10 2:10 ` [LTP] [PATCH 1/2 v2] mount/mount03.c: clean up Wanlong Gao
1 sibling, 0 replies; 5+ messages in thread
From: DAN LI @ 2013-07-08 5:18 UTC (permalink / raw)
To: LTP list
Additional test for feature MS_NOATIME.
---
testcases/kernel/syscalls/mount/mount03.c | 51 ++++++++++++++++++++++++++++---
1 file changed, 47 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
index a4c065a..d3f0733 100644
--- a/testcases/kernel/syscalls/mount/mount03.c
+++ b/testcases/kernel/syscalls/mount/mount03.c
@@ -27,6 +27,7 @@
* 4) MS_SYNCHRONOUS - writes are synced at once.
* 5) MS_REMOUNT - alter flags of a mounted FS.
* 6) MS_NOSUID - ignore suid and sgid bits.
+ * 7) MS_NOATIME - do not update access times.
*/
#ifndef _GNU_SOURCE
@@ -53,7 +54,7 @@ static void cleanup(void);
static int test_rwflag(int, int);
char *TCID = "mount03";
-int TST_TOTAL = 6;
+int TST_TOTAL = 7;
#define DEFAULT_FSTYPE "ext2"
#define TEMP_FILE "temp_file"
@@ -83,6 +84,7 @@ long rwflags[] = {
MS_SYNCHRONOUS,
MS_RDONLY,
MS_NOSUID,
+ MS_NOATIME,
};
static option_t options[] = {
@@ -161,8 +163,9 @@ int test_rwflag(int i, int cnt)
{
int ret, fd, pid, status;
char nobody_uid[] = "nobody";
+ time_t atime;
struct passwd *ltpuser;
- struct stat setuid_test_stat;
+ struct stat file_stat;
switch (i) {
case 0:
@@ -294,10 +297,10 @@ int test_rwflag(int i, int cnt)
snprintf(file, PATH_MAX, "%ssetuid_test", path_name);
SAFE_FILE_PRINTF(cleanup, file, "TEST FILE");
- if (stat(file, &setuid_test_stat) < 0)
+ if (stat(file, &file_stat) < 0)
tst_brkm(TBROK, cleanup, "stat for setuid_test failed");
- if (setuid_test_stat.st_mode != SUID_MODE &&
+ if (file_stat.st_mode != SUID_MODE &&
chmod(file, SUID_MODE) < 0)
tst_brkm(TBROK, cleanup,
"setuid for setuid_test failed");
@@ -326,6 +329,46 @@ int test_rwflag(int i, int cnt)
return 1;
}
}
+ case 6:
+ /* Validate MS_NOATIME flag of mount call */
+
+ snprintf(file, PATH_MAX, "%satime", path_name);
+ fd = open(file, O_CREAT | O_RDWR, S_IRWXU);
+ if (fd == -1) {
+ tst_resm(TWARN | TERRNO, "opening %s failed", file);
+ return 1;
+ }
+
+ if (write(fd, "TEST_MS_NOATIME", 15) != 15) {
+ tst_resm(TWARN | TERRNO, "write %s failed", file);
+ return 1;
+ }
+
+ if (fstat(fd, &file_stat) == -1) {
+ tst_resm(TWARN | TERRNO, "stat %s failed #1", file);
+ return 1;
+ }
+
+ atime = file_stat.st_atime;
+
+ sleep(1);
+
+ if (read(fd, NULL, 20) == -1) {
+ tst_resm(TWARN | TERRNO, "read %s failed", file);
+ return 1;
+ }
+
+ if (fstat(fd, &file_stat) == -1) {
+ tst_resm(TWARN | TERRNO, "stat %s failed #2", file);
+ return 1;
+ }
+ close(fd);
+
+ if (file_stat.st_atime != atime) {
+ tst_resm(TWARN, "access time is updated");
+ return 1;
+ }
+ return 0;
}
return 0;
}
--
1.8.1
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [LTP] [PATCH 1/2 v2] mount/mount03.c: clean up
2013-07-08 5:17 [LTP] [PATCH 1/2 v2] mount/mount03.c: clean up DAN LI
2013-07-08 5:18 ` [LTP] [PATCH 2/2 v2] mount/mount03.c: Test feature MS_NOATIME of mount(2) DAN LI
@ 2013-07-10 2:10 ` Wanlong Gao
1 sibling, 0 replies; 5+ messages in thread
From: Wanlong Gao @ 2013-07-10 2:10 UTC (permalink / raw)
To: DAN LI; +Cc: LTP list
On 07/08/2013 01:17 PM, DAN LI wrote:
> Clean up mount03.c:
> xxx func() -> xxx func(void)
>
> clean up setup()
>
>
> Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
Applied V2 series, thank you.
Wanlong Gao
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 5+ messages in thread
* [LTP] [PATCH 1/2] mount/mount03.c: clean up
@ 2013-07-02 6:21 DAN LI
2013-07-02 6:35 ` [LTP] [PATCH 2/2 v2] mount/mount03.c: Test feature MS_NOATIME of mount(2) DAN LI
0 siblings, 1 reply; 5+ messages in thread
From: DAN LI @ 2013-07-02 6:21 UTC (permalink / raw)
To: LTP list
Clean up mount03.c:
xxx func() -> xxx func(void)
clean up setup()
Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
---
testcases/kernel/syscalls/mount/mount03.c | 47 ++++++++++---------------------
1 file changed, 15 insertions(+), 32 deletions(-)
diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
index b1aa71f..8b2d3e4 100644
--- a/testcases/kernel/syscalls/mount/mount03.c
+++ b/testcases/kernel/syscalls/mount/mount03.c
@@ -85,6 +85,7 @@ static int setup_uid(void);
char *TCID = "mount03";
int TST_TOTAL = 6;
+#define EXEC_COMMAND "cp"
#define DEFAULT_FSTYPE "ext2"
#define TEMP_FILE "temp_file"
#define FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
@@ -106,7 +107,6 @@ static char read_buffer[BUFSIZ];
static char path_name[PATH_MAX];
static char testhome_path[PATH_MAX];
static char file[PATH_MAX];
-static char *cmd = "cp";
long rwflags[] = {
MS_RDONLY,
@@ -375,7 +375,7 @@ int test_rwflag(int i, int cnt)
}
/* setup_uid() - performs setup for NOUID test */
-int setup_uid()
+int setup_uid(void)
{
int pid, status;
char command[PATH_MAX];
@@ -387,7 +387,8 @@ int setup_uid()
return 1;
case 0:
/* Put command into string */
- sprintf(command, "%s %s %s", cmd, testhome_path, path_name);
+ sprintf(command, "%s %s %s",
+ EXEC_COMMAND, testhome_path, path_name);
/* Run command to cp file to right spot */
if (system(command) == 0)
@@ -410,25 +411,17 @@ int setup_uid()
}
}
-void setup()
+void setup(void)
{
- int fd;
char path[PATH_MAX];
- char *test_home;
struct stat setuid_test_stat;
tst_sig(FORK, DEF_HANDLER, cleanup);
- /* Check whether we are root */
- if (geteuid() != 0) {
- free(fs_type);
- tst_brkm(TBROK, NULL, "Test must be run as root");
- }
+ tst_require_root(NULL);
tst_tmpdir();
- test_home = get_current_dir_name();
-
sprintf(mntpoint, "mnt_%d", getpid());
if (mkdir(mntpoint, DIR_MODE))
@@ -444,38 +437,28 @@ void setup()
path_name, DIR_MODE);
snprintf(file, PATH_MAX, "%s/setuid_test", path_name);
- fd = open(file, O_CREAT | O_TRUNC, S_IRWXU);
- if (fd == -1)
+ if (open(file, O_CREAT | O_TRUNC, S_IRWXU) == -1)
tst_brkm(TBROK, cleanup, "open file failed");
- close(fd);
- if (stat(file, &setuid_test_stat) < 0) {
+ if (stat(file, &setuid_test_stat) < 0)
tst_brkm(TBROK, cleanup, "stat for setuid_test failed");
- } else {
- if ((setuid_test_stat.st_uid || setuid_test_stat.st_gid) &&
- chown(file, 0, 0) < 0)
- tst_brkm(TBROK, cleanup,
- "chown for setuid_test failed");
-
- if (setuid_test_stat.st_mode != SUID_MODE &&
- chmod(file, SUID_MODE) < 0)
- tst_brkm(TBROK, cleanup,
- "setuid for setuid_test failed");
- }
+
+ if (setuid_test_stat.st_mode != SUID_MODE && chmod(file, SUID_MODE) < 0)
+ tst_brkm(TBROK, cleanup,
+ "setuid for setuid_test failed");
/*
* under temporary directory
*/
+ strcpy(testhome_path, file);
strncpy(path, path_name, PATH_MAX);
snprintf(path_name, PATH_MAX, "%s/%s/", path, mntpoint);
- strcpy(testhome_path, test_home);
- strcat(testhome_path, "/setuid_test");
TEST_PAUSE;
}
-void cleanup()
+void cleanup(void)
{
free(fs_type);
@@ -487,7 +470,7 @@ void cleanup()
/*
* issue a help message
*/
-void help()
+void help(void)
{
printf("-T type : specifies the type of filesystem to be mounted."
" Default ext2.\n");
--
1.8.1
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 5+ messages in thread* [LTP] [PATCH 2/2 v2] mount/mount03.c: Test feature MS_NOATIME of mount(2)
2013-07-02 6:21 [LTP] [PATCH 1/2] " DAN LI
@ 2013-07-02 6:35 ` DAN LI
2013-07-09 14:57 ` chrubis
0 siblings, 1 reply; 5+ messages in thread
From: DAN LI @ 2013-07-02 6:35 UTC (permalink / raw)
To: LTP list
Additional test for features MS_NOATIME.
Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
---
testcases/kernel/syscalls/mount/mount03.c | 48 +++++++++++++++++++++++++++++--
1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
index 8b2d3e4..6974107 100644
--- a/testcases/kernel/syscalls/mount/mount03.c
+++ b/testcases/kernel/syscalls/mount/mount03.c
@@ -20,7 +20,7 @@
*
* TEST TITLE : Test for checking mount(2) flags
*
- * TEST CASE TOTAL : 6
+ * TEST CASE TOTAL : 7
*
* AUTHOR : Nirmala Devi Dhanasekar <nirmala.devi@wipro.com>
*
@@ -35,6 +35,7 @@
* 4) MS_SYNCHRONOUS - writes are synced at once.
* 5) MS_REMOUNT - alter flags of a mounted FS.
* 6) MS_NOSUID - ignore suid and sgid bits.
+ * 7) MS_NOATIME - do not update access times.
*
* Setup:
* Setup signal handling.
@@ -83,7 +84,7 @@ static int test_rwflag(int, int);
static int setup_uid(void);
char *TCID = "mount03";
-int TST_TOTAL = 6;
+int TST_TOTAL = 7;
#define EXEC_COMMAND "cp"
#define DEFAULT_FSTYPE "ext2"
@@ -115,6 +116,7 @@ long rwflags[] = {
MS_SYNCHRONOUS,
MS_RDONLY,
MS_NOSUID,
+ MS_NOATIME,
};
static option_t options[] = {
@@ -208,6 +210,8 @@ int test_rwflag(int i, int cnt)
{
int ret, fd, pid, status;
char nobody_uid[] = "nobody";
+ time_t atime;
+ struct stat file_stat;
struct passwd *ltpuser;
switch (i) {
@@ -370,6 +374,46 @@ int test_rwflag(int i, int cnt)
return 1;
}
}
+ case 6:
+ /* Validate MS_NOATIME flag of mount call */
+
+ snprintf(file, PATH_MAX, "%satime", path_name);
+ fd = open(file, O_CREAT | O_RDWR, S_IRWXU);
+ if (fd == -1) {
+ tst_resm(TWARN | TERRNO, "opening %s failed", file);
+ return 1;
+ }
+
+ if (write(fd, "TEST_MS_NOATIME", 15) != 15) {
+ tst_resm(TWARN | TERRNO, "write %s failed", file);
+ return 1;
+ }
+
+ if (fstat(fd, &file_stat) == -1) {
+ tst_resm(TWARN | TERRNO, "stat %s failed #1", file);
+ return 1;
+ }
+
+ atime = file_stat.st_atime;
+
+ sleep(1);
+
+ if (read(fd, NULL, 20) == -1) {
+ tst_resm(TWARN | TERRNO, "read %s failed", file);
+ return 1;
+ }
+
+ if (fstat(fd, &file_stat) == -1) {
+ tst_resm(TWARN | TERRNO, "stat %s failed #2", file);
+ return 1;
+ }
+ close(fd);
+
+ if (file_stat.st_atime != atime) {
+ tst_resm(TWARN, "access time is updated");
+ return 1;
+ }
+ return 0;
}
return 0;
}
--
1.8.1
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [LTP] [PATCH 2/2 v2] mount/mount03.c: Test feature MS_NOATIME of mount(2)
2013-07-02 6:35 ` [LTP] [PATCH 2/2 v2] mount/mount03.c: Test feature MS_NOATIME of mount(2) DAN LI
@ 2013-07-09 14:57 ` chrubis
0 siblings, 0 replies; 5+ messages in thread
From: chrubis @ 2013-07-09 14:57 UTC (permalink / raw)
To: DAN LI; +Cc: LTP list
Hi!
> Additional test for features MS_NOATIME.
>
> Signed-off-by: DAN LI <li.dan@cn.fujitsu.com>
> ---
> + case 6:
> + /* Validate MS_NOATIME flag of mount call */
> +
> + snprintf(file, PATH_MAX, "%satime", path_name);
> + fd = open(file, O_CREAT | O_RDWR, S_IRWXU);
> + if (fd == -1) {
> + tst_resm(TWARN | TERRNO, "opening %s failed", file);
> + return 1;
> + }
> +
> + if (write(fd, "TEST_MS_NOATIME", 15) != 15) {
> + tst_resm(TWARN | TERRNO, "write %s failed", file);
> + return 1;
> + }
> +
> + if (fstat(fd, &file_stat) == -1) {
> + tst_resm(TWARN | TERRNO, "stat %s failed #1", file);
> + return 1;
> + }
> +
> + atime = file_stat.st_atime;
> +
> + sleep(1);
> +
> + if (read(fd, NULL, 20) == -1) {
> + tst_resm(TWARN | TERRNO, "read %s failed", file);
> + return 1;
> + }
> +
> + if (fstat(fd, &file_stat) == -1) {
> + tst_resm(TWARN | TERRNO, "stat %s failed #2", file);
> + return 1;
> + }
> + close(fd);
> +
> + if (file_stat.st_atime != atime) {
> + tst_resm(TWARN, "access time is updated");
> + return 1;
> + }
> + return 0;
> }
This version looks fine.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-07-10 2:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-08 5:17 [LTP] [PATCH 1/2 v2] mount/mount03.c: clean up DAN LI
2013-07-08 5:18 ` [LTP] [PATCH 2/2 v2] mount/mount03.c: Test feature MS_NOATIME of mount(2) DAN LI
2013-07-10 2:10 ` [LTP] [PATCH 1/2 v2] mount/mount03.c: clean up Wanlong Gao
-- strict thread matches above, loose matches on Subject: below --
2013-07-02 6:21 [LTP] [PATCH 1/2] " DAN LI
2013-07-02 6:35 ` [LTP] [PATCH 2/2 v2] mount/mount03.c: Test feature MS_NOATIME of mount(2) DAN LI
2013-07-09 14:57 ` chrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox