Debian Codegraph @

crt/s2n/tests/unit/Makefile

raw symbols SCIP
1 #
2 # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License").
5 # You may not use this file except in compliance with the License.
6 # A copy of the License is located at
7 #
8 # http://aws.amazon.com/apache2.0
9 #
10 # or in the "license" file accompanying this file. This file is distributed
11 # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 # express or implied. See the License for the specific language governing
13 # permissions and limitations under the License.
14 #
15
16 SRCS=$(wildcard *.c)
17 OBJS=$(SRCS:.c=.o)
18 TESTS=$(SRCS:.c=)
19 CRYPTO_LDFLAGS = -L$(LIBCRYPTO_ROOT)/lib
20
21 # Users can specify a subset of tests to be run, otherwise run all tests.
22 ifeq (,$(strip ${UNIT_TESTS}))
23 UNIT_TESTS := ${TESTS}
24 endif
25
26 .PHONY : all
27 .PRECIOUS : $(TESTS)
28
29 all: $(UNIT_TESTS)
30
31 include ../../s2n.mk
32
33 CRUFT += $(wildcard *_test)
34 LIBS += ../testlib/libtests2n.a ../../lib/libs2n.a
35
36 # Suppress the unreachable code warning, because tests involve what should be
37 # unreachable code
38 CFLAGS += -Wno-unreachable-code -I../
39 LDFLAGS += ${CRYPTO_LDFLAGS} ${LIBS} ${CRYPTO_LIBS} -lm -ldl
40
41 ifdef S2N_ADDRESS_SANITIZER
42 $(UNIT_TESTS)::
43 @${CC} ${CFLAGS} -o $@ [email protected] ${LDFLAGS} 2>&1
44 @DYLD_LIBRARY_PATH="$(LIBCRYPTO_ROOT)/lib:$$DYLD_LIBRARY_PATH" \
45 LD_LIBRARY_PATH="$(LIBCRYPTO_ROOT)/lib:$$LD_LIBRARY_PATH" \
46 ./$@
47 else
48 $(UNIT_TESTS)::
49 @${CC} ${CFLAGS} -o $@ [email protected] ${LDFLAGS} 2>&1
50 @DYLD_LIBRARY_PATH="$(LIBCRYPTO_ROOT)/lib:$$DYLD_LIBRARY_PATH" \
51 LD_LIBRARY_PATH="$(LIBCRYPTO_ROOT)/lib:$$LD_LIBRARY_PATH" \
52 LD_PRELOAD="../LD_PRELOAD/allocator_overrides.so" \
53 ./$@
54 endif
55
56 .PHONY : clean
57 clean: decruft
58 @$(foreach test, $(TESTS), rm -f -- "${test}";)
59