test/Makefile
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Mon, 21 Jan 2019 14:43:24 +0100
branchENGINE-487
changeset 3229 6d555032f84c
parent 3228 0d6ffda184f7
child 3234 538a03bab6b8
child 3271 9425e2da65e4
permissions -rw-r--r--
ENGINE-487: ENGINE-508: fix in - old tests run, now need to test the real functionality
     1 
     2 # Copyright 2017, pEp Foundation
     3 # This file is part of pEpEngine
     4 # This file may be used under the terms of the GNU General Public License version 3
     5 # see LICENSE.txt
     6 
     7 include ../default.conf
     8 
     9 PY_ENV := $(shell command -v python3 2> /dev/null)
    10 
    11 HERE:=$(CURDIR)
    12 TEST_HOME=$(HERE)/pEp_test_home
    13 
    14 TARGET=TestDriver
    15 
    16 SRCS := $(wildcard src/*.cc) $(wildcard src/*/*.cc)
    17 OBJS := $(addsuffix .o,$(basename $(SRCS)))
    18 DEPS := $(OBJS:.o=.d)
    19 
    20 INC_DIRS := ./include /usr/local/include ../src ../sync ../asn.1
    21 INC_FLAGS := $(addprefix -I,$(INC_DIRS)) $(GPGME_INC) $(CPPUNIT_INC)
    22 
    23 LDFLAGS += -L/usr/local/lib
    24 
    25 CFLAGS += -Wno-deprecated
    26 CXXFLAGS += -Wno-deprecated
    27 CFLAGS:=$(filter-out -Wall,$(CFLAGS))
    28 
    29 LDFLAGS+= $(ETPAN_LIB) $(CPPUNIT_LIB) -L../asn.1 -L../src
    30 LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
    31 
    32 ifeq ($(BUILD_FOR),Linux)
    33 	LDLIBS+= -luuid
    34 endif
    35 
    36 ifeq ($(OPENPGP),NETPGP)
    37 	LDLIBS+= -lnetpgp
    38 	CFLAGS+= -DUSE_NETPGP
    39 ifeq ($(BUILD_FOR),Linux)
    40 	LDLIBS+= -ltre
    41 endif
    42 endif
    43 
    44 ifdef SQLITE3_FROM_OS
    45 	LDLIBS+= -lsqlite3
    46 endif
    47 
    48 ifeq ($(shell uname),Darwin)
    49 	LIBPATH=DYLD_LIBRARY_PATH
    50 	LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
    51 else
    52 	LIBPATH=LD_LIBRARY_PATH
    53 	LLDB_BIN=lldb
    54 endif
    55 
    56 LDLIBS += -lcpptest
    57 
    58 
    59 # 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.
    60 # Note that += can not be used here, as it changes the amount of whitespace
    61 EXTRA_LIB_PATHS=../src:
    62 ifdef ETPAN_LIB
    63 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
    64 endif
    65 ifdef GPGME_LIB
    66 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
    67 endif
    68 ifdef NETPGP_LIB
    69 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
    70 endif
    71 
    72 # Remove trailing ':'
    73 EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
    74 
    75 CFLAGS:=$(filter-out -DNDEBUG,$(CFLAGS))
    76 ifneq ($(MAKECMDGOALS),clean)
    77 	ifneq (,$(findstring -DNDEBUG,$(CFLAGS)))
    78 		$(error The macro NDEBUG must not be defined for test compilation.)
    79 	endif
    80 endif
    81 
    82 CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
    83 ifneq ($(MAKECMDGOALS),clean)
    84 	ifneq (,$(findstring -DNDEBUG,$(CXXFLAGS)))
    85 		$(error The macro NDEBUG must not be defined for test compilation.)
    86 	endif
    87 endif
    88 
    89 CPPFLAGS += $(INC_FLAGS) -MMD -MP
    90 
    91 all: suitemaker $(TARGET) test_home_ scripts
    92 	
    93 %.o: %.cc
    94 	$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
    95 
    96 $(TARGET): $(OBJS)
    97 	$(CXX) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $@
    98 
    99 .PHONY: suitemaker
   100 suitemaker:
   101 ifndef PY_ENV
   102 	@echo "WARNING: Can't find python3 - this is fine unless you're adding test suites. If so, please install python3."
   103 else
   104 ifndef EXCLUDE
   105 	$(PY_ENV) gensuitemaker.py
   106 else
   107 	# Comma-separated list, no spaces
   108 	$(PY_ENV) gensuitemaker.py --exclude=$(EXCLUDE)
   109 endif
   110 endif
   111 		
   112 .PHONY: test_home_
   113 test_home_: 
   114 	
   115 
   116 .PHONY: scripts
   117 scripts: 
   118 ifdef PY_ENV
   119 	$(PY_ENV) genscripts.py
   120 endif
   121 
   122 .PHONY: test
   123 test: all
   124 	$(TEST_DEBUGGER) ./$(TARGET)
   125 	
   126 .PHONY: clean
   127 clean:
   128 	$(RM) $(TARGET) $(OBJS) $(DEPS)
   129 	$(RM) $(HERE)/*Tests
   130 
   131 
   132 
   133 -include $(DEPS)
   134