Skip to content

Commit a14ed9d

Browse files
committed
Kludge around System Integrity Protection on Darwin.
Fixes google#175. Change-Id: I744efe1a59fcbe9274cd1988444c012783952382 Reviewed-on: https://code-review.googlesource.com/24510 Reviewed-by: Paul Wankadia <[email protected]>
1 parent bb093f1 commit a14ed9d

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

Makefile

+7-12
Original file line numberDiff line numberDiff line change
@@ -246,22 +246,13 @@ testofiles: $(TESTOFILES)
246246
test: $(DTESTS) $(TESTS) $(STESTS) debug-test static-test shared-test
247247

248248
debug-test: $(DTESTS)
249-
@echo
250-
@echo Running debug binary tests.
251-
@echo
252249
@./runtests $(DTESTS)
253250

254251
static-test: $(TESTS)
255-
@echo
256-
@echo Running static binary tests.
257-
@echo
258252
@./runtests $(TESTS)
259253

260254
shared-test: $(STESTS)
261-
@echo
262-
@echo Running dynamic binary tests.
263-
@echo
264-
@LD_LIBRARY_PATH=obj/so:$(LD_LIBRARY_PATH) ./runtests $(STESTS)
255+
@./runtests -shared-library-path obj/so $(STESTS)
265256

266257
debug-bigtest: $(DTESTS) $(DBIGTESTS)
267258
@./runtests $(DTESTS) $(DBIGTESTS)
@@ -270,7 +261,7 @@ static-bigtest: $(TESTS) $(BIGTESTS)
270261
@./runtests $(TESTS) $(BIGTESTS)
271262

272263
shared-bigtest: $(STESTS) $(SBIGTESTS)
273-
@LD_LIBRARY_PATH=obj/so:$(LD_LIBRARY_PATH) ./runtests $(STESTS) $(SBIGTESTS)
264+
@./runtests -shared-library-path obj/so $(STESTS) $(SBIGTESTS)
274265

275266
benchmark: obj/test/regexp_benchmark
276267

@@ -314,7 +305,11 @@ shared-testinstall:
314305
@mkdir -p obj
315306
@cp testinstall.cc obj
316307
(cd obj && $(CXX) testinstall.cc -o testinstall $(CXXFLAGS) $(LDFLAGS))
317-
LD_LIBRARY_PATH=$(DESTDIR)$(libdir) obj/testinstall
308+
ifeq ($(shell uname),Darwin)
309+
DYLD_LIBRARY_PATH="$(DESTDIR)$(libdir):$(DYLD_LIBRARY_PATH)" obj/testinstall
310+
else
311+
LD_LIBRARY_PATH="$(DESTDIR)$(libdir):$(LD_LIBRARY_PATH)" obj/testinstall
312+
endif
318313

319314
benchlog: obj/test/regexp_benchmark
320315
(echo '==BENCHMARK==' `hostname` `date`; \

runtests

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
#!/usr/bin/env sh
22

3+
# System Integrity Protection on Darwin complicated these matters somewhat.
4+
# See https://github.com/google/re2/issues/175 for details.
5+
if [ "x$1" = "x-shared-library-path" ]; then
6+
if [ "x$(uname)" = "xDarwin" ]; then
7+
DYLD_LIBRARY_PATH="$2:$DYLD_LIBRARY_PATH"
8+
export DYLD_LIBRARY_PATH
9+
else
10+
LD_LIBRARY_PATH="$2:$LD_LIBRARY_PATH"
11+
export LD_LIBRARY_PATH
12+
fi
13+
shift 2
14+
fi
15+
316
success=true
4-
for i
5-
do
17+
for i; do
618
printf "%-40s" $i
7-
if $($i >$i.log 2>&1) 2>/dev/null
8-
then
19+
if $($i >$i.log 2>&1) 2>/dev/null; then
920
echo PASS
1021
else
1122
echo FAIL';' output in $i.log
@@ -16,6 +27,7 @@ done
1627
if $success; then
1728
echo 'ALL TESTS PASSED.'
1829
exit 0
30+
else
31+
echo 'TESTS FAILED.'
32+
exit 1
1933
fi
20-
echo 'TESTS FAILED.'
21-
exit 1

0 commit comments

Comments
 (0)