From: Han Pingtian <hanpt@linux.vnet.ibm.com>
To: ltp-list@lists.sourceforge.net
Subject: [LTP] [PATCH] performing test on loop device if noatime or relatime specified
Date: Mon, 4 May 2015 14:34:25 +0800 [thread overview]
Message-ID: <20150504063425.GA9995@localhost.localdomain> (raw)
Hi,
The noatime test of open12 fails on a distribution which doesn't
use tmpfs for /tmp. I have composed a patch to fix it. Please have a
look, thanks.
After 2.6.30, kernel specifies relatime option by default. If so then
try to mount a loop device using strictatime option to do the noatime
test.
Signed-off-by: Han Pingtian <hanpt@linux.vnet.ibm.com>
---
testcases/kernel/syscalls/open/open12.c | 41 +++++++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/syscalls/open/open12.c b/testcases/kernel/syscalls/open/open12.c
index 54ddfe0..f9be35b 100644
--- a/testcases/kernel/syscalls/open/open12.c
+++ b/testcases/kernel/syscalls/open/open12.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/mount.h>
#include <unistd.h>
#include <mntent.h>
#include <errno.h>
@@ -34,8 +35,16 @@
#define TEST_FILE "test_file"
#define LARGE_FILE "large_file"
+#define DIR_MODE 0755
+#define MNTPOINT "mntpoint"
+
char *TCID = "open12";
+static const char *device;
+static const char *fs_type;
+static unsigned int mount_flag = 0;
+static unsigned int cd_flag = 0;
+
static void setup(void);
static void cleanup(void);
static void test_append(void);
@@ -114,10 +123,21 @@ static void test_noatime(void)
}
if (tst_path_has_mnt_flags(cleanup, NULL, flags)) {
- tst_resm(TCONF,
- "test O_NOATIME flag for open needs filesystems which "
- "is mounted without noatime and relatime");
- return;
+
+ fs_type = tst_dev_fs_type();
+ device = tst_acquire_device(cleanup);
+
+ if (!device)
+ tst_brkm(TCONF, cleanup, "Failed to obtain block device");
+
+ tst_mkfs(cleanup, device, fs_type, NULL);
+
+ SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);
+ SAFE_MOUNT(cleanup, device, MNTPOINT, fs_type, MS_STRICTATIME, NULL);
+ mount_flag = 1;
+ SAFE_FILE_PRINTF(cleanup, MNTPOINT"/"TEST_FILE, TEST_FILE);
+ SAFE_CHDIR(cleanup, MNTPOINT);
+ cd_flag = 1;
}
SAFE_STAT(cleanup, TEST_FILE, &old_stat);
@@ -221,5 +241,18 @@ static void test_largefile(void)
static void cleanup(void)
{
+ if (cd_flag) {
+ char *tmp_dir = tst_get_tmpdir();
+ SAFE_CHDIR(NULL, tmp_dir);
+ free(tmp_dir);
+ }
+
+ if (mount_flag && tst_umount(MNTPOINT) == -1) {
+ tst_brkm(TBROK | TERRNO, NULL, "umount(2) failed");
+ }
+
+ if (device)
+ tst_release_device(NULL, device);
+
tst_rmdir();
}
--
1.9.3
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next reply other threads:[~2015-05-04 9:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-04 6:34 Han Pingtian [this message]
2015-05-04 11:53 ` [LTP] [PATCH] performing test on loop device if noatime or relatime specified Cyril Hrubis
2015-05-06 13:55 ` Han Pingtian
2015-05-07 12:48 ` Cyril Hrubis
2015-05-08 1:41 ` Han Pingtian
2015-05-12 12:50 ` Cui Bixuan
2015-05-12 13:48 ` Cyril Hrubis
[not found] ` <55530639.2070806@huawei.com>
2015-05-13 8:14 ` Cyril Hrubis
[not found] ` <55559C6A.9090001@huawei.com>
2015-05-18 11:56 ` [LTP] [PATCH] open/open12: compile error Cyril Hrubis
[not found] ` <55530742.3030707@huawei.com>
2015-05-13 9:03 ` [LTP] [PATCH] open/open12: Check the kernel version for 'MS_STRICTATIME' Cyril Hrubis
[not found] ` <5555A746.4080006@huawei.com>
2015-05-18 11:52 ` Cyril Hrubis
[not found] ` <5559DDD9.4090807@huawei.com>
2015-05-27 14:20 ` [LTP] [PATCH 2/2 v2] " Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150504063425.GA9995@localhost.localdomain \
--to=hanpt@linux.vnet.ibm.com \
--cc=ltp-list@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox