Diff options
Diffstat (limited to 'tests/t0003-cache.sh')
-rwxr-xr-xtests/t0003-cache.sh42
1 file changed, 18 insertions, 24 deletions
diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh
index 5cf0250..7e92b05 100755
--- a/tests/t0003-cache.sh
+++ b/tests/t0003-cache.sh
@@ -2,8 +2,6 @@
# Exercises the cache. The first three tests set cache-size to nothing, one
# slot and the full table in turn, then count what the requests left behind.
-# The rest cover a page longer than the output buffer and a key too long to
-# be read back.
test_description='Validate cache'
. ./setup.sh
@@ -78,29 +76,10 @@ test_expect_success 'set up a repo with a page larger than the output buffer' '
rm -rf cache2 && mkdir cache2
'
-# The second request lands while the first is inside its filter, which says
-# so through a marker file, since a fresh binary can take a moment to start.
-overlap_requests() {
- n=0
- rm -f filter-running
- CGIT_CONFIG="$PWD/lockrc" QUERY_STRING="url=bigpage/about/" cgit >first.out 2>first.err &
- while ! test -f filter-running && test $n -lt 10
- do
- sleep 1
- n=$((n + 1))
- done
- CGIT_CONFIG="$PWD/lockrc" QUERY_STRING="url=bigpage/log/" cgit >second.out 2>second.err
- wait
-}
-
-bigpage_query() {
- CGIT_CONFIG="$PWD/bigrc" QUERY_STRING="$1" cgit
-}
-
test_expect_success 'the first request fills the slot and the second replays it' '
- bigpage_query "url=bigpage/tree/big.txt" >big.first &&
+ CGIT_CONFIG="$PWD/bigrc" QUERY_STRING="url=bigpage/tree/big.txt" cgit >big.first &&
test $(wc -c <big.first) -gt 65536 &&
- bigpage_query "url=bigpage/tree/big.txt" >big.second &&
+ CGIT_CONFIG="$PWD/bigrc" QUERY_STRING="url=bigpage/tree/big.txt" cgit >big.second &&
strip_headers <big.first >big.first.body &&
strip_headers <big.second >big.second.body &&
test_cmp big.first.body big.second.body
@@ -125,7 +104,7 @@ test_expect_success 'an over-long cache key leaves no slot behind' '
rm -rf cache3 && mkdir cache3 &&
sed -e "s|^cache-root=.*|cache-root=$PWD/cache3|" bigrc >bigkeyrc &&
long=$(awk "BEGIN{s=\"\";for(i=0;i<6000;i++)s=s \"k\"; print s}") &&
- CGIT_CONFIG="$PWD/bigkeyrc" QUERY_STRING="url=bigpage/&q=$long" cgit >key.out 2>key.err &&
+ CGIT_CONFIG="$PWD/bigkeyrc" QUERY_STRING="url=bigpage/&q=$long" cgit >key.out 2>/dev/null &&
grep "</html>" key.out &&
test_dir_is_empty cache3
'
@@ -250,6 +229,21 @@ test_expect_success 'a failed final write still delivers the page' '
! grep "called many times" flush.err
'
+# The second request lands while the first is inside its filter, which says
+# so through a marker file, since a fresh binary can take a moment to start.
+overlap_requests() {
+ n=0
+ rm -f filter-running
+ CGIT_CONFIG="$PWD/lockrc" QUERY_STRING="url=bigpage/about/" cgit >first.out 2>first.err &
+ while ! test -f filter-running && test $n -lt 10
+ do
+ sleep 1
+ n=$((n + 1))
+ done
+ CGIT_CONFIG="$PWD/lockrc" QUERY_STRING="url=bigpage/log/" cgit >/dev/null 2>second.err
+ wait
+}
+
# The fill writes the page into the lock file through stdout, and an exec
# filter puts its own pipe on stdout while it runs. The slot lock has to
# outlast that, or a second request on the slot rebuilds it under the first