test/Makefile
author Krista Bennett <krista@pep-project.org>
Mon, 10 Jul 2017 18:28:01 +0200
changeset 1913 57585bd12bd1
parent 1911 db8b70e61f55
child 1920 c7e8570c9d25
permissions -rw-r--r--
Removed killgpg because killing the agent kills 2.1
     1 
     2 # This file is under GNU General Public License 3.0
     3 # see LICENSE.txt
     4 
     5 HERE := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
     6 
     7 include ../Makefile.conf
     8 
     9 CC?=g++ -std=gnu++11 -pthread
    10 CXX?=g++ -std=gnu++11 -pthread
    11 LD?=$(CXX)
    12 LDFLAGS?=-L$(HOME)/lib
    13 LDLIBS?=-letpan -lpEpEngine -lstdc++ -L../asn.1 -lasn1
    14 ifeq ($(BUILD_FOR),Linux)
    15 	LDLIBS+= -luuid
    16 endif
    17 CXXFLAGS?=-std=c++11 -g -O0 -I../src -I../asn.1
    18 # CXXFLAGS=-O3 -DNDEBUG
    19 
    20 ifeq ("$(OPENPGP)","NETPGP")
    21 	LDLIBS+= -lnetpgp
    22 endif
    23 
    24 TARGET=pEpEngineTest
    25 
    26 UNIT_TESTS_SOURCE=$(wildcard *_test.cc)
    27 UNIT_TESTS=$(subst .cc,,$(UNIT_TESTS_SOURCE))
    28 UNIT_TESTS_RUN=$(subst .cc,_run,$(UNIT_TESTS_SOURCE))
    29 
    30 all: $(TARGET) $(UNIT_TESTS)
    31 
    32 .PHONY: clean
    33 
    34 # don't delete .o files!
    35 .PRECIOUS: %.o
    36 
    37 unexport GNUPGHOME;
    38 TEST_HOME=$(HERE)/test_home
    39 TEST_HOME_SKEL=$(TEST_HOME)_skel
    40 TEST_GNUPGHOME_SKEL=$(TEST_HOME)_skel/.gnupg
    41 
    42 ifeq ($(shell uname), Darwin)
    43     LIBPATH = DYLD_LIBRARY_PATH
    44     LLDB_BIN = /Applications/Xcode.app/Contents/Developer/usr/bin/lldb
    45 else
    46     LIBPATH = LD_LIBRARY_PATH
    47     LLDB_BIN = lldb
    48 endif
    49 
    50 TEST_CMD_PFX = $(LIBPATH)=$(HOME)/lib:../src HOME=$(TEST_HOME)
    51 
    52 define killgpg =
    53 endef
    54 ifeq ("$(OPENPGP)","NETPGP")
    55     killgpg_if_using_it =
    56 else
    57     killgpg_if_using_it = $(killgpg)
    58 endif
    59 
    60 test_home_skel:
    61 	$(killgpg)
    62 	mkdir -p test_home_skel
    63 	-cat 0x*.asc *_sec.asc | gpg2 --import --homedir $(TEST_GNUPGHOME_SKEL)
    64 	$(killgpg)
    65 
    66 test_home_: test_home_skel
    67 	$(killgpg_if_using_it)
    68 	rm -rf test_home
    69 	cp -a test_home_skel test_home
    70 
    71 clean:
    72 	rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc
    73 	rm -Rf *.dSYM test_home test_home_skel pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
    74 
    75 test: pEpEngineTest test_home_
    76 	$(TEST_CMD_PFX) ./pEpEngineTest
    77 
    78 %_test : %_test.o test_util.o
    79 	 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
    80 
    81 %_run : % test_home_
    82 	$(TEST_CMD_PFX) ./$<
    83 
    84 %_lldb : % test_home_
    85 	$(TEST_CMD_PFX) $(LLDB_BIN) ./$<
    86 
    87 %_valgrind : % test_home_
    88 	$(TEST_CMD_PFX) valgrind --leak-check=yes ./$<
    89 
    90 %_gdb : % test_home_
    91 	$(TEST_CMD_PFX) gdb ./$<
    92 
    93 unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
    94 
    95 install:
    96 	make -C .. install