THRIFT-650. build: Make Check fails on Centos/OSX with 0.2.0 tarball
This patch fixes the make check target for OSX.
Patch: Anthony Molinaro
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@940327 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/Makefile.am b/test/Makefile.am
index 1226935..1463a6f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -68,7 +68,7 @@
TMemoryBufferTest.cpp \
TBufferBaseTest.cpp
-UnitTests_LDADD = libtestgencpp.la
+UnitTests_LDADD = libtestgencpp.la -lboost_unit_test_framework
#
# TFDTransportTest
diff --git a/test/TBufferBaseTest.cpp b/test/TBufferBaseTest.cpp
index da3ce85..21f4747 100644
--- a/test/TBufferBaseTest.cpp
+++ b/test/TBufferBaseTest.cpp
@@ -18,8 +18,7 @@
*/
#include <algorithm>
-#include <boost/foreach.hpp>
-#include <boost/test/unit_test.hpp>
+#include <boost/test/auto_unit_test.hpp>
#include <transport/TBufferTransports.h>
#include <transport/TShortReadTransport.h>
@@ -30,8 +29,6 @@
using apache::thrift::transport::TFramedTransport;
using apache::thrift::transport::test::TShortReadTransport;
-#define foreach BOOST_FOREACH
-
// Shamelessly copied from ZlibTransport. TODO: refactor.
unsigned int dist[][5000] = {
{ 1<<15 },
@@ -175,7 +172,7 @@
}
-BOOST_AUTO_TEST_SUITE( TBufferBaseTest )
+BOOST_AUTO_TEST_SUITE( TBufferBaseTest );
BOOST_AUTO_TEST_CASE( test_MemoryBuffer_Write_GetBuffer ) {
init_data();
@@ -401,7 +398,8 @@
1<<14, 1<<17,
};
- foreach (int size, sizes) {
+ for (int i = 0; i < sizeof (sizes) / sizeof (sizes[0]); i++) {
+ int size = sizes[i];
for (int d1 = 0; d1 < 3; d1++) {
shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer(16));
TBufferedTransport trans(buffer, size);
@@ -431,7 +429,8 @@
1<<14, 1<<17,
};
- foreach (int size, sizes) {
+ for (int i = 0; i < sizeof (sizes) / sizeof (sizes[0]); i++) {
+ int size = sizes[i];
for (int d1 = 0; d1 < 3; d1++) {
shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer(data, sizeof(data)));
TBufferedTransport trans(buffer, size);
@@ -463,7 +462,8 @@
1<<14, 1<<17,
};
- foreach (int size, sizes) {
+ for (int i = 0; i < sizeof (sizes) / sizeof (sizes[0]); i++) {
+ int size = sizes[i];
for (int d1 = 0; d1 < 3; d1++) {
shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer(data, sizeof(data)));
shared_ptr<TShortReadTransport> tshort(new TShortReadTransport(buffer, 0.125));
@@ -496,7 +496,8 @@
1<<14, 1<<17,
};
- foreach (int size, sizes) {
+ for (int i = 0; i < sizeof (sizes) / sizeof (sizes[0]); i++) {
+ int size = sizes[i];
for (int d1 = 0; d1 < 3; d1++) {
shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer(16));
TFramedTransport trans(buffer, size);
@@ -558,8 +559,10 @@
int probs[] = { 1, 2, 4, 8, 16, 32, };
- foreach (int size, sizes) {
- foreach (int prob, probs) {
+ for (int i = 0; i < sizeof (sizes) / sizeof (sizes[0]); i++) {
+ int size = sizes[i];
+ for (int j = 0; j < sizeof (probs) / sizeof (probs[0]); j++) {
+ int prob = probs[j];
for (int d1 = 0; d1 < 3; d1++) {
shared_ptr<TMemoryBuffer> buffer(new TMemoryBuffer(16));
TFramedTransport trans(buffer, size);
@@ -588,7 +591,9 @@
int read_offset = 0;
int read_index = 0;
- foreach (int fsize, flush_sizes) {
+
+ for (int k = 0; k < flush_sizes.size(); k++) {
+ int fsize = flush_sizes[k];
// We are exploiting an implementation detail of TFramedTransport.
// The read buffer starts empty and it will never do more than one
// readFrame per read, so we should always get exactly one frame.
@@ -636,4 +641,4 @@
BOOST_CHECK_EQUAL(buffer->getBufferAsString(), output2);
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END();
diff --git a/test/TMemoryBufferTest.cpp b/test/TMemoryBufferTest.cpp
index 49bd10b..3dc19f8 100644
--- a/test/TMemoryBufferTest.cpp
+++ b/test/TMemoryBufferTest.cpp
@@ -17,7 +17,7 @@
* under the License.
*/
-#include <boost/test/unit_test.hpp>
+#include <boost/test/auto_unit_test.hpp>
#include <iostream>
#include <climits>
#include <cassert>
@@ -25,7 +25,7 @@
#include <protocol/TBinaryProtocol.h>
#include "gen-cpp/ThriftTest_types.h"
-BOOST_AUTO_TEST_SUITE( TMemoryBufferTest )
+BOOST_AUTO_TEST_SUITE( TMemoryBufferTest );
BOOST_AUTO_TEST_CASE( test_roundtrip ) {
using apache::thrift::transport::TMemoryBuffer;
@@ -104,4 +104,4 @@
}
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END();
diff --git a/test/UnitTestMain.cpp b/test/UnitTestMain.cpp
index d90c54f..d4e1ece 100644
--- a/test/UnitTestMain.cpp
+++ b/test/UnitTestMain.cpp
@@ -18,4 +18,6 @@
*/
#define BOOST_TEST_MODULE thrift
-#include <boost/test/included/unit_test.hpp>
+#define BOOST_TEST_DYN_LINK
+#define BOOST_AUTO_TEST_MAIN
+#include <boost/test/auto_unit_test.hpp>