test/Makefile
author Krista Bennett <krista@pep-project.org>
Tue, 22 Aug 2017 15:34:17 +0200
changeset 1988 ea7bceda4dc8
parent 1941 6d99b6e54d54
child 1989 d3e5bc4a9854
permissions -rw-r--r--
Rolled back to revision 1982. Sorry all, checked in wrong branch to default
krista@1988
     1
# Copyright 2017, pEp Foundation
krista@1988
     2
# This file is part of pEpEngine
krista@1988
     3
# This file may be used under the terms of the GNU General Public License version 3
vb@1517
     4
# see LICENSE.txt
vb@1517
     5
krista@1988
     6
HERE:=$(CURDIR)
vb@2
     7
edouard@1844
     8
include ../Makefile.conf
vb@1422
     9
krista@1988
    10
TARGET=pEpEngineTest
krista@1988
    11
krista@1988
    12
unexport GNUPGHOME
krista@1988
    13
TEST_HOME=$(HERE)/test_home
krista@1988
    14
TEST_GNUPGHOME=$(TEST_HOME)/.gnupg
krista@1988
    15
krista@1988
    16
LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -L../src
krista@1988
    17
LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
krista@1988
    18
vb@1304
    19
ifeq ($(BUILD_FOR),Linux)
krista@1988
    20
    LDLIBS+= -luuid
vb@1304
    21
endif
vb@2
    22
krista@1988
    23
ifeq ($(OPENPGP),NETPGP)
krista@1988
    24
    LDLIBS+= -lnetpgp
Edouard@178
    25
endif
Edouard@178
    26
krista@1988
    27
ifeq ($(shell uname),Darwin)
krista@1988
    28
    LIBPATH=DYLD_LIBRARY_PATH
krista@1988
    29
    LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
krista@1988
    30
else
krista@1988
    31
    LIBPATH=LD_LIBRARY_PATH
krista@1988
    32
    LLDB_BIN=lldb
krista@1988
    33
endif
krista@1988
    34
krista@1988
    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.
krista@1988
    36
# Note that += can not be used here, as it changes the amount of whitespace
krista@1988
    37
EXTRA_LIB_PATHS=../src:
krista@1988
    38
ifdef ETPAN_LIB
krista@1988
    39
    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
krista@1988
    40
endif
krista@1988
    41
ifdef GPGME_LIB
krista@1988
    42
    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
krista@1988
    43
endif
krista@1988
    44
ifdef NETPGP_LIB
krista@1988
    45
    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
krista@1988
    46
endif
krista@1988
    47
# Remove trailing ':'
krista@1988
    48
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
krista@1988
    49
krista@1988
    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
krista@1988
    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
krista@1988
    62
.PHONY: test_home_
edouard@1934
    63
test_home_: 
edouard@1941
    64
	-gpgconf --kill gpg-agent
edouard@1941
    65
	-HOME=$(TEST_HOME) gpgconf --kill gpg-agent
edouard@1941
    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
krista@1988
    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
krista@1988
    76
.PHONY: test
krista@1988
    77
test: $(TARGET) test_home_
krista@1988
    78
	$(TEST_CMD_PFX) ./$<
vb@2
    79
roker@1656
    80
%_test : %_test.o test_util.o
krista@1988
    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
krista@1988
    95
.PHONY: unit_tests
Edouard@699
    96
unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
vb@142
    97
krista@1988
    98
# Installs the engine, not the test binaries
krista@1988
    99
.PHONY: install
vb@142
   100
install:
krista@1988
   101
	$(MAKE) -C .. install