Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to builds of Unit Tests and also to Unit Tests of Alerts and Darksend. #13

Merged
merged 2 commits into from
Jun 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ qrc_*.cpp
build

!src/leveldb-*/Makefile
.cproject
.project

25 changes: 19 additions & 6 deletions bitcoin-qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,16 @@ FORMS += src/qt/forms/qrcodedialog.ui
}

contains(BITCOIN_QT_TEST, 1) {
SOURCES -= src/qt/bitcoin.cpp
SOURCES += src/qt/test/test_main.cpp \
src/qt/test/uritests.cpp
HEADERS += src/qt/test/uritests.h
src/qt/test/uritests.cpp \
src/qt/qrcodedialog.cpp
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
Expand Down Expand Up @@ -390,23 +395,31 @@ isEmpty(BOOST_THREAD_LIB_SUFFIX) {
}

isEmpty(BDB_LIB_PATH) {
macx:BDB_LIB_PATH = /opt/local/lib/db48
macx:BDB_LIB_PATH = /usr/local/opt/berkeley-db4/lib
}

isEmpty(BDB_LIB_SUFFIX) {
macx:BDB_LIB_SUFFIX = -4.8
}

isEmpty(BDB_INCLUDE_PATH) {
macx:BDB_INCLUDE_PATH = /opt/local/include/db48
macx:BDB_INCLUDE_PATH = /usr/local/opt/berkeley-db4/include
}

isEmpty(BOOST_LIB_PATH) {
macx:BOOST_LIB_PATH = /opt/local/lib
macx:BOOST_LIB_PATH = /usr/local/opt/boost/lib
}

isEmpty(BOOST_INCLUDE_PATH) {
macx:BOOST_INCLUDE_PATH = /opt/local/include
macx:BOOST_INCLUDE_PATH = /usr/local/opt/boost/include
}

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
}

win32:DEFINES += WIN32
Expand Down
67 changes: 67 additions & 0 deletions contrib/homebrew/makefile.osx.mavericks.patch
Original file line number Diff line number Diff line change
@@ -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); \
5 changes: 5 additions & 0 deletions doc/build-osx.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 17 additions & 2 deletions doc/readme-qt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 9 additions & 3 deletions src/test/alert_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/test/darksend_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down