0
0
mirror of https://gitlab.torproject.org/tpo/core/tor.git synced 2024-09-20 04:12:13 +02:00

Makefile: Quote test-network variable expansions

Also:
  * wrap some long lines
  * replace an instance of "test ... -a ..." with "test ... && test ..."

Part of 33280.
This commit is contained in:
teor 2020-02-14 10:34:17 +10:00
parent eaeda21da1
commit 225613fcc2
No known key found for this signature in database
GPG Key ID: 10FEAA0E7075672A

View File

@ -281,8 +281,10 @@ check-local: \
need-chutney-path: need-chutney-path:
@if test ! -d "$$CHUTNEY_PATH"; then \ @if test ! -d "$$CHUTNEY_PATH"; then \
echo '$$CHUTNEY_PATH was not set.'; \ echo '$$CHUTNEY_PATH was not set.'; \
if test -d $(top_srcdir)/../chutney -a -x $(top_srcdir)/../chutney/chutney; then \ if test -d "$(top_srcdir)/../chutney" && \
echo "Assuming test-network.sh will find" $(top_srcdir)/../chutney; \ test -x "$(top_srcdir)/../chutney/chutney"; then \
echo "Assuming test-network.sh will find" \
"$(top_srcdir)/../chutney"; \
else \ else \
echo; \ echo; \
echo "To run these tests, git clone https://git.torproject.org/chutney.git ; export CHUTNEY_PATH=\`pwd\`/chutney"; \ echo "To run these tests, git clone https://git.torproject.org/chutney.git ; export CHUTNEY_PATH=\`pwd\`/chutney"; \
@ -295,8 +297,10 @@ need-chutney-path:
test-network: test-network:
@$(MAKE) test-network-mkdir @$(MAKE) test-network-mkdir
@$(MAKE) test-network-clean @$(MAKE) test-network-clean
@$(MAKE) test-network-ipv4-impl ipv4_flavors="$(TEST_CHUTNEY_FLAVOR_QUICK)" @$(MAKE) test-network-ipv4-impl \
@$(MAKE) test-network-ipv6-impl ipv6_flavors="$(TEST_CHUTNEY_FLAVOR_QUICK_IPV6)" ipv4_flavors="$(TEST_CHUTNEY_FLAVOR_QUICK)"
@$(MAKE) test-network-ipv6-impl \
ipv6_flavors="$(TEST_CHUTNEY_FLAVOR_QUICK_IPV6)"
@$(MAKE) test-network-results @$(MAKE) test-network-results
# Run all available tests using automake's test-driver # Run all available tests using automake's test-driver
@ -304,9 +308,12 @@ test-network:
test-network-all: test-network-all:
@$(MAKE) test-network-mkdir @$(MAKE) test-network-mkdir
@$(MAKE) test-network-clean @$(MAKE) test-network-clean
@$(MAKE) test-network-ipv4-impl ipv4_flavors="$(TEST_CHUTNEY_FLAVORS)" @$(MAKE) test-network-ipv4-impl \
@$(MAKE) test-network-mixed-impl mixed_flavors="$(TEST_CHUTNEY_FLAVORS_MIXED)" ipv4_flavors="$(TEST_CHUTNEY_FLAVORS)"
@$(MAKE) test-network-ipv6-impl ipv6_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6)" @$(MAKE) test-network-mixed-impl \
mixed_flavors="$(TEST_CHUTNEY_FLAVORS_MIXED)"
@$(MAKE) test-network-ipv6-impl \
ipv6_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6)"
@$(MAKE) test-network-results @$(MAKE) test-network-results
# Run IPv4 and mixed tests using automake's test-driver # Run IPv4 and mixed tests using automake's test-driver
@ -315,7 +322,8 @@ test-network-ipv4:
@$(MAKE) test-network-mkdir @$(MAKE) test-network-mkdir
@$(MAKE) test-network-clean @$(MAKE) test-network-clean
@$(MAKE) test-network-ipv4-impl ipv4_flavors="$(TEST_CHUTNEY_FLAVORS)" @$(MAKE) test-network-ipv4-impl ipv4_flavors="$(TEST_CHUTNEY_FLAVORS)"
@$(MAKE) test-network-mixed-impl mixed_flavors="$(TEST_CHUTNEY_FLAVORS_MIXED)" @$(MAKE) test-network-mixed-impl \
mixed_flavors="$(TEST_CHUTNEY_FLAVORS_MIXED)"
@$(MAKE) test-network-results @$(MAKE) test-network-results
# Run IPv6 tests using automake's test-driver # Run IPv6 tests using automake's test-driver
@ -323,18 +331,22 @@ test-network-ipv4:
test-network-ipv6: test-network-ipv6:
@$(MAKE) test-network-mkdir @$(MAKE) test-network-mkdir
@$(MAKE) test-network-clean @$(MAKE) test-network-clean
@$(MAKE) test-network-ipv6-impl ipv6_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6)" @$(MAKE) test-network-ipv6-impl \
ipv6_flavors="$(TEST_CHUTNEY_FLAVORS_IPV6)"
@$(MAKE) test-network-results @$(MAKE) test-network-results
# Make the test network log directory, if it does not exist # Make the test network log directory, if it does not exist
.PHONY: test-network-mkdir .PHONY: test-network-mkdir
test-network-mkdir: test-network-mkdir:
@mkdir -p $(TEST_NETWORK_ALL_LOG_DIR) @mkdir -p "$(TEST_NETWORK_ALL_LOG_DIR)"
# Clean the test network log directory # Clean the test network log directory
.PHONY: test-network-clean .PHONY: test-network-clean
# We need to remove all matching files, so we can't quote the glob part of the
# rm arguments
test-network-clean: test-network-clean:
rm -f $(TEST_NETWORK_ALL_LOG_DIR)/*.log $(TEST_NETWORK_ALL_LOG_DIR)/*.trs rm -f "$(TEST_NETWORK_ALL_LOG_DIR)"/*.log \
"$(TEST_NETWORK_ALL_LOG_DIR)"/*.trs
# Run the IPv4-only test flavors # Run the IPv4-only test flavors
# - $(ipv4_flavors) contains the tests to run # - $(ipv4_flavors) contains the tests to run
@ -349,13 +361,16 @@ test-network-ipv4-impl:
test-network-mixed-impl: test-network-mixed-impl:
@flavors=""; \ @flavors=""; \
if command -v tor-stable >/dev/null 2>&1; then \ if command -v tor-stable >/dev/null 2>&1; then \
echo "tor-stable found, running mixed flavors: $(mixed_flavors)."; \ echo "tor-stable found, running mixed flavors:" \
"$(mixed_flavors)."; \
flavors="$$flavors $(mixed_flavors)"; \ flavors="$$flavors $(mixed_flavors)"; \
else \ else \
echo "tor-stable not found, skipping mixed flavors: $(mixed_flavors)."; \ echo "tor-stable not found, skipping mixed flavors:" \
"$(mixed_flavors)."; \
skip_flavors="$$skip_flavors $(mixed_flavors)"; \ skip_flavors="$$skip_flavors $(mixed_flavors)"; \
fi; \ fi; \
$(MAKE) test-network-run flavors="$$flavors" skip_flavors="$$skip_flavors" $(MAKE) test-network-run flavors="$$flavors" \
skip_flavors="$$skip_flavors"
# Run the IPv6 tests in $(ipv6_flavors), if IPv6 is available # Run the IPv6 tests in $(ipv6_flavors), if IPv6 is available
# - only run IPv6 tests if we can ping6 or ping -6 ::1 (localhost) # - only run IPv6 tests if we can ping6 or ping -6 ::1 (localhost)
@ -370,30 +385,35 @@ test-network-ipv6-impl:
if ping6 -q -c 1 -o ::1 >/dev/null 2>&1 || \ if ping6 -q -c 1 -o ::1 >/dev/null 2>&1 || \
ping6 -q -c 1 -W 1 ::1 >/dev/null 2>&1 || \ ping6 -q -c 1 -W 1 ::1 >/dev/null 2>&1 || \
ping -6 -c 1 -W 1 ::1 >/dev/null 2>&1; then \ ping -6 -c 1 -W 1 ::1 >/dev/null 2>&1; then \
echo "ping6 ::1 or ping ::1 succeeded, running IPv6 flavors: $(ipv6_flavors)."; \ echo "ping6 ::1 or ping ::1 succeeded, running IPv6" \
"flavors: $(ipv6_flavors)."; \
flavors="$$flavors $(ipv6_flavors)"; \ flavors="$$flavors $(ipv6_flavors)"; \
else \ else \
echo "ping6 ::1 and ping ::1 failed, skipping IPv6 flavors: $(ipv6_flavors)."; \ echo "ping6 ::1 and ping ::1 failed, skipping IPv6 flavors:" \
"$(ipv6_flavors)."; \
skip_flavors="$$skip_flavors $(ipv6_flavors)"; \ skip_flavors="$$skip_flavors $(ipv6_flavors)"; \
fi; \ fi; \
$(MAKE) test-network-run flavors="$$flavors" skip_flavors="$$skip_flavors" $(MAKE) test-network-run flavors="$$flavors" \
skip_flavors="$$skip_flavors"
# Run tests using automake's test-driver # Run tests using automake's test-driver
# - $(flavors) contains the tests to run # - $(flavors) contains the tests to run
# - $(skip_flavors) contains the tests to skip # - $(skip_flavors) contains the tests to skip
.PHONY: test-network-run .PHONY: test-network-run
# We need the word splitting in the "for" lines, so we can't quote
# $(skip_flavors) or $(flavors)
test-network-run: need-chutney-path test-driver $(TESTING_TOR_BINARY) src/tools/tor-gencert test-network-run: need-chutney-path test-driver $(TESTING_TOR_BINARY) src/tools/tor-gencert
@for f in $(skip_flavors); do \ @for f in $(skip_flavors); do \
echo "SKIP: $$f"; \ echo "SKIP: $$f"; \
done; \ done; \
for f in $(flavors); do \ for f in $(flavors); do \
$(SHELL) $(top_srcdir)/test-driver --test-name $$f \ $(SHELL) "$(top_srcdir)/test-driver" --test-name "$$f" \
--log-file $(TEST_NETWORK_ALL_LOG_DIR)/$$f.log \ --log-file "$(TEST_NETWORK_ALL_LOG_DIR)/$$f.log" \
--trs-file $(TEST_NETWORK_ALL_LOG_DIR)/$$f.trs \ --trs-file "$(TEST_NETWORK_ALL_LOG_DIR)/$$f.trs" \
$(TEST_NETWORK_ALL_DRIVER_FLAGS) \ $(TEST_NETWORK_ALL_DRIVER_FLAGS) \
$(top_srcdir)/src/test/test-network.sh \ "$(top_srcdir)/src/test/test-network.sh" \
--flavor $$f $(TEST_NETWORK_FLAGS); \ --flavor "$$f" $(TEST_NETWORK_FLAGS); \
$(top_srcdir)/src/test/test-network.sh \ "$(top_srcdir)/src/test/test-network.sh" \
$(TEST_NETWORK_SHOW_WARNINGS_FOR_LAST_RUN_FLAGS); \ $(TEST_NETWORK_SHOW_WARNINGS_FOR_LAST_RUN_FLAGS); \
done done
@ -402,9 +422,12 @@ test-network-run: need-chutney-path test-driver $(TESTING_TOR_BINARY) src/tools/
# (otherwise, warnings go to the logs, and people don't see them unless # (otherwise, warnings go to the logs, and people don't see them unless
# there is a network failure) # there is a network failure)
.PHONY: test-network-results .PHONY: test-network-results
# We need to grep all matching files, so we can't quote the glob part of the
# grep arguments
test-network-results: test-network-results:
@echo "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)." @echo \
@! grep -q FAIL $(TEST_NETWORK_ALL_LOG_DIR)/*.trs "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)."
@! grep -q FAIL "$(TEST_NETWORK_ALL_LOG_DIR)"/*.trs
need-stem-path: need-stem-path:
@if test ! -d "$$STEM_SOURCE_DIR"; then \ @if test ! -d "$$STEM_SOURCE_DIR"; then \