[PATCH] valgrind tests: be super-super paranoid when creating symlinks
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 21, 2009, 22:31 UTC
- Message-ID
- <alpine.DEB.1.00.0901212331280.3586@pacific.mpi-cbg.de>
- In-Reply-To
- <alpine.DEB.1.00.0901212137130.3586@pacific.mpi-cbg.de>
Even if there is only a faint, almost neglible chance that two parallel tests create the symlinks needed for the valgrind test at the same time, Peff wrote more than just a couple mails about the issue.
To get rid of that threat^Wthread, use a locking mechanism to make sure a symlink is only created by one test invocation, and the other has to wait.
Peff, do you see how much I like you?
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- t/test-lib.sh | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh index 6acc6e0..07e657e 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -490,8 +490,19 @@ else make_symlink () { test -h "$2" && test "$1" = "$(readlink "$2")" || { - rm -f "$2" && - ln -s "$1" "$2" + # be super paranoid + if mkdir "$2".lock + then + rm -f "$2" && + ln -s "$1" "$2" && + rm -r "$2".lock + else + while test -d "$2".lock + do + say "Waiting for lock on $2." + sleep 1 + done + fi } }
-- 1.6.1.442.g112f5