Commit Graph

29 Commits

Author SHA1 Message Date
Roger Meier
2fa9c31e06 THRIFT-1320 Consistency of configure generated config.h
Patch: Alexandre Parenteau

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1165400 13f79535-47bb-0310-9956-ffa450edef68
2011-09-05 19:15:53 +00:00
Roger Meier
9e0f0743f3 THRIFT-1256 Unit Test Logging Output for CI
pass BOOST environment variables to the test suite arguments and create a tests.xml with the results

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1153594 13f79535-47bb-0310-9956-ffa450edef68
2011-08-03 17:36:55 +00:00
Roger Meier
1ebeffb0d8 THRIFT-1197 TFileTransportTest.cpp fails on slower machines
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1132712 13f79535-47bb-0310-9956-ffa450edef68
2011-06-06 18:00:03 +00:00
Christian Lavoie
cbf87cb89c THRIFT-916: Commit THRIFT-916_fix_no-overflow.patch -- remove overflow coming from a few constants.
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1039885 13f79535-47bb-0310-9956-ffa450edef68
2010-11-28 14:34:26 +00:00
Christian Lavoie
af65f1b478 THRIFT-916: Commit a partial fix for flex-generated code infested with warnings on Mac OS X
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1038844 13f79535-47bb-0310-9956-ffa450edef68
2010-11-24 21:58:05 +00:00
Roger Meier
3b771a10f1 THRIFT-916 compile with -Wall -Wextra without warning on Debian Lenny
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1036250 13f79535-47bb-0310-9956-ffa450edef68
2010-11-17 22:11:26 +00:00
Christian Lavoie
01c5cebfdd THRIFT-916: Fix warnings in C++ when compiling with -Wall.
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1031222 13f79535-47bb-0310-9956-ffa450edef68
2010-11-04 20:35:15 +00:00
Christian Lavoie
4f42ef7aa5 THRIFT-953: Fix compilation of TransportTest.cpp on Mac (actual tests still fail) and fix boost m4 macros for Mac.
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1031148 13f79535-47bb-0310-9956-ffa450edef68
2010-11-04 18:51:42 +00:00
Roger Meier
0069cc4a29 THRIFT-916 no errors on GNU/Linux when compiling with CXXFLAGS="-Wall -Wextra -pedantic"
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1022220 13f79535-47bb-0310-9956-ffa450edef68
2010-10-13 18:10:18 +00:00
Roger Meier
085a3e7b60 THRIFT-926 Miscellaneous C++ improvements
changing single destructor call time limit from 500us to 1000us
build does not fail on busy machines



git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1006030 13f79535-47bb-0310-9956-ffa450edef68
2010-10-08 21:23:35 +00:00
David Reiss
109693c82a THRIFT-929. cpp: Convert tests to use boost 1.37
The boost test framework has changed significantly from boost 1.34 to
1.37.  Quite a few new features have been added, and some annoying bugs
have been fixed.

This change now builds the thrift tests against boost 1.37, and updates
them to use some of the newer features.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005162 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:42 +00:00
David Reiss
0a2d81e816 THRIFT-926. cpp: Fix inconsistencies in transport read() behavior
- TBufferedTransport::borrow() could block if not enough data was
  available.  Now it returns NULL immediately in this case, like all
  other transports.

- TBufferedTransport::read() could block some data was available in the
  readahead buffer, but not enough to satisfy the request.  It would
  attempt to call read() on the underlying transport, but this might
  block.  Now it just returns the remaining data in the readahead
  buffer.  The caller is responsible for calling read() again to get the
  rest of the data they want.

- TFrameTransport::read() threw an exception if read() on the underlying
  transport returned 0 when looking for a frame header.  Now
  TFrameTransport::read() returns 0, too.  (It still throws an exception
  if the underlying transport returns 0 after a partial frame or frame
  header has been read.)

- TFDTransport::read() threw an exception on EINTR.  Now it retries up
  to 5 times, similarly to the way TSocket::read() behaves.

- TZlibTransport::read() could block when less data than was requested
  is available.  Now it only calls read() on the underlying transport
  when it would otherwise have nothing to return.

  This does mean that TZlibTransport::read() now often returns less data
  than is actually available at the time.  This required updating
  several of the ZlibTest tests to use readAll() instead of read(),
  since they previously assumed read() would return all available data.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005161 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:40 +00:00
David Reiss
e5c435cccf THRIFT-929. cpp: Add tests to verify blocking read behavior
Add tests that check to see whether or not read() and borrow() block
when called with a length larger than the amount of data currently
available.

At the moment, not all of the transports behave the same way.  I believe
the desired behavior is:

  When M bytes are available, and 0 < M < N:
  - read(N): return M bytes immediately
  - borrow(N): return NULL immediately

  When 0 bytes are available:
  - read(N): In this case, it is acceptable either to immediately return
    0, or to block until some data is available.  If the transport
    blocks, it returns immediately when some date becomes available,
    even if less than N bytes are available.
  - borrow(N): return NULL immediately

- The borrow() tests fail when using TBufferedTransport.
  TBufferedTransport incorrectly blocks until the amount of data
  requested is available.

- test_read_none_available() fails when using TFramedTransport.
  Calling read() on a TFramedTransport when no data is available throws
  an exception instead of returning 0.

- test_read_none_available() fails when using TFDTransport.  This is
  partly just an artifact of the fact that I use SIGALRM as part of this
  test.  Unlike TSocket, TFDTransport doesn't retry after EINTR.

- test_read_part_available() fails when using TZlibTransport around a
  transport that has blocking read() behavior.  TZlibTransport::read()
  loops calling read() on the underlying transport.  It should probably
  break out of the loop and return to the caller as soon as it has
  uncompressed any data, even if it is less than requested and more
  might be available.  Once some data has been uncompressed,
  TZlibTransport cannot risk calling read() again since it might block.

Will commit fixes for these separately.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005160 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:38 +00:00
David Reiss
d4788dfd4a THRIFT-929. cpp: Test wrapper transports more thoroughly
UpdateS TransportTest so that the wrapper transports
(TBufferedTransport, TFramedTransport, TZlibTransport) are tested with a
wider variety of inner transports.  Previously they were only tested
using TMemoryBuffer.  Now all other transports are also tested wrapped
inside each of these transports.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005159 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:37 +00:00
David Reiss
0c025e8f52 THRIFT-929. cpp: Update TransportTest to test TSocket
Made the TSocket(int fd) constructor public, so TransportTest can create
a connected pair of TSocket transports using socketpair().

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005158 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:36 +00:00
David Reiss
65e62d3741 THRIFT-929. cpp: Reduce default buffer sizes for TransportTest
Reduce the default test buffer sizes by about 30x, reducing the time it
takes to run TransportTest from about 1 minute to about 2 seconds.  I
added a --size-multiplier argument that can be used to adjust the sizes
of all test buffers, so developers can still run with large buffer sizes
when desired.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005157 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:35 +00:00
David Reiss
4f9efdb460 THRIFT-926. cpp: Fix bugs in TFileTransport::flush()
Previously flush() had race conditions that could cause it to return
before all data had actually been flushed to disk.  Now the writer
makes sure both buffer queues have been flushed when forceFlush_ is set.

Also, flush() did not wake up the writer thread, so it normally had to
wait for the writer thread to wake up on its own time.  (By default,
this could take up to 3 seconds.)

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005156 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:33 +00:00
David Reiss
4199377a7c THRIFT-926. cpp: TFileTransportTest timing slightly more lenient
Several of the TFileTransportTest tests check wall clock time to make
sure the writer thread processes operations quickly enough, and isn't
hanging.  However, this can easily result in false failures if we don't
get enough processor time.  This commit makes a few changes to reduce
the number of these failures.

- No longer fail if a single destructor call takes more than 500us.
  We only require 90% of the calls to complete in 500us.  No call may
  take more than 100ms, though.  With this change, the test passes most
  of the time now, even while an "fbmake opt" task is running in
  parallel.

- In the flush_max_us tests, make sure the writer thread is started
  before we start recording timing.  Otherwise, creating the thread
  could take long enough to throw off the numbers for the first fsync()
  call.

Also tested with the pthread_cond_signal() in the TFileTransport
destructor commented out, to make sure the test still fails properly
when the destructor takes too long.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005155 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:31 +00:00
David Reiss
709b69f14c THRIFT-926. cpp: Fix destructor behavior of TFileTransport
Set closing_ to true before we wake up the writer thread in the
destructor.  This way the writer thread flushes the data and exits when
it is woken up.

Previously the writer thread could end up going through 2 full timeout
cycles before exiting.  The writer thread could wake up, notice it has
nothing to do since closing_ is not set, and immediately go back to
sleep.  The destructor would then proceed to call flush(), which would
wait for the writer thread to wake up (1 full time out) and clear the
forceFlush_ flag.  After flush returns, the destructor would set
closing_.  It could take the writer thread another full timeout to wake
up again and process this flag.

There were also some points where the worker threads would detect the
closing_ state in their loops and automatically close the file, but did
not zero out the file descriptor, then the destructer attempted to close
the same file.  Fix by simply zeroing out the fd_ at these points.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005154 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:30 +00:00
David Reiss
a0e1159716 THRIFT-926. cpp: remove "standalone" distinction in TZlibTransport
Now that TZlibTransport::flush() behaves the same way as other
transports, there is no need to distinguish between RPC and standalone
behavior for TZlibTransport.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005152 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:27 +00:00
David Reiss
e94fa3391d THRIFT-926. cpp: Make TZlibTransport::flush() behave like other transports
Previously, TZlibTransport::flush() finished the zlib stream, so calling
write() after flush() would result in an error.  Now it just flushes the
data, without finishing the stream.  A new TZlibTransport::finish()
function has been added to finish the stream.

This breaks compatibility.  I'm aware of anyone using this code outside
of Facebook, though.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005151 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:26 +00:00
David Reiss
f2abcf9a56 THRIFT-929. cpp: Use boost::lognormal_distribution in ZlibTest
This way we no longer have to have a huge hard-coded list of numbers in
the source code.  The distribution is randomly generated for each run.
(Although the --seed argument can be used for repeatablity.)

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005150 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:24 +00:00
David Reiss
9a961e7750 THRIFT-929. cpp: Convert ZlibTest to use the boost unit test framework
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005149 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:23 +00:00
David Reiss
3cc9dab229 THRIFT-929. cpp: Remove TZlibTest dependency on filesystem data
Previously, ZlibTest read a file from disk to get data to test with.
It would fail unless gen-cpp/DebugProtoTest_types.tcc was present in the
current directory and was at least 32kB long.

Now ZlibTest simply generates 3 separate buffers to test with.  The
first buffer is just all "a"s, the second is some random sequential
runs, and the third is completely random.  They usually seem to have
compression ratios of around 315:1, 4:1, and 1:1, respectively.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005148 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:21 +00:00
David Reiss
56cb796bce THRIFT-929. cpp: Fix a couple minor issues in ZlibTest
- Add a necessary cast.
- Check buffer sizes more carefully to allow for different read/write
  size distributions.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005147 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:20 +00:00
David Reiss
35dc7695a9 THRIFT-929. cpp: Add unit test for transport functionality
Tests various transport types by writing data, and verifying it can be
read back successfully.  Tests both virtual calls (accessed as
TTransport*) and non-virtual calls (accessed as the appropriate pointer
type, or as TBufferBase* when appropriate).

This is similar to some of the tests already performed in
TMemoryBufferTest and ZlibTest.cpp.  However, this tests a few more
transport types, and it interleaves read and write calls more heavily.
(It currently exposes some bugs in flush() in a couple transports.) It
also exercises both the virtual and non-virtual code paths, now that
read() and write() only result in virtual calls when invoked on a
TTransport*.

TFileTransport currently has several race condition bugs, so most of the
TFileTransport tests ususally fail.  It also has some performance bugs,
causing the TFileTransport tests to take a long time.  Will fix those
issues separately.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005146 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:10:19 +00:00
David Reiss
e71115be6c THRIFT-922. cpp: Templatize binary and compact protocol
Convert TBinaryProtocol and TCompactProtocol to template classes, taking
the transport class as a template parameter.  This allows them to make
non-virtual calls when using the template, improving serialization
performance.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005136 13f79535-47bb-0310-9956-ffa450edef68
2010-10-06 17:09:56 +00:00
Roger Meier
8a441a46ad THRIFT-940 use BOOST_LDFLAGS for unit tests, required to build on Mac OS X
Patch: Christian Lavoie


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1004431 13f79535-47bb-0310-9956-ffa450edef68
2010-10-04 21:13:36 +00:00
David Reiss
351e22b52a THRIFT-503. cpp: Move the tests built by "make check" under lib/cpp
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@991246 13f79535-47bb-0310-9956-ffa450edef68
2010-08-31 16:51:19 +00:00