Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Read back the list a stale lock file could spoil
The scan half grepped the page of the request that rebuilt the list,
and that page is drawn from the scan in memory, so the ghost could
never show there. Had the truncate moved out of cache_lock_file, every
later read of the list would have taken in the stale tail and the test
would still have passed.
Diffstat (limited to 'tests/t0003-cache.sh')
| -rwxr-xr-x | tests/t0003-cache.sh | 23 |
1 file changed, 14 insertions, 9 deletions
diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index 9ae13ac..3dd171b 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -437,7 +437,9 @@ test_expect_success PERL 'a scan finding its lock held runs uncached' ' # A run that died before its rename leaves a lock file behind, here longer # than anything the next run writes and ending in a repository and a marker. -# Emptying the file before reuse keeps that tail out of both caches. +# Emptying the file before reuse keeps that tail out of both caches. The page +# that rebuilt the list is drawn from the scan in memory, so it is the file, +# and a second request reading it back, that would show the ghost. test_expect_success 'a stale lock file reaches neither the scan nor a slot' ' { printf "%01024d\n" 0 0 0 0 && @@ -446,18 +448,21 @@ test_expect_success 'a stale lock file reaches neither the scan nor a slot' ' } >stale.lock && rm -f "cache5/$scanned_rc" && cp stale.lock "cache5/$scanned_rc.lock" && - CGIT_CONFIG="$PWD/scanrc" QUERY_STRING="url=" cgit >scan.out && - grep ">one</a>" scan.out && - ! grep ">ghost</a>" scan.out && + cgit_ok scanrc "url=" >scan.out && + test_grep ">one</a>" scan.out && + test_grep "^repo.url=one$" "cache5/$scanned_rc" && + test_grep ! "^repo.url=ghost$" "cache5/$scanned_rc" && + cgit_ok scanrc "url=" >scan.out && + test_grep ">one</a>" scan.out && + test_grep ! ">ghost</a>" scan.out && rm -rf cache3 && mkdir cache3 && - CGIT_CONFIG="$PWD/bigkeyrc" QUERY_STRING="url=bigpage/" cgit >page.out && + cgit_ok bigkeyrc "url=bigpage/" >page.out && slot=$(ls cache3) && rm "cache3/$slot" && { cat page.out page.out && echo "STALE-TAIL"; } >"cache3/$slot.lock" && - CGIT_CONFIG="$PWD/bigkeyrc" QUERY_STRING="url=bigpage/" cgit >/dev/null && - CGIT_CONFIG="$PWD/bigkeyrc" QUERY_STRING="url=bigpage/" cgit >replay.out && - grep "</html>" replay.out && - ! grep "STALE-TAIL" replay.out + cgit_ok bigkeyrc "url=bigpage/" >/dev/null && + cgit_ok bigkeyrc "url=bigpage/" >replay.out && + test_cmp page.out replay.out ' # The cached list is read back as trusted config, so a config that would |
