test/Makefile
author Damiano Boppart <damiano@pep-security.net>
Thu, 17 Aug 2017 16:01:20 +0000
branchENGINE-228
changeset 1970 9f55b8970727
parent 1960 3e0027330faa
child 1972 639cc236c233
permissions -rw-r--r--
Cleanup test/Makefile, fix src install target
     1 # Copyright 2017, pEp Foundation
     2 # This file is part of pEpEngine
     3 # This file may be used under the terms of the GNU General Public License version 3
     4 # see LICENSE.txt
     5 
     6 HERE:=$(CURDIR)
     7 
     8 include ../Makefile.conf
     9 
    10 TARGET=pEpEngineTest
    11 
    12 unexport GNUPGHOME
    13 TEST_HOME=$(HERE)/test_home
    14 TEST_GNUPGHOME=$(TEST_HOME)/.gnupg
    15 
    16 LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -L../src
    17 LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
    18 
    19 ifeq ($(BUILD_FOR),Linux)
    20     LDLIBS+= -luuid
    21 endif
    22 
    23 ifeq ("$(OPENPGP)","NETPGP")
    24     LDLIBS+= -lnetpgp
    25 endif
    26 
    27 ifeq ($(shell uname),Darwin)
    28     LIBPATH=DYLD_LIBRARY_PATH
    29     LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
    30 else
    31     LIBPATH=LD_LIBRARY_PATH
    32     LLDB_BIN=lldb
    33 endif
    34 
    35 # Create a list of the extra library paths for the loader. We do not assume that the engine and its dependencies are not installed for testing.
    36 # Note that += can not be used here, as it changes the amount of whitespace
    37 EXTRA_LIB_PATHS=../src:
    38 ifdef ETPAN_LIB
    39     EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
    40 endif
    41 ifdef GPGME_LIB
    42     EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
    43 endif
    44 ifdef NETPGP_LIB
    45     EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
    46 endif
    47 # Remove trailing ':'
    48 EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
    49 
    50 TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS) HOME=$(TEST_HOME)
    51 
    52 UNIT_TESTS_SOURCE=$(wildcard *_test.cc)
    53 UNIT_TESTS=$(subst .cc,,$(UNIT_TESTS_SOURCE))
    54 UNIT_TESTS_RUN=$(subst .cc,_run,$(UNIT_TESTS_SOURCE))
    55 
    56 .PHONY: all
    57 all: $(TARGET) $(UNIT_TESTS)
    58 
    59 # don't delete .o files!
    60 .PRECIOUS: %.o
    61 
    62 .PHONY: test_home_
    63 test_home_: 
    64 	-gpgconf --kill gpg-agent
    65 	-HOME=$(TEST_HOME) gpgconf --kill gpg-agent
    66 	-killall gpg-agent
    67 	rm -rf $(TEST_HOME)
    68 	mkdir -p $(TEST_GNUPGHOME)/private-keys-v1.d
    69 	$(GPG_CMD) --import --batch --homedir $(TEST_GNUPGHOME) 0x*.asc *_sec.asc
    70 
    71 .PHONY: clean
    72 clean:
    73 	rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc
    74 	rm -Rf *.dSYM $(TEST_HOME) pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
    75 
    76 .PHONY: test
    77 test: $(TARGET) test_home_
    78 	$(TEST_CMD_PFX) ./$<
    79 
    80 %_test : %_test.o test_util.o
    81 	 $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)
    82 
    83 %_run : % test_home_
    84 	$(TEST_CMD_PFX) ./$<
    85 
    86 %_lldb : % test_home_
    87 	$(TEST_CMD_PFX) $(LLDB_BIN) ./$<
    88 
    89 %_valgrind : % test_home_
    90 	$(TEST_CMD_PFX) valgrind --leak-check=yes ./$<
    91 
    92 %_gdb : % test_home_
    93 	$(TEST_CMD_PFX) gdb ./$<
    94 
    95 .PHONY: unit_tests
    96 unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
    97 
    98 # Installs the engine, not the test binaries
    99 .PHONY: install
   100 install:
   101 	$(MAKE) -C .. install