mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-13 04:46:38 +01:00
Setup unit test environment.
This commit is contained in:
parent
4ce7b0e9ef
commit
5d78e2f5e4
8 changed files with 50 additions and 2 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,6 +6,7 @@ i2p
|
||||||
libi2pd.so
|
libi2pd.so
|
||||||
netDb
|
netDb
|
||||||
tunnels.cfg
|
tunnels.cfg
|
||||||
|
tests/tests
|
||||||
|
|
||||||
# Autotools
|
# Autotools
|
||||||
autom4te.cache
|
autom4te.cache
|
||||||
|
|
12
Makefile
12
Makefile
|
@ -1,6 +1,7 @@
|
||||||
UNAME := $(shell uname -s)
|
UNAME := $(shell uname -s)
|
||||||
SHLIB := libi2pd.so
|
SHLIB := libi2pd.so
|
||||||
I2PD := i2p
|
I2PD := i2p
|
||||||
|
TESTS := tests/tests
|
||||||
GREP := fgrep
|
GREP := fgrep
|
||||||
DEPS := obj/make.dep
|
DEPS := obj/make.dep
|
||||||
|
|
||||||
|
@ -22,10 +23,11 @@ else # win32
|
||||||
DAEMON_SRC += DaemonWin32.cpp
|
DAEMON_SRC += DaemonWin32.cpp
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: mk_build_dir $(SHLIB) $(I2PD)
|
all: mk_build_dir $(SHLIB) $(I2PD) $(TESTS)
|
||||||
|
|
||||||
mk_build_dir:
|
mk_build_dir:
|
||||||
mkdir -p obj
|
mkdir -p obj
|
||||||
|
mkdir -p obj/tests
|
||||||
|
|
||||||
api: $(SHLIB)
|
api: $(SHLIB)
|
||||||
|
|
||||||
|
@ -38,11 +40,13 @@ api: $(SHLIB)
|
||||||
|
|
||||||
deps:
|
deps:
|
||||||
@mkdir -p obj
|
@mkdir -p obj
|
||||||
|
@mkdir -p obj/tests
|
||||||
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) -MM *.cpp > $(DEPS)
|
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) -MM *.cpp > $(DEPS)
|
||||||
@sed -i -e '/\.o:/ s/^/obj\//' $(DEPS)
|
@sed -i -e '/\.o:/ s/^/obj\//' $(DEPS)
|
||||||
|
|
||||||
obj/%.o : %.cpp
|
obj/%.o : %.cpp
|
||||||
@mkdir -p obj
|
@mkdir -p obj
|
||||||
|
@mkdir -p obj/tests
|
||||||
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) $(CPU_FLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) $(CPU_FLAGS) -c -o $@ $<
|
||||||
|
|
||||||
# '-' is 'ignore if missing' on first run
|
# '-' is 'ignore if missing' on first run
|
||||||
|
@ -56,9 +60,13 @@ ifneq ($(USE_STATIC),yes)
|
||||||
$(CXX) $(LDFLAGS) $(LDLIBS) -shared -o $@ $^
|
$(CXX) $(LDFLAGS) $(LDLIBS) -shared -o $@ $^
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
$(TESTS): $(patsubst %.cpp,obj/%.o,$(TESTS_SRC))
|
||||||
|
$(CXX) -o $@ $^ $(LDLIBS) $(LDTESTLIBS) $(LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf obj
|
rm -rf obj
|
||||||
$(RM) $(I2PD) $(SHLIB)
|
$(RM) $(I2PD) $(SHLIB) $(TESTS)
|
||||||
|
|
||||||
LATEST_TAG=$(shell git describe --tags --abbrev=0 master)
|
LATEST_TAG=$(shell git describe --tags --abbrev=0 master)
|
||||||
dist:
|
dist:
|
||||||
|
|
|
@ -10,3 +10,4 @@ NEEDED_CXXFLAGS = -std=c++11
|
||||||
INCFLAGS = -I/usr/include/ -I/usr/local/include/
|
INCFLAGS = -I/usr/include/ -I/usr/local/include/
|
||||||
LDFLAGS = -Wl,-rpath,/usr/local/lib -L/usr/local/lib
|
LDFLAGS = -Wl,-rpath,/usr/local/lib -L/usr/local/lib
|
||||||
LDLIBS = -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread
|
LDLIBS = -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread
|
||||||
|
LDTESTLIBS = -lboost_unit_test_framework
|
||||||
|
|
|
@ -40,6 +40,9 @@ else
|
||||||
LDLIBS = -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread
|
LDLIBS = -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Always link with test framework dynamically
|
||||||
|
LDTESTLIBS = -lboost_unit_test_framework
|
||||||
|
|
||||||
# UPNP Support (miniupnpc 1.5 or 1.6)
|
# UPNP Support (miniupnpc 1.5 or 1.6)
|
||||||
ifeq ($(USE_UPNP),1)
|
ifeq ($(USE_UPNP),1)
|
||||||
LDFLAGS += -ldl
|
LDFLAGS += -ldl
|
||||||
|
|
|
@ -4,6 +4,7 @@ CXXFLAGS = -g -Wall -std=c++11 -DCRYPTOPP_DISABLE_ASM -DMAC_OSX
|
||||||
INCFLAGS = -I/usr/local/include
|
INCFLAGS = -I/usr/local/include
|
||||||
LDFLAGS = -Wl,-rpath,/usr/local/lib -L/usr/local/lib
|
LDFLAGS = -Wl,-rpath,/usr/local/lib -L/usr/local/lib
|
||||||
LDLIBS = -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread
|
LDLIBS = -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread
|
||||||
|
LDTESTLIBS = -lboost_unit_test_framework
|
||||||
|
|
||||||
ifeq ($(USE_UPNP),1)
|
ifeq ($(USE_UPNP),1)
|
||||||
LDFLAGS += -ldl
|
LDFLAGS += -ldl
|
||||||
|
|
|
@ -23,3 +23,6 @@ DAEMON_SRC = $(COMMON_SRC) \
|
||||||
|
|
||||||
LIB_SRC := $(COMMON_SRC) \
|
LIB_SRC := $(COMMON_SRC) \
|
||||||
api.cpp
|
api.cpp
|
||||||
|
|
||||||
|
TESTS_SRC := $(COMMON_SRC) \
|
||||||
|
tests/Utility.cpp tests/Identity.cpp
|
||||||
|
|
12
tests/Identity.cpp
Normal file
12
tests/Identity.cpp
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#define BOOST_TEST_MAIN
|
||||||
|
#define BOOST_TEST_DYN_LINK
|
||||||
|
|
||||||
|
#include <boost/test/unit_test.hpp>
|
||||||
|
#include "../Identity.h"
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_SUITE(IdentityTests)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_SUITE_END()
|
19
tests/Utility.cpp
Normal file
19
tests/Utility.cpp
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#include <boost/test/unit_test.hpp>
|
||||||
|
#include "../util.h"
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_SUITE(UtilityTests)
|
||||||
|
|
||||||
|
using namespace i2p::util::http;
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(DecodeEmptyUrl)
|
||||||
|
{
|
||||||
|
BOOST_CHECK_EQUAL(urlDecode(""), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(DecodeUrl)
|
||||||
|
{
|
||||||
|
BOOST_CHECK_EQUAL(urlDecode("%20"), " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_SUITE_END()
|
Loading…
Add table
Reference in a new issue