From 1480ff43979ce36dc12d36e94e8fa63cd5f5076f Mon Sep 17 00:00:00 2001 From: Norm Fasey Date: Fri, 27 Jun 2014 13:36:46 +0100 Subject: [PATCH 1/2] Fix the build of test code --- bitcoin-qt.pro | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index 88973e1bbe064..8eca0ebe28c4e 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -338,9 +338,12 @@ 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 TARGET = darkcoin-qt_test @@ -390,7 +393,7 @@ 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) { @@ -398,15 +401,23 @@ isEmpty(BDB_LIB_SUFFIX) { } 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 From d90db3a3ef91cbf66ba6bc1ef950a571d217f11f Mon Sep 17 00:00:00 2001 From: Norm Fasey Date: Fri, 27 Jun 2014 14:50:36 +0100 Subject: [PATCH 2/2] Fix build of tests. Fix unit tests for darksend and alerts --- .gitignore | 3 + bitcoin-qt.pro | 2 + contrib/homebrew/makefile.osx.mavericks.patch | 67 +++++++++++++++++++ doc/build-osx.md | 5 ++ doc/readme-qt.rst | 19 +++++- src/test/alert_tests.cpp | 12 +++- src/test/darksend_tests.cpp | 8 +-- 7 files changed, 107 insertions(+), 9 deletions(-) create mode 100644 contrib/homebrew/makefile.osx.mavericks.patch diff --git a/.gitignore b/.gitignore index f675bbc16694e..b68b36e4ff8e3 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ qrc_*.cpp build !src/leveldb-*/Makefile +.cproject +.project + diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro index 8eca0ebe28c4e..d058895ffa4de 100644 --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -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 diff --git a/contrib/homebrew/makefile.osx.mavericks.patch b/contrib/homebrew/makefile.osx.mavericks.patch new file mode 100644 index 0000000000000..00b5e12242c70 --- /dev/null +++ b/contrib/homebrew/makefile.osx.mavericks.patch @@ -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); \ diff --git a/doc/build-osx.md b/doc/build-osx.md index a2fa59c9337ef..d079a8b39a5c8 100644 --- a/doc/build-osx.md +++ b/doc/build-osx.md @@ -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 diff --git a/doc/readme-qt.rst b/doc/readme-qt.rst index a3883d96486be..ef832d21545ff 100644 --- a/doc/readme-qt.rst +++ b/doc/readme-qt.rst @@ -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) diff --git a/src/test/alert_tests.cpp b/src/test/alert_tests.cpp index f9e2be769b00f..3b329125518bd 100644 --- a/src/test/alert_tests.cpp +++ b/src/test/alert_tests.cpp @@ -170,9 +170,15 @@ BOOST_AUTO_TEST_CASE(AlertNotify) alert.ProcessAlert(false); std::vector 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); diff --git a/src/test/darksend_tests.cpp b/src/test/darksend_tests.cpp index ef028a93a2313..dc60a425a517e 100644 --- a/src/test/darksend_tests.cpp +++ b/src/test/darksend_tests.cpp @@ -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); }