Browse Source

Rework unit tests so test_bitcoin.cpp does not #include them all

0.8
Gavin Andresen 13 years ago
parent
commit
1466b8b78a
  1. 5
      src/makefile.osx
  2. 6
      src/makefile.unix
  3. 7
      src/test/DoS_tests.cpp
  4. 4
      src/test/base58_tests.cpp
  5. 12
      src/test/base64_tests.cpp
  6. 2
      src/test/miner_tests.cpp
  7. 4
      src/test/script_tests.cpp
  8. 15
      src/test/test_bitcoin.cpp
  9. 4
      src/test/transaction_tests.cpp
  10. 2
      src/test/uint160_tests.cpp
  11. 2
      src/test/uint256_tests.cpp
  12. 4
      src/test/util_tests.cpp

5
src/makefile.osx vendored

@ -10,6 +10,7 @@ CXX=llvm-g++
DEPSDIR=/opt/local DEPSDIR=/opt/local
INCLUDEPATHS= \ INCLUDEPATHS= \
-I"$(CURDIR)" \
-I"$(DEPSDIR)/include" \ -I"$(DEPSDIR)/include" \
-I"$(DEPSDIR)/include/db48" -I"$(DEPSDIR)/include/db48"
@ -112,6 +113,8 @@ obj/nogui/%.o: %.cpp
bitcoind: $(OBJS:obj/%=obj/nogui/%) bitcoind: $(OBJS:obj/%=obj/nogui/%)
$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS)
TESTOBJS := $(patsubst test/%.cpp,obj/test/%.o,$(wildcard test/*.cpp))
obj/test/%.o: test/%.cpp obj/test/%.o: test/%.cpp
$(CXX) -c $(CFLAGS) -MMD -o $@ $< $(CXX) -c $(CFLAGS) -MMD -o $@ $<
@cp $(@:%.o=%.d) $(@:%.o=%.P); \ @cp $(@:%.o=%.d) $(@:%.o=%.P); \
@ -119,7 +122,7 @@ obj/test/%.o: test/%.cpp
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
rm -f $(@:%.o=%.d) rm -f $(@:%.o=%.d)
test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) test_bitcoin: $(TESTOBJS) $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
$(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(DEPSDIR)/lib/libboost_unit_test_framework-mt.a $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(DEPSDIR)/lib/libboost_unit_test_framework-mt.a
clean: clean:

6
src/makefile.unix

@ -6,7 +6,7 @@ USE_UPNP:=0
DEFS=-DNOPCH DEFS=-DNOPCH
DEFS += $(addprefix -I,$(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH)) DEFS += $(addprefix -I,$(CURDIR) $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
LIBS += $(addprefix -l,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH)) LIBS += $(addprefix -l,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
LMODE = dynamic LMODE = dynamic
@ -141,6 +141,8 @@ obj/nogui/%.o: %.cpp
bitcoind: $(OBJS:obj/%=obj/nogui/%) bitcoind: $(OBJS:obj/%=obj/nogui/%)
$(CXX) $(xCXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(CXX) $(xCXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
TESTOBJS := $(patsubst test/%.cpp,obj/test/%.o,$(wildcard test/*.cpp))
obj/test/%.o: test/%.cpp obj/test/%.o: test/%.cpp
$(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $<
@cp $(@:%.o=%.d) $(@:%.o=%.P); \ @cp $(@:%.o=%.d) $(@:%.o=%.P); \
@ -148,7 +150,7 @@ obj/test/%.o: test/%.cpp
-e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \
rm -f $(@:%.o=%.d) rm -f $(@:%.o=%.d)
test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) test_bitcoin: $(TESTOBJS) $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%))
$(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LDFLAGS) $(LIBS) $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LDFLAGS) $(LIBS)
clean: clean:

7
src/test/DoS_tests.cpp

@ -5,9 +5,10 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include "../main.h" #include "main.h"
#include "../net.h" #include "wallet.h"
#include "../util.h" #include "net.h"
#include "util.h"
using namespace std; using namespace std;

4
src/test/base58_tests.cpp

@ -1,6 +1,8 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "../util.h" #include "main.h"
#include "wallet.h"
#include "util.h"
BOOST_AUTO_TEST_SUITE(base58_tests) BOOST_AUTO_TEST_SUITE(base58_tests)

12
src/test/base64_tests.cpp

@ -1,18 +1,20 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "../util.h" #include "main.h"
#include "wallet.h"
#include "util.h"
BOOST_AUTO_TEST_SUITE(base64_tests) BOOST_AUTO_TEST_SUITE(base64_tests)
BOOST_AUTO_TEST_CASE(base64_testvectors) BOOST_AUTO_TEST_CASE(base64_testvectors)
{ {
static const string vstrIn[] = {"","f","fo","foo","foob","fooba","foobar"}; static const std::string vstrIn[] = {"","f","fo","foo","foob","fooba","foobar"};
static const string vstrOut[] = {"","Zg==","Zm8=","Zm9v","Zm9vYg==","Zm9vYmE=","Zm9vYmFy"}; static const std::string vstrOut[] = {"","Zg==","Zm8=","Zm9v","Zm9vYg==","Zm9vYmE=","Zm9vYmFy"};
for (int i=0; i<sizeof(vstrIn)/sizeof(vstrIn[0]); i++) for (int i=0; i<sizeof(vstrIn)/sizeof(vstrIn[0]); i++)
{ {
string strEnc = EncodeBase64(vstrIn[i]); std::string strEnc = EncodeBase64(vstrIn[i]);
BOOST_CHECK(strEnc == vstrOut[i]); BOOST_CHECK(strEnc == vstrOut[i]);
string strDec = DecodeBase64(strEnc); std::string strDec = DecodeBase64(strEnc);
BOOST_CHECK(strDec == vstrIn[i]); BOOST_CHECK(strDec == vstrIn[i]);
} }
} }

2
src/test/miner_tests.cpp

@ -1,6 +1,6 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "../uint256.h" #include "uint256.h"
extern void SHA256Transform(void* pstate, void* pinput, const void* pinit); extern void SHA256Transform(void* pstate, void* pinput, const void* pinit);

4
src/test/script_tests.cpp

@ -2,8 +2,8 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include "../main.h" #include "main.h"
#include "../wallet.h" #include "wallet.h"
using namespace std; using namespace std;
extern uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType); extern uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);

15
src/test/test_bitcoin.cpp

@ -1,19 +1,8 @@
#define BOOST_TEST_MODULE Bitcoin Test Suite #define BOOST_TEST_MODULE Bitcoin Test Suite
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "../main.h" #include "main.h"
#include "../wallet.h" #include "wallet.h"
#include "uint160_tests.cpp"
#include "uint256_tests.cpp"
#include "script_tests.cpp"
#include "transaction_tests.cpp"
#include "DoS_tests.cpp"
#include "base64_tests.cpp"
#include "util_tests.cpp"
#include "base58_tests.cpp"
#include "miner_tests.cpp"
#include "Checkpoints_tests.cpp"
CWallet* pwalletMain; CWallet* pwalletMain;

4
src/test/transaction_tests.cpp

@ -1,7 +1,7 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "../main.h" #include "main.h"
#include "../wallet.h" #include "wallet.h"
using namespace std; using namespace std;

2
src/test/uint160_tests.cpp

@ -1,6 +1,6 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "../uint256.h" #include "uint256.h"
BOOST_AUTO_TEST_SUITE(uint160_tests) BOOST_AUTO_TEST_SUITE(uint160_tests)

2
src/test/uint256_tests.cpp

@ -1,6 +1,6 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include "../uint256.h" #include "uint256.h"
BOOST_AUTO_TEST_SUITE(uint256_tests) BOOST_AUTO_TEST_SUITE(uint256_tests)

4
src/test/util_tests.cpp

@ -2,7 +2,9 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include "../util.h" #include "main.h"
#include "wallet.h"
#include "util.h"
using namespace std; using namespace std;

Loading…
Cancel
Save