test/Makefile
author Edouard Tisserant <edouard@pep-project.org>
Wed, 19 Jul 2017 18:37:01 +0200
branchgnupg-2.1
changeset 1929 bad90979fd7e
parent 1920 c7e8570c9d25
child 1932 1bbe9e6435b7
permissions -rw-r--r--
ENGINE-221: use 'gpg' when 'gpg2' command line alias isn't available (i.e. on deb9)
     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 which gpg2), )
    43     GPG_CMD = gpg
    44 else
    45     GPG_CMD = gpg2
    46 endif
    47 
    48 ifeq ($(shell uname), Darwin)
    49     LIBPATH = DYLD_LIBRARY_PATH
    50     LLDB_BIN = /Applications/Xcode.app/Contents/Developer/usr/bin/lldb
    51 else
    52     LIBPATH = LD_LIBRARY_PATH
    53     LLDB_BIN = lldb
    54 endif
    55 
    56 TEST_CMD_PFX = $(LIBPATH)=$(HOME)/lib:../src HOME=$(TEST_HOME)
    57 
    58 test_home_skel:
    59 	mkdir -p test_home_skel
    60 	mkdir -p $(TEST_GNUPGHOME_SKEL)/private-keys-v1.d
    61 	$(GPG_CMD) --import --batch --homedir $(TEST_GNUPGHOME_SKEL) 0x*.asc *_sec.asc
    62 
    63 test_home_: test_home_skel
    64 	rm -rf test_home
    65 	cp -a test_home_skel test_home
    66 
    67 clean:
    68 	rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc
    69 	rm -Rf *.dSYM test_home test_home_skel pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
    70 
    71 test: pEpEngineTest test_home_
    72 	$(TEST_CMD_PFX) ./pEpEngineTest
    73 
    74 %_test : %_test.o test_util.o
    75 	 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
    76 
    77 %_run : % test_home_
    78 	$(TEST_CMD_PFX) ./$<
    79 
    80 %_lldb : % test_home_
    81 	$(TEST_CMD_PFX) $(LLDB_BIN) ./$<
    82 
    83 %_valgrind : % test_home_
    84 	$(TEST_CMD_PFX) valgrind --leak-check=yes ./$<
    85 
    86 %_gdb : % test_home_
    87 	$(TEST_CMD_PFX) gdb ./$<
    88 
    89 unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
    90 
    91 install:
    92 	make -C .. install