All of lore.kernel.org
 help / color / mirror / Atom feed
From: naresh.kamboju@linaro.org <naresh.kamboju@linaro.org>
To: ltp@lists.linux.it
Subject: [LTP] [v2] readahead02: fix read_ahead_kb file not found
Date: Fri,  2 Sep 2016 16:12:33 +0530	[thread overview]
Message-ID: <1472812953-30811-1-git-send-email-naresh.kamboju@linaro.org> (raw)

From: Naresh Kamboju <naresh.kamboju@linaro.org>

Test case is looking for read_ahead_kb file on a partition device (8:2) and
not on block device (8:0/8:16/8:32/8:48). The appropriate block device that
holds the partition can be found at queue/read_ahead_kb entry.

Before patch readahead02 test broken,
readahead02    1  TBROK  :  safe_file_ops.c:144: Failed to open FILE
'/sys/dev/block/8:2/queue/read_ahead_kb' for reading at
readahead02.c:197: errno=ENOENT(2): No such file or directory

After applying patch,
readahead02    0  TINFO  :  creating test file of size: 67108864
readahead02    0  TINFO  :  max readahead size is: 131072
readahead02    0  TINFO  :  read_testfile(0)
readahead02    0  TINFO  :  max readahead size is: 131072
readahead02    0  TINFO  :  read_testfile(1)
readahead02    0  TINFO  :  max readahead size is: 131072
readahead02    1  TPASS  :  expected ret success - returned value = 0
readahead02    2  TPASS  :  offset is still at 0 as expected
readahead02    0  TINFO  :  read_testfile(0) took: 1437202 usec
readahead02    0  TINFO  :  read_testfile(1) took: 1361915 usec
readahead02    0  TINFO  :  read_testfile(0) read: 67108864 bytes
readahead02    0  TINFO  :  read_testfile(1) read: 0 bytes
readahead02    3  TPASS  :  readahead saved some I/O
readahead02    0  TINFO  :  cache can hold at least: 157404 kB
readahead02    0  TINFO  :  read_testfile(0) used cache: 65332 kB
readahead02    0  TINFO  :  read_testfile(1) used cache: 65636 kB
readahead02    4  TPASS  :  using cache as expected

Patch tested on aarch64 and x86_64.

Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>
---
 testcases/kernel/syscalls/readahead/readahead02.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c
index 53278be..97ab0a8 100644
--- a/testcases/kernel/syscalls/readahead/readahead02.c
+++ b/testcases/kernel/syscalls/readahead/readahead02.c
@@ -192,8 +192,13 @@ static long get_device_readahead(const char *fname)
 
 	if (stat(fname, &st) == -1)
 		tst_brkm(TBROK | TERRNO, cleanup, "stat");
-	snprintf(buf, sizeof(buf), "/sys/dev/block/%d:%d/queue/read_ahead_kb",
-		 major(st.st_dev), minor(st.st_dev));
+	if (minor(st.st_dev)) {
+		snprintf(buf, sizeof(buf), "/sys/dev/block/%d:%d/../queue/read_ahead_kb",
+			major(st.st_dev), minor(st.st_dev));
+	} else {
+		snprintf(buf, sizeof(buf), "/sys/dev/block/%d:%d/queue/read_ahead_kb",
+			major(st.st_dev), minor(st.st_dev));
+	}
 	SAFE_FILE_SCANF(cleanup, buf, "%ld", &ra_kb);
 
 	return ra_kb * 1024;
-- 
1.9.1


             reply	other threads:[~2016-09-02 10:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-02 10:42 naresh.kamboju [this message]
2016-09-05  7:36 ` [LTP] [v2] readahead02: fix read_ahead_kb file not found Jan Stancek
2016-09-06 12:33   ` Naresh Kamboju
2016-09-06 14:22     ` Jan Stancek
2016-09-13 13:56       ` Jan Stancek

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=1472812953-30811-1-git-send-email-naresh.kamboju@linaro.org \
    --to=naresh.kamboju@linaro.org \
    --cc=ltp@lists.linux.it \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.