From: Bart Van Assche <bvanassche@acm.org>
To: Omar Sandoval <osandov@fb.com>
Cc: linux-block@vger.kernel.org,
Johannes Thumshirn <jthumshirn@suse.de>,
Bart Van Assche <bvanassche@acm.org>
Subject: [PATCH blktests 1/2] Move and rename uptime_s()
Date: Mon, 21 Oct 2019 15:57:18 -0700 [thread overview]
Message-ID: <20191021225719.211651-2-bvanassche@acm.org> (raw)
In-Reply-To: <20191021225719.211651-1-bvanassche@acm.org>
Make it easy to use the uptime_s() function from block tests.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
common/multipath-over-rdma | 9 +--------
common/rc | 9 +++++++++
tests/nvmeof-mp/rc | 2 +-
tests/srp/014 | 2 +-
tests/srp/rc | 2 +-
5 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/common/multipath-over-rdma b/common/multipath-over-rdma
index 65ebb7b7f5f7..545a81e8c18e 100644
--- a/common/multipath-over-rdma
+++ b/common/multipath-over-rdma
@@ -129,19 +129,12 @@ held_by() {
done
}
-# System uptime in seconds.
-uptime_s() {
- local a b
-
- echo "$(</proc/uptime)" | { read -r a b && echo "${a%%.*}"; }
-}
-
# Sleep until either $1 seconds have elapsed or until the deadline $2 has been
# reached. Return 1 if and only if the deadline has been met.
sleep_until() {
local duration=$1 deadline=$2 u
- u=$(uptime_s)
+ u=$(_uptime_s)
if [ $((u + duration)) -le "$deadline" ]; then
sleep "$duration"
else
diff --git a/common/rc b/common/rc
index 41aee3aaa735..c00f2fe1f463 100644
--- a/common/rc
+++ b/common/rc
@@ -246,3 +246,12 @@ _test_dev_is_partition() {
_filter_xfs_io_error() {
sed -e 's/^\(.*\)64\(: .*$\)/\1\2/'
}
+
+# System uptime in seconds.
+_uptime_s() {
+ local a b
+
+ echo "$(</proc/uptime)" | {
+ read -r a b && echo "$b" >/dev/null && echo "${a%%.*}";
+ }
+}
diff --git a/tests/nvmeof-mp/rc b/tests/nvmeof-mp/rc
index 2493fcee12de..278843a1270d 100755
--- a/tests/nvmeof-mp/rc
+++ b/tests/nvmeof-mp/rc
@@ -113,7 +113,7 @@ simulate_network_failure_loop() {
[ -e "$dev" ] || return $?
[ -n "$duration" ] || return $?
- deadline=$(($(uptime_s) + duration))
+ deadline=$(($(_uptime_s) + duration))
while [ $rc = 0 ]; do
sleep_until 5 ${deadline} || break
for d in $(held_by "$dev"); do
diff --git a/tests/srp/014 b/tests/srp/014
index 8ecd8a439a82..7afde6284b83 100755
--- a/tests/srp/014
+++ b/tests/srp/014
@@ -69,7 +69,7 @@ sg_reset_loop() {
[ -e "$dev" ] || return $?
[ -n "$duration" ] || return $?
reset_type=(-d -b)
- deadline=$(($(uptime_s) + duration))
+ deadline=$(($(_uptime_s) + duration))
while true; do
sleep_until 1 ${deadline} || break
cmd="sg_reset --no-esc ${reset_type[i++ % 2]} $dev"
diff --git a/tests/srp/rc b/tests/srp/rc
index 696d94e5fb97..a1bc09b496ec 100755
--- a/tests/srp/rc
+++ b/tests/srp/rc
@@ -247,7 +247,7 @@ simulate_network_failure_loop() {
[ -e "$dev" ] || return $?
[ -n "$duration" ] || return $?
- deadline=$(($(uptime_s) + duration))
+ deadline=$(($(_uptime_s) + duration))
s=5
while [ $rc = 0 ]; do
sleep_until 5 ${deadline} || break
--
2.23.0.866.gb869b98d4c-goog
next prev parent reply other threads:[~2019-10-21 22:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-21 22:57 [PATCH blktests 0/2] Add a test that triggers blk_mq_update_nr_hw_queues() Bart Van Assche
2019-10-21 22:57 ` Bart Van Assche [this message]
2019-10-22 17:55 ` [PATCH blktests 1/2] Move and rename uptime_s() Chaitanya Kulkarni
2019-10-24 17:27 ` Omar Sandoval
2019-10-24 17:41 ` Bart Van Assche
2019-10-24 17:44 ` Omar Sandoval
2019-10-21 22:57 ` [PATCH blktests 2/2] Add a test that triggers blk_mq_update_nr_hw_queues() Bart Van Assche
2019-10-22 17:59 ` Chaitanya Kulkarni
2019-10-24 17:42 ` Omar Sandoval
2019-10-24 17:55 ` Bart Van Assche
2019-10-24 17:58 ` Omar Sandoval
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=20191021225719.211651-2-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=jthumshirn@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=osandov@fb.com \
/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;
as well as URLs for NNTP newsgroup(s).