about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-10-06 00:48:04 -0700
committerEric Wong <normalperson@yhbt.net>2009-10-06 00:48:55 -0700
commita83f898b9faf193698185a89762d8eac08cc7736 (patch)
tree516545f5d481b7837bf8ec94af1d71f9fa1a265e
parent6a08ae739570ec49046b48339a84997c3bff0cbb (diff)
downloadrainbows-a83f898b9faf193698185a89762d8eac08cc7736.tar.gz
We don't need to repeatedly waste cycles and memory
bandwidth to generate random throwaway data.
-rw-r--r--t/.gitignore1
-rw-r--r--t/GNUmakefile7
-rwxr-xr-xt/t3100-revactor-tee-input.sh13
3 files changed, 15 insertions, 6 deletions
diff --git a/t/.gitignore b/t/.gitignore
index 7cb5e32..d2d3d0e 100644
--- a/t/.gitignore
+++ b/t/.gitignore
@@ -2,3 +2,4 @@
 /test-bin-*
 /*.code
 /*.log
+/random_blob
diff --git a/t/GNUmakefile b/t/GNUmakefile
index 50b1867..76776da 100644
--- a/t/GNUmakefile
+++ b/t/GNUmakefile
@@ -56,6 +56,13 @@ test-bin-$(RUBY_VERSION)/rainbows: ../bin/rainbows
         cmp $@+ $@ 2>/dev/null || mv $@+ $@
         $(RM) $@+
 
+req_random_blob := t3100-revactor-tee-input
+random_blob:
+        dd if=/dev/urandom bs=1M count=10 of=$@+
+        mv $@+ $@
+
+$(addsuffix .sh,$(req_random_blob)): random_blob
+
 $(T): export ruby := $(ruby)
 $(T): export PATH := $(CURDIR)/test-bin-$(RUBY_VERSION):$(PATH)
 $(T): test-bin-$(RUBY_VERSION)/rainbows
diff --git a/t/t3100-revactor-tee-input.sh b/t/t3100-revactor-tee-input.sh
index 2cbc73b..eb17a8b 100755
--- a/t/t3100-revactor-tee-input.sh
+++ b/t/t3100-revactor-tee-input.sh
@@ -4,6 +4,7 @@ nr_actor=${nr_actor-50}
 
 . ./test-lib.sh
 require_revactor
+test -r random_blob || die "random_blob required, run with 'make $0'"
 
 eval $(unused_listen)
 unicorn_config=$(mktemp -t rainbows.$$.unicorn.rb.XXXXXXXX)
@@ -12,9 +13,8 @@ curl_err=$(mktemp -t rainbows.$$.curl.err.XXXXXXXX)
 r_err=$(mktemp -t rainbows.$$.r.err.XXXXXXXX)
 r_out=$(mktemp -t rainbows.$$.r.out.XXXXXXXX)
 pid=$(mktemp -t rainbows.$$.pid.XXXXXXXX)
-blob=$(mktemp -t rainbows.$$.blob.XXXXXXXX)
 TEST_RM_LIST="$TEST_RM_LIST $unicorn_config $lock_path $r_err $r_out"
-TEST_RM_LIST="$TEST_RM_LIST $curl_out $curl_err $blob $pid"
+TEST_RM_LIST="$TEST_RM_LIST $curl_out $curl_err $pid"
 
 cat > $unicorn_config <<EOF
 listen "$listen"
@@ -31,12 +31,13 @@ echo pid=$pid
 rainbows -D sha1.ru -c $unicorn_config
 wait_for_pid $pid
 
-dd if=/dev/urandom bs=1M count=10 of=$blob 2>/dev/null
-
 start=$(date +%s)
 for i in $(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" </dev/null)
 do
-        ( curl -sSf -T- < $blob http://$listen/$i >> $curl_out 2>> $curl_err ) &
+        (
+                curl -sSf -T- http://$listen/$i \
+                  < random_blob >> $curl_out 2>> $curl_err
+        ) &
 done
 wait
 echo elapsed=$(( $(date +%s) - $start ))
@@ -44,6 +45,6 @@ echo elapsed=$(( $(date +%s) - $start ))
 kill $(cat $pid)
 test $nr_client -eq $(wc -l < $curl_out)
 test 1 -eq $(sort < $curl_out | uniq | wc -l)
-blob_sha1=$( expr "$(sha1sum < $blob)" : '\([a-f0-9]\+\)')
+blob_sha1=$( expr "$(sha1sum < random_blob)" : '\([a-f0-9]\+\)')
 echo blob_sha1=$blob_sha1
 test x"$blob_sha1" = x"$(sort < $curl_out | uniq)"