FYI, two small test-related patches

Jim Meyering jim at meyering.net
Tue Oct 19 14:53:04 UTC 2010


These make it slightly easier to see what's going on it tests.

>From 32a041e25d2c1c9d6e4c353ce8db6649aed62954 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Tue, 19 Oct 2010 16:50:57 +0200
Subject: [PATCH 1/2] tests: wait_for: report how long we waited, or that timeout expired

* t/init.cfg (wait_for): Tell how long we wait.
---
 t/init.cfg |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/t/init.cfg b/t/init.cfg
index bffe669..90bb390 100644
--- a/t/init.cfg
+++ b/t/init.cfg
@@ -31,9 +31,10 @@ wait_for()
   esac
   local i=0
   while :; do
-    eval "$cmd" && return 0
+    eval "$cmd" && { warn_ "cmd took $i x ${sleep_seconds}s: '$cmd'"; return 0; }
     sleep $sleep_seconds
     i=$(expr $i + 1)
-    test $i = $max_n_sleeps && return 1
+    test $i = $max_n_sleeps \
+      && { warn_ "EXPIRED: $i x ${sleep_seconds}s: '$cmd'"; return 1; }
   done
 }
--
1.7.3.1.526.g2ee4


>From 5a88451cf5e0e69635a9dc4eacbb7f2606256fcc Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Tue, 19 Oct 2010 16:52:17 +0200
Subject: [PATCH 2/2] tests: avoid using a temp file in wait_for_repl utility

* t/replication (wait_for_repl): Use a variable rather than a
temporary file.
---
 t/replication |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/t/replication b/t/replication
index 902d340..78911cc 100644
--- a/t/replication
+++ b/t/replication
@@ -45,9 +45,11 @@ cleanup_() { kill -9 $mongo_pid; kill $iwhd_pid $iwhd_d_pid; }

 api=http://localhost:$port
 wait_for_repl() {
-	curl -d op=rep_status $api > repl.out || return 1
-	test "$(cat repl.out)" = "0 requests" || return 1
-	return 0
+	local n_req=$(curl -d op=rep_status $api) || return 1
+	case $n_req in
+	  '0 requests') return 1 ;;
+	  *) return 0 ;;
+	esac
 }
 bkt=$api/rbucket

--
1.7.3.1.526.g2ee4


More information about the iwhd-devel mailing list