From 3c2e0ba586355c957444338a66ea354a5c213026 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Wed, 3 Jun 2015 23:13:52 +0200 Subject: [PATCH 1/2] ipfs-test-lib: implement test_seq() License: MIT Signed-off-by: Christian Couder --- test/ipfs-test-lib.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/ipfs-test-lib.sh b/test/ipfs-test-lib.sh index 26821c14a52..e483817e14f 100644 --- a/test/ipfs-test-lib.sh +++ b/test/ipfs-test-lib.sh @@ -22,3 +22,16 @@ test_sort_cmp() { sort "$2" >"$2_sorted" && test_cmp "$1_sorted" "$2_sorted" } + +# Depending on GNU seq availability is not nice. +# Git also has test_seq but it uses Perl. +test_seq() { + test "$1" -le "$2" || return + i="$1" + j="$2" + while test "$i" -le "$j" + do + echo "$i" + i=$(expr "$i" + 1) + done +} From 59cac0a161d3b674efa1b15e6bc5c979978d7421 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Wed, 3 Jun 2015 23:53:24 +0200 Subject: [PATCH 2/2] test-lib: use test_seq() License: MIT Signed-off-by: Christian Couder --- test/sharness/lib/test-lib.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index 234477172db..d58fef6f005 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -52,7 +52,7 @@ fi . ../../ipfs-test-lib.sh test_cmp_repeat_10_sec() { - for i in `seq 1 100` + for i in $(test_seq 1 100) do test_cmp "$1" "$2" >/dev/null && return sleep 0.1 @@ -245,7 +245,7 @@ test_launch_ipfs_daemon_and_mount() { test_kill_repeat_10_sec() { # try to shut down once + wait for graceful exit kill $1 - for i in `seq 1 100` + for i in $(test_seq 1 100) do sleep 0.1 ! kill -0 $1 2>/dev/null && return