blob: d12e384dd06425db6818568634513052f89cfd49 [file] [log] [blame]
David Reiss35dc7692010-10-06 17:10:19 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19#ifndef _GNU_SOURCE
20#define _GNU_SOURCE // needed for getopt_long
21#endif
22
23#include <stdlib.h>
24#include <time.h>
25#include <unistd.h>
26#include <getopt.h>
David Reisse5c435c2010-10-06 17:10:38 +000027#include <signal.h>
David Reiss35dc7692010-10-06 17:10:19 +000028#include <sstream>
29#include <tr1/functional>
30
31#include <boost/mpl/list.hpp>
32#include <boost/shared_array.hpp>
33#include <boost/random.hpp>
34#include <boost/type_traits.hpp>
35#include <boost/test/unit_test.hpp>
36
37#include <transport/TBufferTransports.h>
38#include <transport/TFDTransport.h>
39#include <transport/TFileTransport.h>
David Reisse94fa332010-10-06 17:10:26 +000040#include <transport/TZlibTransport.h>
David Reiss0c025e82010-10-06 17:10:36 +000041#include <transport/TSocket.h>
David Reiss35dc7692010-10-06 17:10:19 +000042
43using namespace apache::thrift::transport;
44
45static boost::mt19937 rng;
46static const char* tmp_dir = "/tmp";
47
David Reiss65e62d32010-10-06 17:10:35 +000048void initrand(unsigned int seed) {
David Reiss35dc7692010-10-06 17:10:19 +000049 rng.seed(seed);
50}
51
52class SizeGenerator {
53 public:
54 virtual ~SizeGenerator() {}
55 virtual uint32_t nextSize() = 0;
56 virtual std::string describe() const = 0;
57};
58
59class ConstantSizeGenerator : public SizeGenerator {
60 public:
61 ConstantSizeGenerator(uint32_t value) : value_(value) {}
62 uint32_t nextSize() { return value_; }
63 std::string describe() const {
64 std::ostringstream desc;
65 desc << value_;
66 return desc.str();
67 }
68
69 private:
70 uint32_t value_;
71};
72
73class RandomSizeGenerator : public SizeGenerator {
74 public:
75 RandomSizeGenerator(uint32_t min, uint32_t max) :
76 generator_(rng, boost::uniform_int<int>(min, max)) {}
77
78 uint32_t nextSize() { return generator_(); }
79
80 std::string describe() const {
81 std::ostringstream desc;
82 desc << "rand(" << getMin() << ", " << getMax() << ")";
83 return desc.str();
84 }
85
86 uint32_t getMin() const { return generator_.distribution().min(); }
87 uint32_t getMax() const { return generator_.distribution().max(); }
88
89 private:
90 boost::variate_generator< boost::mt19937&, boost::uniform_int<int> >
91 generator_;
92};
93
94/**
95 * This class exists solely to make the TEST_RW() macro easier to use.
96 * - it can be constructed implicitly from an integer
97 * - it can contain either a ConstantSizeGenerator or a RandomSizeGenerator
98 * (TEST_RW can't take a SizeGenerator pointer or reference, since it needs
99 * to make a copy of the generator to bind it to the test function.)
100 */
101class GenericSizeGenerator : public SizeGenerator {
102 public:
103 GenericSizeGenerator(uint32_t value) :
104 generator_(new ConstantSizeGenerator(value)) {}
105 GenericSizeGenerator(uint32_t min, uint32_t max) :
106 generator_(new RandomSizeGenerator(min, max)) {}
107
108 uint32_t nextSize() { return generator_->nextSize(); }
109 std::string describe() const { return generator_->describe(); }
110
111 private:
112 boost::shared_ptr<SizeGenerator> generator_;
113};
114
115/**************************************************************************
116 * Classes to set up coupled transports
117 **************************************************************************/
118
David Reiss0c025e82010-10-06 17:10:36 +0000119/**
120 * Helper class to represent a coupled pair of transports.
121 *
122 * Data written to the out transport can be read from the in transport.
123 *
124 * This is used as the base class for the various coupled transport
125 * implementations. It shouldn't be instantiated directly.
126 */
David Reiss35dc7692010-10-06 17:10:19 +0000127template <class Transport_>
128class CoupledTransports {
129 public:
130 typedef Transport_ TransportType;
131
David Reissd4788df2010-10-06 17:10:37 +0000132 CoupledTransports() : in(), out() {}
David Reiss35dc7692010-10-06 17:10:19 +0000133
David Reissd4788df2010-10-06 17:10:37 +0000134 boost::shared_ptr<Transport_> in;
135 boost::shared_ptr<Transport_> out;
David Reiss35dc7692010-10-06 17:10:19 +0000136
137 private:
138 CoupledTransports(const CoupledTransports&);
139 CoupledTransports &operator=(const CoupledTransports&);
140};
141
David Reiss0c025e82010-10-06 17:10:36 +0000142/**
143 * Coupled TMemoryBuffers
144 */
David Reiss35dc7692010-10-06 17:10:19 +0000145class CoupledMemoryBuffers : public CoupledTransports<TMemoryBuffer> {
146 public:
David Reissd4788df2010-10-06 17:10:37 +0000147 CoupledMemoryBuffers() :
148 buf(new TMemoryBuffer) {
149 in = buf;
150 out = buf;
David Reiss35dc7692010-10-06 17:10:19 +0000151 }
152
David Reissd4788df2010-10-06 17:10:37 +0000153 boost::shared_ptr<TMemoryBuffer> buf;
154};
155
156/**
157 * Helper template class for creating coupled transports that wrap
158 * another transport.
159 */
160template <class WrapperTransport_, class InnerCoupledTransports_>
161class CoupledWrapperTransportsT : public CoupledTransports<WrapperTransport_> {
162 public:
163 CoupledWrapperTransportsT() {
164 if (inner_.in) {
165 this->in.reset(new WrapperTransport_(inner_.in));
166 }
167 if (inner_.out) {
168 this->out.reset(new WrapperTransport_(inner_.out));
169 }
170 }
171
172 InnerCoupledTransports_ inner_;
David Reiss35dc7692010-10-06 17:10:19 +0000173};
174
David Reiss0c025e82010-10-06 17:10:36 +0000175/**
176 * Coupled TBufferedTransports.
David Reiss0c025e82010-10-06 17:10:36 +0000177 */
David Reissd4788df2010-10-06 17:10:37 +0000178template <class InnerTransport_>
179class CoupledBufferedTransportsT :
180 public CoupledWrapperTransportsT<TBufferedTransport, InnerTransport_> {
David Reiss35dc7692010-10-06 17:10:19 +0000181};
182
David Reissd4788df2010-10-06 17:10:37 +0000183typedef CoupledBufferedTransportsT<CoupledMemoryBuffers>
184 CoupledBufferedTransports;
185
David Reiss0c025e82010-10-06 17:10:36 +0000186/**
187 * Coupled TFramedTransports.
David Reiss0c025e82010-10-06 17:10:36 +0000188 */
David Reissd4788df2010-10-06 17:10:37 +0000189template <class InnerTransport_>
190class CoupledFramedTransportsT :
191 public CoupledWrapperTransportsT<TFramedTransport, InnerTransport_> {
David Reiss35dc7692010-10-06 17:10:19 +0000192};
193
David Reissd4788df2010-10-06 17:10:37 +0000194typedef CoupledFramedTransportsT<CoupledMemoryBuffers>
195 CoupledFramedTransports;
196
David Reiss0c025e82010-10-06 17:10:36 +0000197/**
198 * Coupled TZlibTransports.
199 */
David Reissd4788df2010-10-06 17:10:37 +0000200template <class InnerTransport_>
201class CoupledZlibTransportsT :
202 public CoupledWrapperTransportsT<TZlibTransport, InnerTransport_> {
David Reisse94fa332010-10-06 17:10:26 +0000203};
204
David Reissd4788df2010-10-06 17:10:37 +0000205typedef CoupledZlibTransportsT<CoupledMemoryBuffers>
206 CoupledZlibTransports;
207
David Reiss0c025e82010-10-06 17:10:36 +0000208/**
209 * Coupled TFDTransports.
210 */
David Reiss35dc7692010-10-06 17:10:19 +0000211class CoupledFDTransports : public CoupledTransports<TFDTransport> {
212 public:
213 CoupledFDTransports() {
214 int pipes[2];
215
216 if (pipe(pipes) != 0) {
217 return;
218 }
219
David Reissd4788df2010-10-06 17:10:37 +0000220 in.reset(new TFDTransport(pipes[0], TFDTransport::CLOSE_ON_DESTROY));
221 out.reset(new TFDTransport(pipes[1], TFDTransport::CLOSE_ON_DESTROY));
David Reiss35dc7692010-10-06 17:10:19 +0000222 }
223};
224
David Reiss0c025e82010-10-06 17:10:36 +0000225/**
226 * Coupled TSockets
227 */
228class CoupledSocketTransports : public CoupledTransports<TSocket> {
229 public:
230 CoupledSocketTransports() {
231 int sockets[2];
232 if (socketpair(PF_UNIX, SOCK_STREAM, 0, sockets) != 0) {
233 return;
234 }
235
David Reissd4788df2010-10-06 17:10:37 +0000236 in.reset(new TSocket(sockets[0]));
237 out.reset(new TSocket(sockets[1]));
David Reiss0c025e82010-10-06 17:10:36 +0000238 }
239};
240
241/**
242 * Coupled TFileTransports
243 */
David Reiss35dc7692010-10-06 17:10:19 +0000244class CoupledFileTransports : public CoupledTransports<TFileTransport> {
245 public:
246 CoupledFileTransports() {
247 // Create a temporary file to use
248 size_t filename_len = strlen(tmp_dir) + 32;
249 filename = new char[filename_len];
250 snprintf(filename, filename_len,
251 "%s/thrift.transport_test.XXXXXX", tmp_dir);
252 fd = mkstemp(filename);
253 if (fd < 0) {
254 return;
255 }
256
David Reissd4788df2010-10-06 17:10:37 +0000257 in.reset(new TFileTransport(filename, true));
258 out.reset(new TFileTransport(filename));
David Reiss35dc7692010-10-06 17:10:19 +0000259 }
260
261 ~CoupledFileTransports() {
David Reiss35dc7692010-10-06 17:10:19 +0000262 if (fd >= 0) {
263 close(fd);
264 unlink(filename);
265 }
266 delete[] filename;
267 }
268
269 char* filename;
270 int fd;
271};
272
David Reiss0c025e82010-10-06 17:10:36 +0000273/**
274 * Wrapper around another CoupledTransports implementation that exposes the
275 * transports as TTransport pointers.
276 *
277 * This is used since accessing a transport via a "TTransport*" exercises a
278 * different code path than using the base pointer class. As part of the
279 * template code changes, most transport methods are no longer virtual.
280 */
David Reiss35dc7692010-10-06 17:10:19 +0000281template <class CoupledTransports_>
282class CoupledTTransports : public CoupledTransports<TTransport> {
283 public:
284 CoupledTTransports() : transports() {
285 in = transports.in;
286 out = transports.out;
287 }
288
289 CoupledTransports_ transports;
290};
291
David Reiss0c025e82010-10-06 17:10:36 +0000292/**
293 * Wrapper around another CoupledTransports implementation that exposes the
294 * transports as TBufferBase pointers.
295 *
296 * This can only be instantiated with a transport type that is a subclass of
297 * TBufferBase.
298 */
David Reiss35dc7692010-10-06 17:10:19 +0000299template <class CoupledTransports_>
300class CoupledBufferBases : public CoupledTransports<TBufferBase> {
301 public:
302 CoupledBufferBases() : transports() {
303 in = transports.in;
304 out = transports.out;
305 }
306
307 CoupledTransports_ transports;
308};
309
David Reiss35dc7692010-10-06 17:10:19 +0000310/**************************************************************************
David Reisse5c435c2010-10-06 17:10:38 +0000311 * Alarm handling code for use in tests that check the transport blocking
312 * semantics.
313 *
314 * If the transport ends up blocking, we don't want to hang forever. We use
315 * SIGALRM to fire schedule signal to wake up and try to write data so the
316 * transport will unblock.
317 *
318 * It isn't really the safest thing in the world to be mucking around with
319 * complicated global data structures in a signal handler. It should probably
320 * be okay though, since we know the main thread should always be blocked in a
321 * read() request when the signal handler is running.
322 **************************************************************************/
323
324struct TriggerInfo {
325 TriggerInfo(int seconds, const boost::shared_ptr<TTransport>& transport,
326 uint32_t writeLength) :
327 timeoutSeconds(seconds),
328 transport(transport),
329 writeLength(writeLength),
330 next(NULL) {}
331
332 int timeoutSeconds;
333 boost::shared_ptr<TTransport> transport;
334 uint32_t writeLength;
335 TriggerInfo* next;
336};
337
338TriggerInfo* triggerInfo;
339unsigned int numTriggersFired;
340
341void set_alarm();
342
343void alarm_handler(int signum) {
Roger Meier3b771a12010-11-17 22:11:26 +0000344 (void) signum;
David Reisse5c435c2010-10-06 17:10:38 +0000345 // The alarm timed out, which almost certainly means we're stuck
346 // on a transport that is incorrectly blocked.
347 ++numTriggersFired;
348
349 // Note: we print messages to stdout instead of stderr, since
350 // tools/test/runner only records stdout messages in the failure messages for
351 // boost tests. (boost prints its test info to stdout.)
352 printf("Timeout alarm expired; attempting to unblock transport\n");
353 if (triggerInfo == NULL) {
354 printf(" trigger stack is empty!\n");
355 }
356
357 // Pop off the first TriggerInfo.
358 // If there is another one, schedule an alarm for it.
359 TriggerInfo* info = triggerInfo;
360 triggerInfo = info->next;
361 set_alarm();
362
363 // Write some data to the transport to hopefully unblock it.
Roger Meier0069cc42010-10-13 18:10:18 +0000364 uint8_t* buf = new uint8_t[info->writeLength];
David Reisse5c435c2010-10-06 17:10:38 +0000365 memset(buf, 'b', info->writeLength);
Roger Meier0069cc42010-10-13 18:10:18 +0000366 boost::scoped_array<uint8_t> array(buf);
David Reisse5c435c2010-10-06 17:10:38 +0000367 info->transport->write(buf, info->writeLength);
368 info->transport->flush();
369
370 delete info;
371}
372
373void set_alarm() {
374 if (triggerInfo == NULL) {
375 // clear any alarm
376 alarm(0);
377 return;
378 }
379
380 struct sigaction action;
381 memset(&action, 0, sizeof(action));
382 action.sa_handler = alarm_handler;
Christian Lavoie4f42ef72010-11-04 18:51:42 +0000383 action.sa_flags = SA_RESETHAND;
David Reisse5c435c2010-10-06 17:10:38 +0000384 sigemptyset(&action.sa_mask);
385 sigaction(SIGALRM, &action, NULL);
386
387 alarm(triggerInfo->timeoutSeconds);
388}
389
390/**
391 * Add a trigger to be scheduled "seconds" seconds after the
392 * last currently scheduled trigger.
393 *
394 * (Note that this is not "seconds" from now. That might be more logical, but
395 * would require slightly more complicated sorting, rather than just appending
396 * to the end.)
397 */
398void add_trigger(unsigned int seconds,
399 const boost::shared_ptr<TTransport> &transport,
400 uint32_t write_len) {
401 TriggerInfo* info = new TriggerInfo(seconds, transport, write_len);
402
403 if (triggerInfo == NULL) {
404 // This is the first trigger.
405 // Set triggerInfo, and schedule the alarm
406 triggerInfo = info;
407 set_alarm();
408 } else {
409 // Add this trigger to the end of the list
410 TriggerInfo* prev = triggerInfo;
411 while (prev->next) {
412 prev = prev->next;
413 }
414
415 prev->next = info;
416 }
417}
418
419void clear_triggers() {
420 TriggerInfo *info = triggerInfo;
421 alarm(0);
422 triggerInfo = NULL;
423 numTriggersFired = 0;
424
425 while (info != NULL) {
426 TriggerInfo* next = info->next;
427 delete info;
428 info = next;
429 }
430}
431
432void set_trigger(unsigned int seconds,
433 const boost::shared_ptr<TTransport> &transport,
434 uint32_t write_len) {
435 clear_triggers();
436 add_trigger(seconds, transport, write_len);
437}
438
439/**************************************************************************
440 * Test functions
David Reiss35dc7692010-10-06 17:10:19 +0000441 **************************************************************************/
442
443/**
444 * Test interleaved write and read calls.
445 *
446 * Generates a buffer totalSize bytes long, then writes it to the transport,
447 * and verifies the written data can be read back correctly.
448 *
449 * Mode of operation:
450 * - call wChunkGenerator to figure out how large of a chunk to write
451 * - call wSizeGenerator to get the size for individual write() calls,
452 * and do this repeatedly until the entire chunk is written.
453 * - call rChunkGenerator to figure out how large of a chunk to read
454 * - call rSizeGenerator to get the size for individual read() calls,
455 * and do this repeatedly until the entire chunk is read.
456 * - repeat until the full buffer is written and read back,
457 * then compare the data read back against the original buffer
458 *
459 *
460 * - If any of the size generators return 0, this means to use the maximum
461 * possible size.
462 *
463 * - If maxOutstanding is non-zero, write chunk sizes will be chosen such that
464 * there are never more than maxOutstanding bytes waiting to be read back.
465 */
466template <class CoupledTransports>
467void test_rw(uint32_t totalSize,
468 SizeGenerator& wSizeGenerator,
469 SizeGenerator& rSizeGenerator,
470 SizeGenerator& wChunkGenerator,
471 SizeGenerator& rChunkGenerator,
472 uint32_t maxOutstanding) {
473 CoupledTransports transports;
474 BOOST_REQUIRE(transports.in != NULL);
475 BOOST_REQUIRE(transports.out != NULL);
476
477 boost::shared_array<uint8_t> wbuf =
478 boost::shared_array<uint8_t>(new uint8_t[totalSize]);
479 boost::shared_array<uint8_t> rbuf =
480 boost::shared_array<uint8_t>(new uint8_t[totalSize]);
481
482 // store some data in wbuf
483 for (uint32_t n = 0; n < totalSize; ++n) {
484 wbuf[n] = (n & 0xff);
485 }
486 // clear rbuf
487 memset(rbuf.get(), 0, totalSize);
488
489 uint32_t total_written = 0;
490 uint32_t total_read = 0;
491 while (total_read < totalSize) {
492 // Determine how large a chunk of data to write
493 uint32_t wchunk_size = wChunkGenerator.nextSize();
494 if (wchunk_size == 0 || wchunk_size > totalSize - total_written) {
495 wchunk_size = totalSize - total_written;
496 }
497
498 // Make sure (total_written - total_read) + wchunk_size
499 // is less than maxOutstanding
500 if (maxOutstanding > 0 &&
501 wchunk_size > maxOutstanding - (total_written - total_read)) {
502 wchunk_size = maxOutstanding - (total_written - total_read);
503 }
504
505 // Write the chunk
506 uint32_t chunk_written = 0;
507 while (chunk_written < wchunk_size) {
508 uint32_t write_size = wSizeGenerator.nextSize();
509 if (write_size == 0 || write_size > wchunk_size - chunk_written) {
510 write_size = wchunk_size - chunk_written;
511 }
512
513 transports.out->write(wbuf.get() + total_written, write_size);
514 chunk_written += write_size;
515 total_written += write_size;
516 }
517
518 // Flush the data, so it will be available in the read transport
519 // Don't flush if wchunk_size is 0. (This should only happen if
520 // total_written == totalSize already, and we're only reading now.)
521 if (wchunk_size > 0) {
522 transports.out->flush();
523 }
524
525 // Determine how large a chunk of data to read back
526 uint32_t rchunk_size = rChunkGenerator.nextSize();
527 if (rchunk_size == 0 || rchunk_size > total_written - total_read) {
528 rchunk_size = total_written - total_read;
529 }
530
531 // Read the chunk
532 uint32_t chunk_read = 0;
533 while (chunk_read < rchunk_size) {
534 uint32_t read_size = rSizeGenerator.nextSize();
535 if (read_size == 0 || read_size > rchunk_size - chunk_read) {
536 read_size = rchunk_size - chunk_read;
537 }
538
David Reisse94fa332010-10-06 17:10:26 +0000539 int bytes_read = -1;
540 try {
541 bytes_read = transports.in->read(rbuf.get() + total_read, read_size);
542 } catch (TTransportException& e) {
543 BOOST_FAIL("read(pos=" << total_read << ", size=" << read_size <<
544 ") threw exception \"" << e.what() <<
545 "\"; written so far: " << total_written << " / " <<
546 totalSize << " bytes");
547 }
548
David Reiss35dc7692010-10-06 17:10:19 +0000549 BOOST_REQUIRE_MESSAGE(bytes_read > 0,
550 "read(pos=" << total_read << ", size=" <<
551 read_size << ") returned " << bytes_read <<
552 "; written so far: " << total_written << " / " <<
553 totalSize << " bytes");
554 chunk_read += bytes_read;
555 total_read += bytes_read;
556 }
557 }
558
559 // make sure the data read back is identical to the data written
560 BOOST_CHECK_EQUAL(memcmp(rbuf.get(), wbuf.get(), totalSize), 0);
561}
562
David Reisse5c435c2010-10-06 17:10:38 +0000563template <class CoupledTransports>
564void test_read_part_available() {
565 CoupledTransports transports;
566 BOOST_REQUIRE(transports.in != NULL);
567 BOOST_REQUIRE(transports.out != NULL);
568
569 uint8_t write_buf[16];
570 uint8_t read_buf[16];
571 memset(write_buf, 'a', sizeof(write_buf));
572
573 // Attemping to read 10 bytes when only 9 are available should return 9
574 // immediately.
575 transports.out->write(write_buf, 9);
576 transports.out->flush();
577 set_trigger(3, transports.out, 1);
578 uint32_t bytes_read = transports.in->read(read_buf, 10);
Christian Lavoie01c5ceb2010-11-04 20:35:15 +0000579 BOOST_CHECK_EQUAL(numTriggersFired, (unsigned int) 0);
580 BOOST_CHECK_EQUAL(bytes_read, (uint32_t) 9);
David Reisse5c435c2010-10-06 17:10:38 +0000581
582 clear_triggers();
583}
584
585template <class CoupledTransports>
David Reiss0a2d81e2010-10-06 17:10:40 +0000586void test_read_partial_midframe() {
587 CoupledTransports transports;
588 BOOST_REQUIRE(transports.in != NULL);
589 BOOST_REQUIRE(transports.out != NULL);
590
591 uint8_t write_buf[16];
592 uint8_t read_buf[16];
593 memset(write_buf, 'a', sizeof(write_buf));
594
595 // Attempt to read 10 bytes, when only 9 are available, but after we have
596 // already read part of the data that is available. This exercises a
597 // different code path for several of the transports.
598 //
599 // For transports that add their own framing (e.g., TFramedTransport and
600 // TFileTransport), the two flush calls break up the data in to a 10 byte
601 // frame and a 3 byte frame. The first read then puts us partway through the
602 // first frame, and then we attempt to read past the end of that frame, and
603 // through the next frame, too.
604 //
605 // For buffered transports that perform read-ahead (e.g.,
606 // TBufferedTransport), the read-ahead will most likely see all 13 bytes
607 // written on the first read. The next read will then attempt to read past
608 // the end of the read-ahead buffer.
609 //
610 // Flush 10 bytes, then 3 bytes. This creates 2 separate frames for
611 // transports that track framing internally.
612 transports.out->write(write_buf, 10);
613 transports.out->flush();
614 transports.out->write(write_buf, 3);
615 transports.out->flush();
616
617 // Now read 4 bytes, so that we are partway through the written data.
618 uint32_t bytes_read = transports.in->read(read_buf, 4);
Christian Lavoie01c5ceb2010-11-04 20:35:15 +0000619 BOOST_CHECK_EQUAL(bytes_read, (uint32_t) 4);
David Reiss0a2d81e2010-10-06 17:10:40 +0000620
621 // Now attempt to read 10 bytes. Only 9 more are available.
622 //
623 // We should be able to get all 9 bytes, but it might take multiple read
624 // calls, since it is valid for read() to return fewer bytes than requested.
625 // (Most transports do immediately return 9 bytes, but the framing transports
626 // tend to only return to the end of the current frame, which is 6 bytes in
627 // this case.)
628 uint32_t total_read = 0;
629 while (total_read < 9) {
630 set_trigger(3, transports.out, 1);
631 bytes_read = transports.in->read(read_buf, 10);
Christian Lavoie01c5ceb2010-11-04 20:35:15 +0000632 BOOST_REQUIRE_EQUAL(numTriggersFired, (unsigned int) 0);
633 BOOST_REQUIRE_GT(bytes_read, (uint32_t) 0);
David Reiss0a2d81e2010-10-06 17:10:40 +0000634 total_read += bytes_read;
Christian Lavoie01c5ceb2010-11-04 20:35:15 +0000635 BOOST_REQUIRE_LE(total_read, (uint32_t) 9);
David Reiss0a2d81e2010-10-06 17:10:40 +0000636 }
637
Christian Lavoie01c5ceb2010-11-04 20:35:15 +0000638 BOOST_CHECK_EQUAL(total_read, (uint32_t) 9);
David Reiss0a2d81e2010-10-06 17:10:40 +0000639
640 clear_triggers();
641}
642
643template <class CoupledTransports>
David Reisse5c435c2010-10-06 17:10:38 +0000644void test_borrow_part_available() {
645 CoupledTransports transports;
646 BOOST_REQUIRE(transports.in != NULL);
647 BOOST_REQUIRE(transports.out != NULL);
648
649 uint8_t write_buf[16];
650 uint8_t read_buf[16];
651 memset(write_buf, 'a', sizeof(write_buf));
652
653 // Attemping to borrow 10 bytes when only 9 are available should return NULL
654 // immediately.
655 transports.out->write(write_buf, 9);
656 transports.out->flush();
657 set_trigger(3, transports.out, 1);
658 uint32_t borrow_len = 10;
659 const uint8_t* borrowed_buf = transports.in->borrow(read_buf, &borrow_len);
Christian Lavoie01c5ceb2010-11-04 20:35:15 +0000660 BOOST_CHECK_EQUAL(numTriggersFired, (unsigned int) 0);
David Reisse5c435c2010-10-06 17:10:38 +0000661 BOOST_CHECK(borrowed_buf == NULL);
662
663 clear_triggers();
664}
665
666template <class CoupledTransports>
667void test_read_none_available() {
668 CoupledTransports transports;
669 BOOST_REQUIRE(transports.in != NULL);
670 BOOST_REQUIRE(transports.out != NULL);
671
672 uint8_t write_buf[16];
673 uint8_t read_buf[16];
674 memset(write_buf, 'a', sizeof(write_buf));
675
676 // Attempting to read when no data is available should either block until
677 // some data is available, or fail immediately. (e.g., TSocket blocks,
678 // TMemoryBuffer just fails.)
679 //
680 // If the transport blocks, it should succeed once some data is available,
681 // even if less than the amount requested becomes available.
682 set_trigger(1, transports.out, 2);
683 add_trigger(1, transports.out, 8);
684 uint32_t bytes_read = transports.in->read(read_buf, 10);
685 if (bytes_read == 0) {
Christian Lavoie01c5ceb2010-11-04 20:35:15 +0000686 BOOST_CHECK_EQUAL(numTriggersFired, (unsigned int) 0);
David Reisse5c435c2010-10-06 17:10:38 +0000687 clear_triggers();
688 } else {
Christian Lavoie01c5ceb2010-11-04 20:35:15 +0000689 BOOST_CHECK_EQUAL(numTriggersFired, (unsigned int) 1);
690 BOOST_CHECK_EQUAL(bytes_read, (uint32_t) 2);
David Reisse5c435c2010-10-06 17:10:38 +0000691 }
692
693 clear_triggers();
694}
695
696template <class CoupledTransports>
697void test_borrow_none_available() {
698 CoupledTransports transports;
699 BOOST_REQUIRE(transports.in != NULL);
700 BOOST_REQUIRE(transports.out != NULL);
701
702 uint8_t write_buf[16];
703 memset(write_buf, 'a', sizeof(write_buf));
704
705 // Attempting to borrow when no data is available should fail immediately
706 set_trigger(1, transports.out, 10);
707 uint32_t borrow_len = 10;
708 const uint8_t* borrowed_buf = transports.in->borrow(NULL, &borrow_len);
709 BOOST_CHECK(borrowed_buf == NULL);
Christian Lavoie01c5ceb2010-11-04 20:35:15 +0000710 BOOST_CHECK_EQUAL(numTriggersFired, (unsigned int) 0);
David Reisse5c435c2010-10-06 17:10:38 +0000711
712 clear_triggers();
713}
714
David Reiss35dc7692010-10-06 17:10:19 +0000715/**************************************************************************
716 * Test case generation
717 *
718 * Pretty ugly and annoying. This would be much easier if we the unit test
719 * framework didn't force each test to be a separate function.
720 * - Writing a completely separate function definition for each of these would
721 * result in a lot of repetitive boilerplate code.
722 * - Combining many tests into a single function makes it more difficult to
723 * tell precisely which tests failed. It also means you can't get a progress
724 * update after each test, and the tests are already fairly slow.
725 * - Similar registration could be acheived with BOOST_TEST_CASE_TEMPLATE,
726 * but it requires a lot of awkward MPL code, and results in useless test
727 * case names. (The names are generated from std::type_info::name(), which
728 * is compiler-dependent. gcc returns mangled names.)
729 **************************************************************************/
730
David Reisse5c435c2010-10-06 17:10:38 +0000731#define ADD_TEST_RW(CoupledTransports, totalSize, ...) \
732 addTestRW< CoupledTransports >(BOOST_STRINGIZE(CoupledTransports), \
733 totalSize, ## __VA_ARGS__);
David Reissd4788df2010-10-06 17:10:37 +0000734
David Reiss35dc7692010-10-06 17:10:19 +0000735#define TEST_RW(CoupledTransports, totalSize, ...) \
736 do { \
737 /* Add the test as specified, to test the non-virtual function calls */ \
David Reisse5c435c2010-10-06 17:10:38 +0000738 ADD_TEST_RW(CoupledTransports, totalSize, ## __VA_ARGS__); \
David Reiss35dc7692010-10-06 17:10:19 +0000739 /* \
740 * Also test using the transport as a TTransport*, to test \
741 * the read_virt()/write_virt() calls \
742 */ \
David Reisse5c435c2010-10-06 17:10:38 +0000743 ADD_TEST_RW(CoupledTTransports<CoupledTransports>, \
744 totalSize, ## __VA_ARGS__); \
David Reissd4788df2010-10-06 17:10:37 +0000745 /* Test wrapping the transport with TBufferedTransport */ \
David Reisse5c435c2010-10-06 17:10:38 +0000746 ADD_TEST_RW(CoupledBufferedTransportsT<CoupledTransports>, \
747 totalSize, ## __VA_ARGS__); \
David Reissd4788df2010-10-06 17:10:37 +0000748 /* Test wrapping the transport with TFramedTransports */ \
David Reisse5c435c2010-10-06 17:10:38 +0000749 ADD_TEST_RW(CoupledFramedTransportsT<CoupledTransports>, \
750 totalSize, ## __VA_ARGS__); \
David Reissd4788df2010-10-06 17:10:37 +0000751 /* Test wrapping the transport with TZlibTransport */ \
David Reisse5c435c2010-10-06 17:10:38 +0000752 ADD_TEST_RW(CoupledZlibTransportsT<CoupledTransports>, \
753 totalSize, ## __VA_ARGS__); \
David Reiss35dc7692010-10-06 17:10:19 +0000754 } while (0)
755
David Reisse5c435c2010-10-06 17:10:38 +0000756#define ADD_TEST_BLOCKING(CoupledTransports) \
757 addTestBlocking< CoupledTransports >(BOOST_STRINGIZE(CoupledTransports));
758
759#define TEST_BLOCKING_BEHAVIOR(CoupledTransports) \
760 ADD_TEST_BLOCKING(CoupledTransports); \
761 ADD_TEST_BLOCKING(CoupledTTransports<CoupledTransports>); \
762 ADD_TEST_BLOCKING(CoupledBufferedTransportsT<CoupledTransports>); \
763 ADD_TEST_BLOCKING(CoupledFramedTransportsT<CoupledTransports>); \
764 ADD_TEST_BLOCKING(CoupledZlibTransportsT<CoupledTransports>);
765
David Reiss35dc7692010-10-06 17:10:19 +0000766class TransportTestGen {
767 public:
David Reiss65e62d32010-10-06 17:10:35 +0000768 TransportTestGen(boost::unit_test::test_suite* suite,
769 float sizeMultiplier) :
770 suite_(suite),
771 sizeMultiplier_(sizeMultiplier) {}
David Reiss35dc7692010-10-06 17:10:19 +0000772
773 void generate() {
774 GenericSizeGenerator rand4k(1, 4096);
775
776 /*
777 * We do the basically the same set of tests for each transport type,
778 * although we tweak the parameters in some places.
779 */
780
David Reissd4788df2010-10-06 17:10:37 +0000781 // TMemoryBuffer tests
782 TEST_RW(CoupledMemoryBuffers, 1024*1024, 0, 0);
783 TEST_RW(CoupledMemoryBuffers, 1024*256, rand4k, rand4k);
784 TEST_RW(CoupledMemoryBuffers, 1024*256, 167, 163);
785 TEST_RW(CoupledMemoryBuffers, 1024*16, 1, 1);
David Reiss35dc7692010-10-06 17:10:19 +0000786
David Reissd4788df2010-10-06 17:10:37 +0000787 TEST_RW(CoupledMemoryBuffers, 1024*256, 0, 0, rand4k, rand4k);
788 TEST_RW(CoupledMemoryBuffers, 1024*256, rand4k, rand4k, rand4k, rand4k);
789 TEST_RW(CoupledMemoryBuffers, 1024*256, 167, 163, rand4k, rand4k);
790 TEST_RW(CoupledMemoryBuffers, 1024*16, 1, 1, rand4k, rand4k);
David Reisse94fa332010-10-06 17:10:26 +0000791
David Reisse5c435c2010-10-06 17:10:38 +0000792 TEST_BLOCKING_BEHAVIOR(CoupledMemoryBuffers);
793
David Reiss35dc7692010-10-06 17:10:19 +0000794 // TFDTransport tests
795 // Since CoupledFDTransports tests with a pipe, writes will block
796 // if there is too much outstanding unread data in the pipe.
797 uint32_t fd_max_outstanding = 4096;
David Reiss65e62d32010-10-06 17:10:35 +0000798 TEST_RW(CoupledFDTransports, 1024*1024, 0, 0,
David Reiss35dc7692010-10-06 17:10:19 +0000799 0, 0, fd_max_outstanding);
David Reiss65e62d32010-10-06 17:10:35 +0000800 TEST_RW(CoupledFDTransports, 1024*256, rand4k, rand4k,
David Reiss35dc7692010-10-06 17:10:19 +0000801 0, 0, fd_max_outstanding);
David Reiss65e62d32010-10-06 17:10:35 +0000802 TEST_RW(CoupledFDTransports, 1024*256, 167, 163,
David Reiss35dc7692010-10-06 17:10:19 +0000803 0, 0, fd_max_outstanding);
David Reiss65e62d32010-10-06 17:10:35 +0000804 TEST_RW(CoupledFDTransports, 1024*16, 1, 1,
David Reiss35dc7692010-10-06 17:10:19 +0000805 0, 0, fd_max_outstanding);
806
David Reiss65e62d32010-10-06 17:10:35 +0000807 TEST_RW(CoupledFDTransports, 1024*256, 0, 0,
David Reiss35dc7692010-10-06 17:10:19 +0000808 rand4k, rand4k, fd_max_outstanding);
David Reiss65e62d32010-10-06 17:10:35 +0000809 TEST_RW(CoupledFDTransports, 1024*256, rand4k, rand4k,
David Reiss35dc7692010-10-06 17:10:19 +0000810 rand4k, rand4k, fd_max_outstanding);
David Reiss65e62d32010-10-06 17:10:35 +0000811 TEST_RW(CoupledFDTransports, 1024*256, 167, 163,
David Reiss35dc7692010-10-06 17:10:19 +0000812 rand4k, rand4k, fd_max_outstanding);
David Reiss65e62d32010-10-06 17:10:35 +0000813 TEST_RW(CoupledFDTransports, 1024*16, 1, 1,
David Reiss35dc7692010-10-06 17:10:19 +0000814 rand4k, rand4k, fd_max_outstanding);
815
David Reisse5c435c2010-10-06 17:10:38 +0000816 TEST_BLOCKING_BEHAVIOR(CoupledFDTransports);
817
David Reiss0c025e82010-10-06 17:10:36 +0000818 // TSocket tests
819 uint32_t socket_max_outstanding = 4096;
820 TEST_RW(CoupledSocketTransports, 1024*1024, 0, 0,
821 0, 0, socket_max_outstanding);
822 TEST_RW(CoupledSocketTransports, 1024*256, rand4k, rand4k,
823 0, 0, socket_max_outstanding);
824 TEST_RW(CoupledSocketTransports, 1024*256, 167, 163,
825 0, 0, socket_max_outstanding);
826 // Doh. Apparently writing to a socket has some additional overhead for
827 // each send() call. If we have more than ~400 outstanding 1-byte write
828 // requests, additional send() calls start blocking.
829 TEST_RW(CoupledSocketTransports, 1024*16, 1, 1,
830 0, 0, 400);
831 TEST_RW(CoupledSocketTransports, 1024*256, 0, 0,
832 rand4k, rand4k, socket_max_outstanding);
833 TEST_RW(CoupledSocketTransports, 1024*256, rand4k, rand4k,
834 rand4k, rand4k, socket_max_outstanding);
835 TEST_RW(CoupledSocketTransports, 1024*256, 167, 163,
836 rand4k, rand4k, socket_max_outstanding);
837 TEST_RW(CoupledSocketTransports, 1024*16, 1, 1,
838 rand4k, rand4k, 400);
839
David Reisse5c435c2010-10-06 17:10:38 +0000840 TEST_BLOCKING_BEHAVIOR(CoupledSocketTransports);
841
David Reiss35dc7692010-10-06 17:10:19 +0000842 // TFileTransport tests
843 // We use smaller buffer sizes here, since TFileTransport is fairly slow.
844 //
845 // TFileTransport can't write more than 16MB at once
846 uint32_t max_write_at_once = 1024*1024*16 - 4;
David Reiss65e62d32010-10-06 17:10:35 +0000847 TEST_RW(CoupledFileTransports, 1024*1024, max_write_at_once, 0);
848 TEST_RW(CoupledFileTransports, 1024*128, rand4k, rand4k);
849 TEST_RW(CoupledFileTransports, 1024*128, 167, 163);
850 TEST_RW(CoupledFileTransports, 1024*2, 1, 1);
David Reiss35dc7692010-10-06 17:10:19 +0000851
David Reiss65e62d32010-10-06 17:10:35 +0000852 TEST_RW(CoupledFileTransports, 1024*64, 0, 0, rand4k, rand4k);
853 TEST_RW(CoupledFileTransports, 1024*64,
David Reiss35dc7692010-10-06 17:10:19 +0000854 rand4k, rand4k, rand4k, rand4k);
David Reiss65e62d32010-10-06 17:10:35 +0000855 TEST_RW(CoupledFileTransports, 1024*64, 167, 163, rand4k, rand4k);
856 TEST_RW(CoupledFileTransports, 1024*2, 1, 1, rand4k, rand4k);
David Reissd4788df2010-10-06 17:10:37 +0000857
David Reisse5c435c2010-10-06 17:10:38 +0000858 TEST_BLOCKING_BEHAVIOR(CoupledFileTransports);
859
David Reissd4788df2010-10-06 17:10:37 +0000860 // Add some tests that access TBufferedTransport and TFramedTransport
861 // via TTransport pointers and TBufferBase pointers.
David Reisse5c435c2010-10-06 17:10:38 +0000862 ADD_TEST_RW(CoupledTTransports<CoupledBufferedTransports>,
863 1024*1024, rand4k, rand4k, rand4k, rand4k);
864 ADD_TEST_RW(CoupledBufferBases<CoupledBufferedTransports>,
865 1024*1024, rand4k, rand4k, rand4k, rand4k);
866 ADD_TEST_RW(CoupledTTransports<CoupledFramedTransports>,
867 1024*1024, rand4k, rand4k, rand4k, rand4k);
868 ADD_TEST_RW(CoupledBufferBases<CoupledFramedTransports>,
869 1024*1024, rand4k, rand4k, rand4k, rand4k);
David Reissd4788df2010-10-06 17:10:37 +0000870
871 // Test using TZlibTransport via a TTransport pointer
David Reisse5c435c2010-10-06 17:10:38 +0000872 ADD_TEST_RW(CoupledTTransports<CoupledZlibTransports>,
873 1024*1024, rand4k, rand4k, rand4k, rand4k);
David Reiss35dc7692010-10-06 17:10:19 +0000874 }
875
876 private:
877 template <class CoupledTransports>
David Reisse5c435c2010-10-06 17:10:38 +0000878 void addTestRW(const char* transport_name, uint32_t totalSize,
879 GenericSizeGenerator wSizeGen, GenericSizeGenerator rSizeGen,
880 GenericSizeGenerator wChunkSizeGen = 0,
881 GenericSizeGenerator rChunkSizeGen = 0,
882 uint32_t maxOutstanding = 0,
883 uint32_t expectedFailures = 0) {
David Reiss65e62d32010-10-06 17:10:35 +0000884 // adjust totalSize by the specified sizeMultiplier_ first
885 totalSize = static_cast<uint32_t>(totalSize * sizeMultiplier_);
886
David Reiss35dc7692010-10-06 17:10:19 +0000887 std::ostringstream name;
888 name << transport_name << "::test_rw(" << totalSize << ", " <<
889 wSizeGen.describe() << ", " << rSizeGen.describe() << ", " <<
890 wChunkSizeGen.describe() << ", " << rChunkSizeGen.describe() << ", " <<
891 maxOutstanding << ")";
892
893 boost::unit_test::callback0<> test_func =
894 std::tr1::bind(test_rw<CoupledTransports>, totalSize,
895 wSizeGen, rSizeGen, wChunkSizeGen, rChunkSizeGen,
896 maxOutstanding);
897 boost::unit_test::test_case* tc =
898 boost::unit_test::make_test_case(test_func, name.str());
899 suite_->add(tc, expectedFailures);
Roger Meier0069cc42010-10-13 18:10:18 +0000900 }
David Reiss35dc7692010-10-06 17:10:19 +0000901
David Reisse5c435c2010-10-06 17:10:38 +0000902 template <class CoupledTransports>
903 void addTestBlocking(const char* transportName,
904 uint32_t expectedFailures = 0) {
905 char name[1024];
906 boost::unit_test::test_case* tc;
907
908 snprintf(name, sizeof(name), "%s::test_read_part_available()",
909 transportName);
910 tc = boost::unit_test::make_test_case(
911 test_read_part_available<CoupledTransports>, name);
912 suite_->add(tc, expectedFailures);
913
David Reiss0a2d81e2010-10-06 17:10:40 +0000914 snprintf(name, sizeof(name), "%s::test_read_partial_midframe()",
915 transportName);
916 tc = boost::unit_test::make_test_case(
917 test_read_partial_midframe<CoupledTransports>, name);
918 suite_->add(tc, expectedFailures);
919
David Reisse5c435c2010-10-06 17:10:38 +0000920 snprintf(name, sizeof(name), "%s::test_read_none_available()",
921 transportName);
922 tc = boost::unit_test::make_test_case(
923 test_read_none_available<CoupledTransports>, name);
924 suite_->add(tc, expectedFailures);
925
926 snprintf(name, sizeof(name), "%s::test_borrow_part_available()",
927 transportName);
928 tc = boost::unit_test::make_test_case(
929 test_borrow_part_available<CoupledTransports>, name);
930 suite_->add(tc, expectedFailures);
931
932 snprintf(name, sizeof(name), "%s::test_borrow_none_available()",
933 transportName);
934 tc = boost::unit_test::make_test_case(
935 test_borrow_none_available<CoupledTransports>, name);
936 suite_->add(tc, expectedFailures);
937 }
938
David Reiss35dc7692010-10-06 17:10:19 +0000939 boost::unit_test::test_suite* suite_;
David Reiss65e62d32010-10-06 17:10:35 +0000940 // sizeMultiplier_ is configurable via the command line, and allows the
941 // user to adjust between smaller buffers that can be tested quickly,
942 // or larger buffers that more thoroughly exercise the code, but take
943 // longer.
944 float sizeMultiplier_;
David Reiss35dc7692010-10-06 17:10:19 +0000945};
946
947/**************************************************************************
948 * General Initialization
949 **************************************************************************/
950
951void print_usage(FILE* f, const char* argv0) {
952 fprintf(f, "Usage: %s [boost_options] [options]\n", argv0);
953 fprintf(f, "Options:\n");
954 fprintf(f, " --seed=<N>, -s <N>\n");
955 fprintf(f, " --tmp-dir=DIR, -t DIR\n");
956 fprintf(f, " --help\n");
957}
958
David Reiss65e62d32010-10-06 17:10:35 +0000959struct Options {
David Reiss35dc7692010-10-06 17:10:19 +0000960 int seed;
David Reiss65e62d32010-10-06 17:10:35 +0000961 bool haveSeed;
962 float sizeMultiplier;
963};
964
965void parse_args(int argc, char* argv[], Options* options) {
966 bool have_seed = false;
967 options->sizeMultiplier = 1;
David Reiss35dc7692010-10-06 17:10:19 +0000968
969 struct option long_opts[] = {
970 { "help", false, NULL, 'h' },
971 { "seed", true, NULL, 's' },
972 { "tmp-dir", true, NULL, 't' },
David Reiss65e62d32010-10-06 17:10:35 +0000973 { "size-multiplier", true, NULL, 'x' },
David Reiss35dc7692010-10-06 17:10:19 +0000974 { NULL, 0, NULL, 0 }
975 };
976
977 while (true) {
978 optopt = 1;
David Reiss65e62d32010-10-06 17:10:35 +0000979 int optchar = getopt_long(argc, argv, "hs:t:x:", long_opts, NULL);
David Reiss35dc7692010-10-06 17:10:19 +0000980 if (optchar == -1) {
981 break;
982 }
983
984 switch (optchar) {
985 case 't':
986 tmp_dir = optarg;
987 break;
988 case 's': {
989 char *endptr;
David Reiss65e62d32010-10-06 17:10:35 +0000990 options->seed = strtol(optarg, &endptr, 0);
David Reiss35dc7692010-10-06 17:10:19 +0000991 if (endptr == optarg || *endptr != '\0') {
992 fprintf(stderr, "invalid seed value \"%s\": must be an integer\n",
993 optarg);
994 exit(1);
995 }
David Reiss65e62d32010-10-06 17:10:35 +0000996 have_seed = true;
David Reiss35dc7692010-10-06 17:10:19 +0000997 break;
998 }
999 case 'h':
1000 print_usage(stdout, argv[0]);
1001 exit(0);
David Reiss65e62d32010-10-06 17:10:35 +00001002 case 'x': {
1003 char *endptr;
1004 options->sizeMultiplier = strtof(optarg, &endptr);
1005 if (endptr == optarg || *endptr != '\0') {
1006 fprintf(stderr, "invalid size multiplier \"%s\": must be a number\n",
1007 optarg);
1008 exit(1);
1009 }
1010 if (options->sizeMultiplier < 0) {
1011 fprintf(stderr, "invalid size multiplier \"%s\": "
1012 "must be non-negative\n", optarg);
1013 exit(1);
1014 }
1015 break;
1016 }
David Reiss35dc7692010-10-06 17:10:19 +00001017 case '?':
1018 exit(1);
1019 default:
1020 // Only happens if someone adds another option to the optarg string,
1021 // but doesn't update the switch statement to handle it.
1022 fprintf(stderr, "unknown option \"-%c\"\n", optchar);
1023 exit(1);
1024 }
1025 }
1026
David Reiss65e62d32010-10-06 17:10:35 +00001027 if (!have_seed) {
1028 // choose a seed now if the user didn't specify one
Christian Lavoie4f42ef72010-11-04 18:51:42 +00001029 struct timeval tv;
1030 struct timezone tz;
1031 gettimeofday(&tv, &tz);
1032 options->seed = tv.tv_sec ^ tv.tv_usec;
David Reiss65e62d32010-10-06 17:10:35 +00001033 }
David Reiss35dc7692010-10-06 17:10:19 +00001034}
1035
1036boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
1037 // Parse arguments
David Reiss65e62d32010-10-06 17:10:35 +00001038 Options options;
1039 parse_args(argc, argv, &options);
1040
1041 initrand(options.seed);
David Reiss35dc7692010-10-06 17:10:19 +00001042
David Reiss109693c2010-10-06 17:10:42 +00001043 boost::unit_test::test_suite* suite =
1044 &boost::unit_test::framework::master_test_suite();
1045 suite->p_name.value = "TransportTest";
David Reiss65e62d32010-10-06 17:10:35 +00001046 TransportTestGen transport_test_generator(suite, options.sizeMultiplier);
David Reiss35dc7692010-10-06 17:10:19 +00001047 transport_test_generator.generate();
1048
David Reiss109693c2010-10-06 17:10:42 +00001049 return NULL;
David Reiss35dc7692010-10-06 17:10:19 +00001050}