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
     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 uname), Darwin)
    43     LIBPATH = DYLD_LIBRARY_PATH
    44     LLDB_BIN = /Applications/Xcode.app/Contents/Developer/usr/bin/lldb
    45 else
    46     LIBPATH = LD_LIBRARY_PATH
    47     LLDB_BIN = lldb
    48 endif
    49 
    50 TEST_CMD_PFX = $(LIBPATH)=$(HOME)/lib:../src HOME=$(TEST_HOME)
    51 
    52 test_home_skel:
    53 	mkdir -p test_home_skel
    54 	-cat 0x*.asc *_sec.asc | gpg2 --import --homedir $(TEST_GNUPGHOME_SKEL)
    55 
    56 test_home_: test_home_skel
    57 	rm -rf test_home
    58 	cp -a test_home_skel test_home
    59 
    60 clean:
    61 	rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc
    62 	rm -Rf *.dSYM test_home test_home_skel pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
    63 
    64 test: pEpEngineTest test_home_
    65 	$(TEST_CMD_PFX) ./pEpEngineTest
    66 
    67 %_test : %_test.o test_util.o
    68 	 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
    69 
    70 %_run : % test_home_
    71 	$(TEST_CMD_PFX) ./$<
    72 
    73 %_lldb : % test_home_
    74 	$(TEST_CMD_PFX) $(LLDB_BIN) ./$<
    75 
    76 %_valgrind : % test_home_
    77 	$(TEST_CMD_PFX) valgrind --leak-check=yes ./$<
    78 
    79 %_gdb : % test_home_
    80 	$(TEST_CMD_PFX) gdb ./$<
    81 
    82 unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
    83 
    84 install:
    85 	make -C .. install