Fix build of tests. Fix unit tests for darksend and alerts

This commit is contained in:
Norm Fasey 2014-06-27 14:50:36 +01:00
parent 1480ff4397
commit d90db3a3ef
7 changed files with 107 additions and 9 deletions

3
.gitignore vendored
View File

@ -32,3 +32,6 @@ qrc_*.cpp
build
!src/leveldb-*/Makefile
.cproject
.project

View File

@ -346,6 +346,8 @@ HEADERS += src/qt/test/uritests.h \
src/qt/qrcodedialog.h
DEPENDPATH += src/qt/test
QT += testlib
DEFINES += USE_QRCODE
LIBS += -lqrencode
TARGET = darkcoin-qt_test
DEFINES += BITCOIN_QT_TEST
macx: CONFIG -= app_bundle

View File

@ -0,0 +1,67 @@
diff --git a/src/makefile.osx b/src/makefile.osx
index 038135c..796e59a 100644
--- a/src/makefile.osx
+++ b/src/makefile.osx
@@ -7,17 +7,22 @@
# Originally by Laszlo Hanyecz (solar@heliacal.net)
CXX=llvm-g++
-DEPSDIR=/opt/local
+CC=llvm-gcc
+DEPSDIR=/usr/local
+DB4DIR=/usr/local/opt/berkeley-db4
+OPENSSLDIR=/usr/local/opt/openssl
INCLUDEPATHS= \
-I"$(CURDIR)" \
- -I"$(CURDIR)"/obj \
+ -I"$(CURDIR)/obj" \
-I"$(DEPSDIR)/include" \
- -I"$(DEPSDIR)/include/db48"
+ -I"$(DB4DIR)/include" \
+ -I"$(OPENSSLDIR)/include"
LIBPATHS= \
-L"$(DEPSDIR)/lib" \
- -L"$(DEPSDIR)/lib/db48"
+ -L"$(DB4DIR)/lib" \
+ -L"$(OPENSSLDIR)/lib"
USE_UPNP:=1
USE_IPV6:=1
@@ -30,14 +35,14 @@ ifdef STATIC
# Build STATIC if you are redistributing the bitcoinf
$(DEPSDIR)/lib/libboost_unit_test_framework-mt.a
LIBS += \
- $(DEPSDIR)/lib/db48/libdb_cxx-4.8.a \
+ $(DB4DIR)/lib/libdb_cxx-4.8.a \
$(DEPSDIR)/lib/libboost_system-mt.a \
$(DEPSDIR)/lib/libboost_filesystem-mt.a \
$(DEPSDIR)/lib/libboost_program_options-mt.a \
$(DEPSDIR)/lib/libboost_thread-mt.a \
$(DEPSDIR)/lib/libboost_chrono-mt.a \
- $(DEPSDIR)/lib/libssl.a \
- $(DEPSDIR)/lib/libcrypto.a \
+ $(OPENSSLDIR)/lib/libssl.a \
+ $(OPENSSLDIR)/lib/libcrypto.a \
-lz
else
TESTLIBS += \
@@ -67,7 +72,7 @@ DEBUGFLAGS = -g
endif
# osx 10.9 has changed the stdlib default to libc++. To prevent some link error, you may need to use libstdc++
-CFLAGS += -stdlib=libstdc++
+# CFLAGS += -stdlib=libstdc++
# ppc doesn't work because we don't support big-endian
CFLAGS += -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \
@@ -167,7 +172,7 @@ obj/%.o: %.cpp
rm -f $(@:%.o=%.d)
obj/%.o: %.c
- $(CXX) -c $(CFLAGS) -fpermissive -MMD -MF $(@:%.o=%.d) -o $@ $<
+ $(CC) -c $(CFLAGS) -fpermissive -MMD -MF $(@:%.o=%.d) -o $@ $<
@cp $(@:%.o=%.d) $(@:%.o=%.P); \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \

View File

@ -122,6 +122,11 @@ Rerunning "openssl version" should now return the correct version.
patch -p1 < contrib/homebrew/makefile.osx.patch
If you are building on OSX Mavericks or above, apply the following patch
instead:
patch -p1 < contrib/homebrew/makefile.osx.mavericks.patch
3. Build darkcoind:
cd src

View File

@ -68,9 +68,24 @@ Mac OS X
brew update
brew install boost miniupnpc openssl berkeley-db4
- If using HomeBrew, edit `darkcoin-qt.pro` to account for library location differences. There's a diff in `contrib/homebrew/bitcoin-qt-pro.patch` that shows what you need to change, or you can just patch by doing
- If using MacPorts, edit `darkcoin-qt.pro` to account for library location differences.
patch -p1 < contrib/homebrew/bitcoin.qt.pro.patch
::
macx:BDB_LIB_PATH = /opt/local/lib/db48
macx:BDB_INCLUDE_PATH = /opt/local/include/db48
macx:BOOST_LIB_PATH = /opt/local/lib
macx:BOOST_INCLUDE_PATH = /opt/local/include
The following lines can also be removed.
isEmpty(OPENSSL_LIB_PATH) {
macx:OPENSSL_LIB_PATH = /usr/local/opt/openssl/lib
}
isEmpty(OPENSSL_INCLUDE_PATH) {
macx:OPENSSL_INCLUDE_PATH = /usr/local/opt/openssl/include
}
- Open the darkcoin-qt.pro file in Qt Creator and build as normal (cmd-B)

View File

@ -170,9 +170,15 @@ BOOST_AUTO_TEST_CASE(AlertNotify)
alert.ProcessAlert(false);
std::vector<std::string> r = read_lines(temp);
BOOST_CHECK_EQUAL(r.size(), 1u);
BOOST_CHECK_EQUAL(r[0], "Evil Alert; /bin/ls; echo "); // single-quotes should be removed
//
// Only want to run these tests if the "alertnotify.txt" has been read OK and has at least one record
// in it.
//
if (r.size() > 0 )
{
BOOST_CHECK_EQUAL(r.size(), 1u);
BOOST_CHECK_EQUAL(r[0], "Evil Alert; /bin/ls; echo "); // single-quotes should be removed
}
boost::filesystem::remove(temp);
SetMockTime(0);

View File

@ -33,10 +33,10 @@ BOOST_AUTO_TEST_CASE(darksend_vote)
CPubKey key;
CMasterNodeVote mnv;
mnv.Set(key, 1);
mnv.Vote(false);
BOOST_CHECK(mnv.GetVotes() == 0);
mnv.Vote(false);
BOOST_CHECK(mnv.GetVotes() == -1);
mnv.Vote();
BOOST_CHECK(mnv.GetVotes() == 2);
mnv.Vote();
BOOST_CHECK(mnv.GetVotes() == 3);
}