Revert "test-lib: support running tests under valgrind in parallel"

This reverts commit ad0e6233320b004f0d686f6887c803e508607bd2. --valgrind-parallel was broken from the start: during review I made the whole valgrind setup code conditional on not being a --valgrind-parallel worker child. But even the children crucially need $GIT_VALGRIND to be set; it should therefore have been set outside the conditional. The fix would be a two-liner, but since the introduction of the feature, almost four months have passed without anyone noticing that it is broken. So this feature is not worth the about hundred lines of test-lib.sh complexity. Revert it. Signed-off-by: Thomas Rast <tr@thomasrast.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Rast committed Oct 19, 2013 at 23:06 UTC 26a07309a6e195fc2d0adc89dcc06f3994ae7603
1 file changed +22 -84
t/test-lib.sh
+22 -84
@@ -205,15 +205,6 @@ do
205 --valgrind-only=*)
206 valgrind_only=$(expr "z$1" : 'z[^=]*=\(.*\)')
207 shift ;;
208 - --valgrind-parallel=*)
209 - valgrind_parallel=$(expr "z$1" : 'z[^=]*=\(.*\)')
210 - shift ;;
211 - --valgrind-only-stride=*)
212 - valgrind_only_stride=$(expr "z$1" : 'z[^=]*=\(.*\)')
213 - shift ;;
214 - --valgrind-only-offset=*)
215 - valgrind_only_offset=$(expr "z$1" : 'z[^=]*=\(.*\)')
216 - shift ;;
208 --tee)
209 shift ;; # was handled already
210 --root=*)
@@ -227,7 +218,7 @@ do
218 esac
219 done
220
230 -if test -n "$valgrind_only" || test -n "$valgrind_only_stride"
221 +if test -n "$valgrind_only"
222 then
223 test -z "$valgrind" && valgrind=memcheck
224 test -z "$verbose" && verbose_only="$valgrind_only"
@@ -377,9 +368,7 @@ maybe_teardown_verbose () {
368 last_verbose=t
369 maybe_setup_verbose () {
370 test -z "$verbose_only" && return
380 - if match_pattern_list $test_count $verbose_only ||
381 - { test -n "$valgrind_only_stride" &&
382 - expr $test_count "%" $valgrind_only_stride - $valgrind_only_offset = 0 >/dev/null; }
371 + if match_pattern_list $test_count $verbose_only
372 then
373 exec 4>&2 3>&1
374 # Emit a delimiting blank line when going from
@@ -403,17 +392,13 @@ maybe_teardown_valgrind () {
392
393 maybe_setup_valgrind () {
394 test -z "$GIT_VALGRIND" && return
406 - if test -z "$valgrind_only" && test -z "$valgrind_only_stride"
395 + if test -z "$valgrind_only"
396 then
397 GIT_VALGRIND_ENABLED=t
398 return
399 fi
400 GIT_VALGRIND_ENABLED=
401 if match_pattern_list $test_count $valgrind_only
413 - then
414 - GIT_VALGRIND_ENABLED=t
415 - elif test -n "$valgrind_only_stride" &&
416 - expr $test_count "%" $valgrind_only_stride - $valgrind_only_offset = 0 >/dev/null
402 then
403 GIT_VALGRIND_ENABLED=t
404 fi
@@ -568,9 +553,6 @@ test_done () {
553 esac
554 }
555
571 -
572 -# Set up a directory that we can put in PATH which redirects all git
573 -# calls to 'valgrind git ...'.
556 if test -n "$valgrind"
557 then
558 make_symlink () {
@@ -618,42 +600,33 @@ then
600 make_symlink "$symlink_target" "$GIT_VALGRIND/bin/$base" || exit
601 }
602
621 - # In the case of --valgrind-parallel, we only need to do the
622 - # wrapping once, in the main script. The worker children all
623 - # have $valgrind_only_stride set, so we can skip based on that.
624 - if test -z "$valgrind_only_stride"
625 - then
626 - # override all git executables in TEST_DIRECTORY/..
627 - GIT_VALGRIND=$TEST_DIRECTORY/valgrind
628 - mkdir -p "$GIT_VALGRIND"/bin
629 - for file in $GIT_BUILD_DIR/git* $GIT_BUILD_DIR/test-*
630 - do
631 - make_valgrind_symlink $file
632 - done
633 - # special-case the mergetools loadables
634 - make_symlink "$GIT_BUILD_DIR"/mergetools "$GIT_VALGRIND/bin/mergetools"
635 - OLDIFS=$IFS
636 - IFS=:
637 - for path in $PATH
603 + # override all git executables in TEST_DIRECTORY/..
604 + GIT_VALGRIND=$TEST_DIRECTORY/valgrind
605 + mkdir -p "$GIT_VALGRIND"/bin
606 + for file in $GIT_BUILD_DIR/git* $GIT_BUILD_DIR/test-*
607 + do
608 + make_valgrind_symlink $file
609 + done
610 + # special-case the mergetools loadables
611 + make_symlink "$GIT_BUILD_DIR"/mergetools "$GIT_VALGRIND/bin/mergetools"
612 + OLDIFS=$IFS
613 + IFS=:
614 + for path in $PATH
615 + do
616 + ls "$path"/git-* 2> /dev/null |
617 + while read file
618 do
639 - ls "$path"/git-* 2> /dev/null |
640 - while read file
641 - do
642 - make_valgrind_symlink "$file"
643 - done
619 + make_valgrind_symlink "$file"
620 done
645 - IFS=$OLDIFS
646 - fi
621 + done
622 + IFS=$OLDIFS
623 PATH=$GIT_VALGRIND/bin:$PATH
624 GIT_EXEC_PATH=$GIT_VALGRIND/bin
625 export GIT_VALGRIND
626 GIT_VALGRIND_MODE="$valgrind"
627 export GIT_VALGRIND_MODE
628 GIT_VALGRIND_ENABLED=t
653 - if test -n "$valgrind_only" || test -n "$valgrind_only_stride"
654 - then
655 - GIT_VALGRIND_ENABLED=
656 - fi
629 + test -n "$valgrind_only" && GIT_VALGRIND_ENABLED=
630 export GIT_VALGRIND_ENABLED
631 elif test -n "$GIT_TEST_INSTALLED"
632 then
@@ -739,41 +712,6 @@ then
712 else
713 mkdir -p "$TRASH_DIRECTORY"
714 fi
742 -
743 -# Gross hack to spawn N sub-instances of the tests in parallel, and
744 -# summarize the results. Note that if this is enabled, the script
745 -# terminates at the end of this 'if' block.
746 -if test -n "$valgrind_parallel"
747 -then
748 - for i in $(test_seq 1 $valgrind_parallel)
749 - do
750 - root="$TRASH_DIRECTORY/vgparallel-$i"
751 - mkdir "$root"
752 - TEST_OUTPUT_DIRECTORY="$root" \
753 - ${SHELL_PATH} "$0" \
754 - --root="$root" --statusprefix="[$i] " \
755 - --valgrind="$valgrind" \
756 - --valgrind-only-stride="$valgrind_parallel" \
757 - --valgrind-only-offset="$i" &
758 - pids="$pids $!"
759 - done
760 - trap "kill $pids" INT TERM HUP
761 - wait $pids
762 - trap - INT TERM HUP
763 - for i in $(test_seq 1 $valgrind_parallel)
764 - do
765 - root="$TRASH_DIRECTORY/vgparallel-$i"
766 - eval "$(cat "$root/test-results/$(basename "$0" .sh)"-*.counts |
767 - sed 's/^\([a-z][a-z]*\) \([0-9][0-9]*\)/inner_\1=\2/')"
768 - test_count=$(expr $test_count + $inner_total)
769 - test_success=$(expr $test_success + $inner_success)
770 - test_fixed=$(expr $test_fixed + $inner_fixed)
771 - test_broken=$(expr $test_broken + $inner_broken)
772 - test_failure=$(expr $test_failure + $inner_failed)
773 - done
774 - test_done
775 -fi
776 -
715 # Use -P to resolve symlinks in our working directory so that the cwd
716 # in subprocesses like git equals our $PWD (for pathname comparisons).
717 cd -P "$TRASH_DIRECTORY" || exit 1