Skip to content

Commit ea101b1

Browse files
committed
Improve debuggability of a few sanitizer tests
1 parent d93036a commit ea101b1

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/test/run-make/sanitizer-address/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
-include ../tools.mk
22

3+
LOG := $(TMPDIR)/log.txt
4+
35
# NOTE the address sanitizer only supports x86_64 linux and macOS
46

57
ifeq ($(TARGET),x86_64-apple-darwin)
@@ -15,5 +17,6 @@ endif
1517
all:
1618
ifeq ($(ASAN_SUPPORT),1)
1719
$(RUSTC) -g -Z sanitizer=address -Z print-link-args $(EXTRA_RUSTFLAG) overflow.rs | grep -q librustc_asan
18-
$(TMPDIR)/overflow 2>&1 | grep -q stack-buffer-overflow
20+
$(TMPDIR)/overflow 2>&1 | tee $(LOG)
21+
grep -q stack-buffer-overflow $(LOG)
1922
endif

src/test/run-make/sanitizer-cdylib-link/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
-include ../tools.mk
22

3+
LOG := $(TMPDIR)/log.txt
4+
35
# This test builds a shared object, then an executable that links it as a native
46
# rust library (constrast to an rlib). The shared library and executable both
57
# are compiled with address sanitizer, and we assert that a fault in the cdylib
@@ -14,6 +16,6 @@ all:
1416
ifeq ($(ASAN_SUPPORT),1)
1517
$(RUSTC) -g -Z sanitizer=address --crate-type cdylib --target $(TARGET) library.rs
1618
$(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) -llibrary program.rs
17-
LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | grep -q stack-buffer-overflow
19+
LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | tee $(LOG)
20+
grep -q stack-buffer-overflow $(LOG)
1821
endif
19-

src/test/run-make/sanitizer-dylib-link/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
-include ../tools.mk
22

3+
LOG := $(TMPDIR)/log.txt
4+
35
# This test builds a shared object, then an executable that links it as a native
46
# rust library (constrast to an rlib). The shared library and executable both
57
# are compiled with address sanitizer, and we assert that a fault in the dylib
@@ -14,6 +16,6 @@ all:
1416
ifeq ($(ASAN_SUPPORT),1)
1517
$(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) library.rs
1618
$(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) -llibrary program.rs
17-
LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | grep -q stack-buffer-overflow
19+
LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | tee $(LOG)
20+
grep -q stack-buffer-overflow $(LOG)
1821
endif
19-

0 commit comments

Comments
 (0)