test/Makefile
author Edouard Tisserant <edouard@pep-project.org>
Fri, 09 Jun 2017 16:05:17 +0200
changeset 1845 40bfde56746e
parent 1844 415b5ea8bfd1
child 1851 41014174857f
permissions -rw-r--r--
ENGINE-212 fixed harmless typo
     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 else
    45     LIBPATH = LD_LIBRARY_PATH
    46 endif
    47 
    48 TEST_CMD_PFX = $(LIBPATH)=$(HOME)/lib:../src HOME=$(TEST_HOME)
    49 
    50 test_home_skel:
    51 	mkdir -p test_home_skel
    52 	-cat 0x*.asc *_sec.asc | gpg2 --import --homedir $(TEST_GNUPGHOME_SKEL)
    53 
    54 test_home_: test_home_skel
    55 	rm -rf test_home
    56 	cp -a test_home_skel test_home
    57 
    58 clean:
    59 	rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc
    60 	rm -Rf *.dSYM test_home test_home_skel pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
    61 
    62 test: pEpEngineTest test_home_
    63 	$(TEST_CMD_PFX) ./pEpEngineTest
    64 
    65 %_test : %_test.o test_util.o
    66 	 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
    67 
    68 %_run : % test_home_
    69 	$(TEST_CMD_PFX) ./$<
    70 
    71 %_lldb : % test_home_
    72 	$(TEST_CMD_PFX) lldb ./$<
    73 
    74 %_valgrind : % test_home_
    75 	$(TEST_CMD_PFX) valgrind --leak-check=yes ./$<
    76 
    77 %_gdb : % test_home_
    78 	$(TEST_CMD_PFX) gdb ./$<
    79 
    80 unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
    81 
    82 install:
    83 	make -C .. install