From 49b60d6f67a94560a802c6ff80c16c92093de877 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 16 May 2011 19:43:38 +0000 Subject: tests: unify checks for copy_stream and threaded app dispatch This makes things easier to maintain as we add more concurrency options. --- t/t0022-copy_stream-byte-range.sh | 17 +---------------- t/t0026-splice-copy_stream-byte-range.sh | 17 +---------------- t/t0027-nil-copy_stream.sh | 10 +--------- t/t9100-thread-timeout.sh | 8 +------- t/t9101-thread-timeout-threshold.sh | 8 +------- t/test-lib.sh | 31 +++++++++++++++++++++++++++++++ 6 files changed, 36 insertions(+), 55 deletions(-) diff --git a/t/t0022-copy_stream-byte-range.sh b/t/t0022-copy_stream-byte-range.sh index 3e0a66b..f8494d1 100755 --- a/t/t0022-copy_stream-byte-range.sh +++ b/t/t0022-copy_stream-byte-range.sh @@ -1,22 +1,7 @@ #!/bin/sh . ./test-lib.sh test -r random_blob || die "random_blob required, run with 'make $0'" -case $RUBY_VERSION in -1.9.*) ;; -*) - t_info "skipping $T since it can't IO.copy_stream" - exit 0 - ;; -esac - -case $model in -ThreadSpawn|WriterThreadSpawn|ThreadPool|WriterThreadPool|Base) ;; -XEpollThreadSpawn) ;; -*) - t_info "skipping $T since it doesn't use IO.copy_stream" - exit 0 - ;; -esac +check_copy_stream t_plan 13 "IO.copy_stream byte range response for $model" diff --git a/t/t0026-splice-copy_stream-byte-range.sh b/t/t0026-splice-copy_stream-byte-range.sh index 70546b6..b4b89e5 100644 --- a/t/t0026-splice-copy_stream-byte-range.sh +++ b/t/t0026-splice-copy_stream-byte-range.sh @@ -1,24 +1,9 @@ #!/bin/sh . ./test-lib.sh test -r random_blob || die "random_blob required, run with 'make $0'" -case $RUBY_VERSION in -1.9.*) ;; -*) - t_info "skipping $T since it can't IO::Splice.copy_stream" - exit 0 - ;; -esac +check_copy_stream check_splice -case $model in -ThreadSpawn|WriterThreadSpawn|ThreadPool|WriterThreadPool|Base) ;; -XEpollThreadSpawn) ;; -*) - t_info "skipping $T since it doesn't use copy_stream" - exit 0 - ;; -esac - t_plan 13 "IO::Splice.copy_stream byte range response for $model" t_begin "setup and startup" && { diff --git a/t/t0027-nil-copy_stream.sh b/t/t0027-nil-copy_stream.sh index 03c7f0a..9b68160 100644 --- a/t/t0027-nil-copy_stream.sh +++ b/t/t0027-nil-copy_stream.sh @@ -1,15 +1,7 @@ #!/bin/sh . ./test-lib.sh test -r random_blob || die "random_blob required, run with 'make $0'" - -case $model in -ThreadSpawn|WriterThreadSpawn|ThreadPool|WriterThreadPool|Base) ;; -XEpollThreadSpawn) ;; -*) - t_info "skipping $T since it doesn't use copy_stream" - exit 0 - ;; -esac +check_copy_stream t_plan 7 "large file 'copy_stream nil' test for $model" diff --git a/t/t9100-thread-timeout.sh b/t/t9100-thread-timeout.sh index 8d61cc5..bf0c252 100755 --- a/t/t9100-thread-timeout.sh +++ b/t/t9100-thread-timeout.sh @@ -1,12 +1,6 @@ #!/bin/sh . ./test-lib.sh -case $model in -ThreadSpawn|ThreadPool) ;; -RevThreadSpawn|RevThreadPool) ;; -CoolioThreadSpawn|CoolioThreadPool) ;; -XEpollThreadSpawn) ;; -*) t_info "$0 is only compatible with Thread*"; exit 0 ;; -esac +check_threaded_app_dispatch t_plan 6 "ThreadTimeout Rack middleware test for $model" diff --git a/t/t9101-thread-timeout-threshold.sh b/t/t9101-thread-timeout-threshold.sh index 67e65f6..07ac3b2 100755 --- a/t/t9101-thread-timeout-threshold.sh +++ b/t/t9101-thread-timeout-threshold.sh @@ -1,12 +1,6 @@ #!/bin/sh . ./test-lib.sh -case $model in -ThreadSpawn|ThreadPool) ;; -RevThreadSpawn|RevThreadPool) ;; -CoolioThreadSpawn|CoolioThreadPool) ;; -XEpollThreadSpawn) ;; -*) t_info "$0 is only compatible with Thread*"; exit 0 ;; -esac +check_threaded_app_dispatch t_plan 6 "ThreadTimeout Rack middleware test for $model" diff --git a/t/test-lib.sh b/t/test-lib.sh index be654d6..2f02cf1 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -225,6 +225,37 @@ check_splice () { esac } +check_threaded_app_dispatch () { + case $model in + ThreadSpawn|ThreadPool) ;; + RevThreadSpawn|RevThreadPool) ;; + CoolioThreadSpawn|CoolioThreadPool) ;; + XEpollThreadSpawn|XEpollThreadPool) ;; + *) + t_info "$0 is only compatible with threaded app dispatch" + exit 0 ;; + esac +} + +check_copy_stream () { + case $RUBY_VERSION in + 1.9.*) ;; + *) + t_info "skipping $T since it can't IO.copy_stream" + exit 0 + ;; + esac + + case $model in + ThreadSpawn|WriterThreadSpawn|ThreadPool|WriterThreadPool|Base) ;; + XEpollThreadSpawn|XEpollThreadPool) ;; + *) + t_info "skipping $T since it doesn't use copy_stream" + exit 0 + ;; + esac +} + case $model in Rev) require_check rev Rev::VERSION ;; Coolio) require_check coolio Coolio::VERSION ;; -- cgit v1.2.3-24-ge0c7