summaryrefslogtreecommitdiff
path: root/tools/testing
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2026-07-06 14:01:59 +0100
committerMark Brown <broonie@kernel.org>2026-07-06 14:01:59 +0100
commitc2a154f5de2496f6eccf8c5ef6b6f10bd77b7eb6 (patch)
tree248edddfd95cb7f4cd9ac48890dcfb2f2625e315 /tools/testing
parent28a05eb3c3ee59ed89a3c296dd9876b5c3a91eec (diff)
parent9e05e91a9a847ed57926414bd7c2c5e54d6c56c6 (diff)
downloadlinux-next-c2a154f5de2496f6eccf8c5ef6b6f10bd77b7eb6.tar.gz
linux-next-c2a154f5de2496f6eccf8c5ef6b6f10bd77b7eb6.zip
Merge branch 'main' of https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/selftests/net/lib.sh25
1 files changed, 23 insertions, 2 deletions
diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh
index b3827b43782b..d46d2cec89e4 100644
--- a/tools/testing/selftests/net/lib.sh
+++ b/tools/testing/selftests/net/lib.sh
@@ -70,12 +70,33 @@ ksft_exit_status_merge()
$ksft_xfail $ksft_pass $ksft_skip $ksft_fail
}
+timestamp_ms()
+{
+ local now
+ local seconds
+ local nanoseconds
+
+ now=$(date -u +%s:%N) || return
+ seconds=${now%:*}
+ nanoseconds=${now#*:}
+
+ if [[ $nanoseconds =~ ^[0-9]+$ ]]; then
+ nanoseconds=${nanoseconds:0:9}
+ else
+ nanoseconds=0
+ fi
+
+ echo $((seconds * 1000 + 10#$nanoseconds / 1000000))
+}
+
loopy_wait()
{
local sleep_cmd=$1; shift
local timeout_ms=$1; shift
+ local start_time
+ local current_time
- local start_time="$(date -u +%s%3N)"
+ start_time=$(timestamp_ms) || return
while true
do
local out
@@ -84,7 +105,7 @@ loopy_wait()
return 0
fi
- local current_time="$(date -u +%s%3N)"
+ current_time=$(timestamp_ms) || return
if ((current_time - start_time > timeout_ms)); then
echo -n "$out"
return 1