aboutsummaryrefslogtreecommitdiff
path: root/src/test/alert_tests.cpp
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2013-09-10 15:18:09 -0400
committerCory Fields <cory-nospam-@coryfields.com>2013-09-16 12:53:11 -0400
commit152e51c7af2624831cc4796e06bf3b72787cc85f (patch)
treed943cbc4159b2e88f0ee68907edf51b9f673d6a8 /src/test/alert_tests.cpp
parent08081e393b6d3249c19395f91537a7d824ec7333 (diff)
included-tests: generate binary data from test files for inclusion into test binaries
This change moves test data into the binaries rather than reading them from the disk at runtime. Advantages: - Tests become distributable - Cross-compile friendly. Build on one machine and execute in an arbitrary location on another. - Easier testing for backports. Users can verify that tests pass without having to track down corresponding test data. - More trustworthy test results and easier quality assurance as tests make fewer assumptions about their environment. - Tests could theoretically run at client/daemon startup and exit on failure. Disadvantages: - Required 'hexdump' build-dependency. This is a standard bsd tool that should be usable everywhere. It is likely already installed on all build-machines. - Tests can no longer be fudged after build by altering test-data.
Diffstat (limited to 'src/test/alert_tests.cpp')
-rw-r--r--src/test/alert_tests.cpp23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/test/alert_tests.cpp b/src/test/alert_tests.cpp
index ed6dcd8186..cb941943f7 100644
--- a/src/test/alert_tests.cpp
+++ b/src/test/alert_tests.cpp
@@ -9,6 +9,7 @@
#include "alert.h"
#include "serialize.h"
#include "util.h"
+#include "data/alertTests.raw.h"
#if 0
//
@@ -71,27 +72,13 @@ struct ReadAlerts
{
ReadAlerts()
{
- std::string filename("alertTests");
- namespace fs = boost::filesystem;
- fs::path testFile = fs::current_path() / "data" / filename;
-#ifdef TEST_DATA_DIR
- if (!fs::exists(testFile))
- {
- testFile = fs::path(BOOST_PP_STRINGIZE(TEST_DATA_DIR)) / filename;
- }
-#endif
- FILE* fp = fopen(testFile.string().c_str(), "rb");
- if (!fp) return;
-
-
- CAutoFile filein = CAutoFile(fp, SER_DISK, CLIENT_VERSION);
- if (!filein) return;
-
+ std::vector<unsigned char> vch(alert_tests::alertTests, alert_tests::alertTests + sizeof(alert_tests::alertTests));
+ CDataStream stream(vch, SER_DISK, CLIENT_VERSION);
try {
- while (!feof(filein))
+ while (stream.good())
{
CAlert alert;
- filein >> alert;
+ stream >> alert;
alerts.push_back(alert);
}
}