test/Makefile
author Krista Bennett <krista@pep-project.org>
Wed, 14 Jun 2017 18:52:55 +0200
branchENGINE-215
changeset 1856 99348d336639
parent 1851 41014174857f
child 1910 8a1cf9cf1b87
permissions -rw-r--r--
ENGINE-215: needs to be tested, test cases impacted by the change need to be adjusted
vb@1513
     1
vb@1513
     2
# This file is under GNU General Public License 3.0
vb@1513
     3
# see LICENSE.txt
vb@1513
     4
edouard@1844
     5
HERE := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
edouard@1844
     6
vb@2
     7
include ../Makefile.conf
vb@2
     8
vb@66
     9
CC?=g++ -std=gnu++11 -pthread
vb@66
    10
CXX?=g++ -std=gnu++11 -pthread
vb@66
    11
LD?=$(CXX)
Edouard@134
    12
LDFLAGS?=-L$(HOME)/lib
vb@1304
    13
LDLIBS?=-letpan -lpEpEngine -lstdc++ -L../asn.1 -lasn1
vb@1304
    14
ifeq ($(BUILD_FOR),Linux)
vb@1310
    15
	LDLIBS+= -luuid
vb@1304
    16
endif
roker@762
    17
CXXFLAGS?=-std=c++11 -g -O0 -I../src -I../asn.1
vb@2
    18
# CXXFLAGS=-O3 -DNDEBUG
vb@2
    19
Edouard@178
    20
ifeq ("$(OPENPGP)","NETPGP")
Edouard@178
    21
	LDLIBS+= -lnetpgp
Edouard@178
    22
endif
Edouard@178
    23
vb@2
    24
TARGET=pEpEngineTest
vb@2
    25
vb@50
    26
UNIT_TESTS_SOURCE=$(wildcard *_test.cc)
vb@50
    27
UNIT_TESTS=$(subst .cc,,$(UNIT_TESTS_SOURCE))
krista@1617
    28
UNIT_TESTS_RUN=$(subst .cc,_run,$(UNIT_TESTS_SOURCE))
vb@2
    29
vb@48
    30
all: $(TARGET) $(UNIT_TESTS)
vb@2
    31
vb@2
    32
.PHONY: clean
vb@2
    33
roker@1659
    34
# don't delete .o files!
roker@1659
    35
.PRECIOUS: %.o
roker@1659
    36
edouard@1844
    37
unexport GNUPGHOME;
edouard@1844
    38
TEST_HOME=$(HERE)/test_home
edouard@1844
    39
TEST_HOME_SKEL=$(TEST_HOME)_skel
edouard@1844
    40
TEST_GNUPGHOME_SKEL=$(TEST_HOME)_skel/.gnupg
edouard@1844
    41
edouard@1844
    42
ifeq ($(shell uname), Darwin)
edouard@1844
    43
    LIBPATH = DYLD_LIBRARY_PATH
edouard@1851
    44
    LLDB_BIN = /Applications/Xcode.app/Contents/Developer/usr/bin/lldb
edouard@1844
    45
else
edouard@1844
    46
    LIBPATH = LD_LIBRARY_PATH
edouard@1851
    47
    LLDB_BIN = lldb
edouard@1844
    48
endif
edouard@1844
    49
edouard@1844
    50
TEST_CMD_PFX = $(LIBPATH)=$(HOME)/lib:../src HOME=$(TEST_HOME)
edouard@1844
    51
edouard@1844
    52
test_home_skel:
edouard@1844
    53
	mkdir -p test_home_skel
edouard@1844
    54
	-cat 0x*.asc *_sec.asc | gpg2 --import --homedir $(TEST_GNUPGHOME_SKEL)
edouard@1844
    55
edouard@1844
    56
test_home_: test_home_skel
edouard@1844
    57
	rm -rf test_home
edouard@1844
    58
	cp -a test_home_skel test_home
edouard@1844
    59
vb@2
    60
clean:
vb@458
    61
	rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc
edouard@1844
    62
	rm -Rf *.dSYM test_home test_home_skel pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
vb@2
    63
edouard@1844
    64
test: pEpEngineTest test_home_
edouard@1844
    65
	$(TEST_CMD_PFX) ./pEpEngineTest
vb@2
    66
roker@1656
    67
%_test : %_test.o test_util.o
roker@1656
    68
	 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
roker@1656
    69
edouard@1844
    70
%_run : % test_home_
edouard@1844
    71
	$(TEST_CMD_PFX) ./$<
Edouard@699
    72
edouard@1844
    73
%_lldb : % test_home_
edouard@1851
    74
	$(TEST_CMD_PFX) $(LLDB_BIN) ./$<
roker@1656
    75
edouard@1844
    76
%_valgrind : % test_home_
edouard@1844
    77
	$(TEST_CMD_PFX) valgrind --leak-check=yes ./$<
Edouard@745
    78
edouard@1844
    79
%_gdb : % test_home_
edouard@1844
    80
	$(TEST_CMD_PFX) gdb ./$<
Edouard@770
    81
Edouard@699
    82
unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
vb@142
    83
vb@142
    84
install:
vb@142
    85
	make -C .. install