1# Copyright 2015 The Weave Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5### 6# tests 7 8TEST_FLAGS ?= \ 9 --gtest_break_on_failure 10 11TEST_ENV ?= 12ifeq (1, $(CLANG)) 13 TEST_ENV += ASAN_SYMBOLIZER_PATH=$(shell which llvm-symbolizer-3.6) 14endif 15 16weave_test_obj_files := $(WEAVE_TEST_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o) 17 18$(weave_test_obj_files) : out/$(BUILD_MODE)/%.o : %.cc third_party/include/gtest/gtest.h 19 mkdir -p $(dir $@) 20 $(CXX) $(DEFS_$(BUILD_MODE)) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $< 21 22out/$(BUILD_MODE)/libweave-test.a : $(weave_test_obj_files) 23 $(AR) crs $@ $^ 24 25weave_unittest_obj_files := $(WEAVE_UNITTEST_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o) 26 27$(weave_unittest_obj_files) : out/$(BUILD_MODE)/%.o : %.cc third_party/include/gtest/gtest.h 28 mkdir -p $(dir $@) 29 $(CXX) $(DEFS_TEST) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $< 30 31out/$(BUILD_MODE)/libweave_testrunner : \ 32 $(weave_unittest_obj_files) \ 33 $(third_party_chromium_crypto_unittest_obj_files) \ 34 $(third_party_chromium_base_unittest_obj_files) \ 35 out/$(BUILD_MODE)/libweave_common.a \ 36 out/$(BUILD_MODE)/libweave-test.a \ 37 third_party/lib/gmock.a \ 38 third_party/lib/gtest.a 39 $(CXX) -o $@ $^ $(CFLAGS) -lcrypto -lexpat -lpthread -lrt -Lthird_party/lib 40 41test : out/$(BUILD_MODE)/libweave_testrunner 42 $(TEST_ENV) $< $(TEST_FLAGS) 43 44### 45# export tests 46 47weave_exports_unittest_obj_files := $(WEAVE_EXPORTS_UNITTEST_SRC_FILES:%.cc=out/$(BUILD_MODE)/%.o) 48 49$(weave_exports_unittest_obj_files) : out/$(BUILD_MODE)/%.o : %.cc third_party/include/gtest/gtest.h 50 mkdir -p $(dir $@) 51 $(CXX) $(DEFS_TEST) $(INCLUDES) $(CFLAGS) $(CFLAGS_$(BUILD_MODE)) $(CFLAGS_CC) -c -o $@ $< 52 53out/$(BUILD_MODE)/libweave_exports_testrunner : \ 54 $(weave_exports_unittest_obj_files) \ 55 out/$(BUILD_MODE)/libweave.so \ 56 out/$(BUILD_MODE)/libweave-test.a \ 57 out/$(BUILD_MODE)/src/test/weave_testrunner.o \ 58 third_party/lib/gmock.a \ 59 third_party/lib/gtest.a 60 $(CXX) -o $@ $^ $(CFLAGS) -lcrypto -lexpat -lpthread -lrt -Lthird_party/lib -Wl,-rpath=out/$(BUILD_MODE)/ 61 62export-test : out/$(BUILD_MODE)/libweave_exports_testrunner 63 $(TEST_ENV) $< $(TEST_FLAGS) 64 65testall : test export-test 66 67.PHONY : test export-test testall 68 69