Skip to content

Commit

Permalink
Kludge around System Integrity Protection on Darwin.
Browse files Browse the repository at this point in the history
Fixes #175.

Change-Id: I744efe1a59fcbe9274cd1988444c012783952382
Reviewed-on: https://code-review.googlesource.com/24510
Reviewed-by: Paul Wankadia <[email protected]>
  • Loading branch information
junyer committed Mar 4, 2018
1 parent bb093f1 commit a14ed9d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
19 changes: 7 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -246,22 +246,13 @@ testofiles: $(TESTOFILES)
test: $(DTESTS) $(TESTS) $(STESTS) debug-test static-test shared-test

debug-test: $(DTESTS)
@echo
@echo Running debug binary tests.
@echo
@./runtests $(DTESTS)

static-test: $(TESTS)
@echo
@echo Running static binary tests.
@echo
@./runtests $(TESTS)

shared-test: $(STESTS)
@echo
@echo Running dynamic binary tests.
@echo
@LD_LIBRARY_PATH=obj/so:$(LD_LIBRARY_PATH) ./runtests $(STESTS)
@./runtests -shared-library-path obj/so $(STESTS)

debug-bigtest: $(DTESTS) $(DBIGTESTS)
@./runtests $(DTESTS) $(DBIGTESTS)
Expand All @@ -270,7 +261,7 @@ static-bigtest: $(TESTS) $(BIGTESTS)
@./runtests $(TESTS) $(BIGTESTS)

shared-bigtest: $(STESTS) $(SBIGTESTS)
@LD_LIBRARY_PATH=obj/so:$(LD_LIBRARY_PATH) ./runtests $(STESTS) $(SBIGTESTS)
@./runtests -shared-library-path obj/so $(STESTS) $(SBIGTESTS)

benchmark: obj/test/regexp_benchmark

Expand Down Expand Up @@ -314,7 +305,11 @@ shared-testinstall:
@mkdir -p obj
@cp testinstall.cc obj
(cd obj && $(CXX) testinstall.cc -o testinstall $(CXXFLAGS) $(LDFLAGS))
LD_LIBRARY_PATH=$(DESTDIR)$(libdir) obj/testinstall
ifeq ($(shell uname),Darwin)
DYLD_LIBRARY_PATH="$(DESTDIR)$(libdir):$(DYLD_LIBRARY_PATH)" obj/testinstall
else
LD_LIBRARY_PATH="$(DESTDIR)$(libdir):$(LD_LIBRARY_PATH)" obj/testinstall
endif

benchlog: obj/test/regexp_benchmark
(echo '==BENCHMARK==' `hostname` `date`; \
Expand Down
24 changes: 18 additions & 6 deletions runtests
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
#!/usr/bin/env sh

# System Integrity Protection on Darwin complicated these matters somewhat.
# See https://github.com/google/re2/issues/175 for details.
if [ "x$1" = "x-shared-library-path" ]; then
if [ "x$(uname)" = "xDarwin" ]; then
DYLD_LIBRARY_PATH="$2:$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH
else
LD_LIBRARY_PATH="$2:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH
fi
shift 2
fi

success=true
for i
do
for i; do
printf "%-40s" $i
if $($i >$i.log 2>&1) 2>/dev/null
then
if $($i >$i.log 2>&1) 2>/dev/null; then
echo PASS
else
echo FAIL';' output in $i.log
Expand All @@ -16,6 +27,7 @@ done
if $success; then
echo 'ALL TESTS PASSED.'
exit 0
else
echo 'TESTS FAILED.'
exit 1
fi
echo 'TESTS FAILED.'
exit 1

0 comments on commit a14ed9d

Please sign in to comment.