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