This repository was archived by the owner on May 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmbuf_tests.cpp
More file actions
552 lines (465 loc) · 19.1 KB
/
Copy pathmbuf_tests.cpp
File metadata and controls
552 lines (465 loc) · 19.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
// Copyright 2018 The Fuchsia Authors
//
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT
#include <object/mbuf.h>
#include <fbl/array.h>
#include <ktl/unique_ptr.h>
#include <lib/unittest/unittest.h>
#include <lib/unittest/user_memory.h>
namespace {
using testing::UserMemory;
enum class MessageType {
kStream,
kDatagram
};
enum class ReadType {
kRead,
kPeek
};
// Writes a null-terminated string into |chain|.
//
// Helps eliminate some of the boilerplate code dealing with copying in and
// out of user memory to make the test logic more obvious.
//
// The null terminator on |str| is not copied into |chain|, it's just used
// so that we can easily determine the length without requiring the caller
// to pass it in separately.
//
// Returns false if a user memory operation fails or |chain| failed to write
// the whole |str|.
bool WriteHelper(MBufChain* chain, const char* str, MessageType message_type) {
BEGIN_TEST;
const size_t length = strlen(str);
ktl::unique_ptr<UserMemory> memory = UserMemory::Create(length);
ASSERT_NE(nullptr, memory.get(), "");
ASSERT_EQ(ZX_OK, make_user_out_ptr(memory->out()).copy_array_to_user(str, length), "");
auto user_in = make_user_in_ptr(memory->in());
size_t written = 0;
if (message_type == MessageType::kDatagram) {
ASSERT_EQ(ZX_OK, chain->WriteDatagram(user_in, length, &written), "");
} else {
ASSERT_EQ(ZX_OK, chain->WriteStream(user_in, length, &written), "");
}
ASSERT_EQ(length, written, "");
END_TEST;
}
// Reads or peeks data from |chain|.
//
// Returns nullptr on memory failure.
fbl::Array<char> ReadHelper(MBufChain* chain, size_t length, MessageType message_type,
ReadType read_type) {
// It's an error to create UserMemory of size 0, so bump this to 1 even if we
// don't intend to use it.
ktl::unique_ptr<UserMemory> memory = UserMemory::Create(length ? length : 1);
if (!memory) {
unittest_printf("Failed to allocate UserMemory\n");
return nullptr;
}
auto user_out = make_user_out_ptr(memory->out());
bool datagram = (message_type == MessageType::kDatagram);
size_t result =
(read_type == ReadType::kRead) ? chain->Read(user_out, length, datagram)
: chain->Peek(user_out, length, datagram);
fbl::AllocChecker ac;
fbl::Array<char> buffer(new (&ac) char[result], result);
if (!ac.check()) {
unittest_printf("Failed to allocate char buffer\n");
return nullptr;
}
if (make_user_in_ptr(memory->in()).copy_array_from_user(buffer.get(), result) != ZX_OK) {
unittest_printf("Failed to copy user memory bytes\n");
return nullptr;
}
return buffer;
}
// Checks that the contents of |buffer| match the null-terminated |str|.
//
// fbl::Array<char> isn't supported by EXPECT_EQ() due to printf() usage so
// this allows us to write EXPECT_TRUE(Equal(...)) instead.
//
// Returns false if either the size or contents differ.
bool Equal(const fbl::Array<char>& buffer, const char* str) {
const size_t length = strlen(str);
return buffer.size() == length && memcmp(buffer.get(), str, length) == 0;
}
static bool initial_state() {
BEGIN_TEST;
MBufChain chain;
EXPECT_TRUE(chain.is_empty(), "");
EXPECT_FALSE(chain.is_full(), "");
EXPECT_EQ(0U, chain.size(), "");
END_TEST;
}
// Tests reading a stream when the chain is empty.
static bool stream_read_empty() {
BEGIN_TEST;
ktl::unique_ptr<UserMemory> mem = UserMemory::Create(1);
auto mem_out = make_user_out_ptr(mem->out());
MBufChain chain;
EXPECT_EQ(0U, chain.Read(mem_out, 1, false), "");
END_TEST;
}
// Tests reading a stream with a zero-length buffer.
static bool stream_read_zero() {
BEGIN_TEST;
ktl::unique_ptr<UserMemory> mem = UserMemory::Create(1);
auto mem_in = make_user_in_ptr(mem->in());
auto mem_out = make_user_out_ptr(mem->out());
MBufChain chain;
size_t written = 7;
ASSERT_EQ(ZX_OK, chain.WriteStream(mem_in, 1, &written), "");
ASSERT_EQ(1U, written, "");
EXPECT_EQ(0U, chain.Read(mem_out, 0, false), "");
END_TEST;
}
// Tests basic WriteStream/Read functionality.
static bool stream_write_basic() {
BEGIN_TEST;
constexpr size_t kWriteLen = 1024;
constexpr int kNumWrites = 5;
ktl::unique_ptr<UserMemory> mem = UserMemory::Create(kWriteLen);
auto mem_in = make_user_in_ptr(mem->in());
auto mem_out = make_user_out_ptr(mem->out());
size_t written = 0;
MBufChain chain;
// Call write several times with different buffer contents.
for (int i = 0; i < kNumWrites; ++i) {
char buf[kWriteLen] = {0};
memset(buf, 'A' + i, kWriteLen);
ASSERT_EQ(ZX_OK, mem_out.copy_array_to_user(buf, kWriteLen), "");
ASSERT_EQ(ZX_OK, chain.WriteStream(mem_in, kWriteLen, &written), "");
ASSERT_EQ(kWriteLen, written, "");
EXPECT_FALSE(chain.is_empty(), "");
EXPECT_FALSE(chain.is_full(), "");
EXPECT_EQ((i + 1) * kWriteLen, chain.size(), "");
}
// Read it all back in one call.
constexpr size_t kTotalLen = kWriteLen * kNumWrites;
ASSERT_EQ(kTotalLen, chain.size(), "");
ktl::unique_ptr<UserMemory> read_buf = UserMemory::Create(kTotalLen);
auto read_buf_in = make_user_in_ptr(read_buf->in());
auto read_buf_out = make_user_out_ptr(read_buf->out());
size_t result = chain.Read(read_buf_out, kTotalLen, false);
ASSERT_EQ(kTotalLen, result, "");
EXPECT_TRUE(chain.is_empty(), "");
EXPECT_FALSE(chain.is_full(), "");
EXPECT_EQ(0U, chain.size(), "");
// Verify result.
fbl::AllocChecker ac;
auto expected_buf = ktl::unique_ptr<char[]>(new (&ac) char[kTotalLen]);
ASSERT_TRUE(ac.check(), "");
for (int i = 0; i < kNumWrites; ++i) {
memset(static_cast<void*>(expected_buf.get() + i * kWriteLen), 'A' + i, kWriteLen);
}
auto actual_buf = ktl::unique_ptr<char[]>(new (&ac) char[kTotalLen]);
ASSERT_TRUE(ac.check(), "");
ASSERT_EQ(ZX_OK, read_buf_in.copy_array_from_user(actual_buf.get(), kTotalLen), "");
EXPECT_EQ(0, memcmp(static_cast<void*>(expected_buf.get()),
static_cast<void*>(actual_buf.get()), kTotalLen), "");
END_TEST;
}
// Tests writing a stream with a zero-length buffer.
static bool stream_write_zero() {
BEGIN_TEST;
ktl::unique_ptr<UserMemory> mem = UserMemory::Create(1);
auto mem_in = make_user_in_ptr(mem->in());
size_t written = 7;
MBufChain chain;
// TODO(maniscalco): Is ZX_ERR_SHOULD_WAIT really the right error here in this case?
EXPECT_EQ(ZX_ERR_SHOULD_WAIT, chain.WriteStream(mem_in, 0, &written), "");
EXPECT_EQ(7U, written, "");
EXPECT_TRUE(chain.is_empty(), "");
EXPECT_FALSE(chain.is_full(), "");
EXPECT_EQ(0U, chain.size(), "");
END_TEST;
}
// Tests writing a stream to the chain until it stops accepting writes.
static bool stream_write_too_much() {
BEGIN_TEST;
constexpr size_t kWriteLen = 65536;
ktl::unique_ptr<UserMemory> mem = UserMemory::Create(kWriteLen);
auto mem_in = make_user_in_ptr(mem->in());
auto mem_out = make_user_out_ptr(mem->out());
size_t written = 0;
MBufChain chain;
size_t total_written = 0;
// Fill the chain until it refuses to take any more.
while (!chain.is_full() && chain.WriteStream(mem_in, kWriteLen, &written) == ZX_OK) {
total_written += written;
}
ASSERT_FALSE(chain.is_empty(), "");
ASSERT_TRUE(chain.is_full(), "");
EXPECT_EQ(total_written, chain.size(), "");
// Read it all back out and see we get back the same number of bytes we wrote.
size_t total_read = 0;
size_t bytes_read = 0;
while (!chain.is_empty() && (bytes_read = chain.Read(mem_out, kWriteLen, false)) > 0) {
total_read += bytes_read;
}
EXPECT_TRUE(chain.is_empty(), "");
EXPECT_EQ(0U, chain.size(), "");
EXPECT_EQ(total_written, total_read, "");
END_TEST;
}
static bool stream_peek() {
BEGIN_TEST;
MBufChain chain;
ASSERT_TRUE(WriteHelper(&chain, "abc", MessageType::kStream), "");
ASSERT_TRUE(WriteHelper(&chain, "123", MessageType::kStream), "");
EXPECT_TRUE(Equal(ReadHelper(&chain, 1, MessageType::kStream, ReadType::kPeek), "a"), "");
EXPECT_TRUE(Equal(ReadHelper(&chain, 3, MessageType::kStream, ReadType::kPeek), "abc"), "");
EXPECT_TRUE(Equal(ReadHelper(&chain, 4, MessageType::kStream, ReadType::kPeek), "abc1"), "");
EXPECT_TRUE(Equal(ReadHelper(&chain, 6, MessageType::kStream, ReadType::kPeek), "abc123"), "");
// Make sure peeking didn't affect an actual read.
EXPECT_EQ(6u, chain.size(), "");
EXPECT_TRUE(Equal(ReadHelper(&chain, 6, MessageType::kStream, ReadType::kRead), "abc123"), "");
END_TEST;
}
static bool stream_peek_empty() {
BEGIN_TEST;
MBufChain chain;
EXPECT_TRUE(Equal(ReadHelper(&chain, 1, MessageType::kStream, ReadType::kPeek), ""), "");
END_TEST;
}
static bool stream_peek_zero() {
BEGIN_TEST;
MBufChain chain;
ASSERT_TRUE(WriteHelper(&chain, "a", MessageType::kStream), "");
EXPECT_TRUE(Equal(ReadHelper(&chain, 0, MessageType::kStream, ReadType::kPeek), ""), "");
END_TEST;
}
// Ask for more data than exists, make sure it only returns the real data.
static bool stream_peek_underflow() {
BEGIN_TEST;
MBufChain chain;
ASSERT_TRUE(WriteHelper(&chain, "abc", MessageType::kStream), "");
EXPECT_TRUE(Equal(ReadHelper(&chain, 10, MessageType::kStream, ReadType::kPeek), "abc"), "");
ASSERT_TRUE(WriteHelper(&chain, "123", MessageType::kStream), "");
EXPECT_TRUE(Equal(ReadHelper(&chain, 10, MessageType::kStream, ReadType::kPeek), "abc123"), "");
END_TEST;
}
// Tests reading a datagram when chain is empty.
static bool datagram_read_empty() {
BEGIN_TEST;
ktl::unique_ptr<UserMemory> mem = UserMemory::Create(1);
auto mem_out = make_user_out_ptr(mem->out());
MBufChain chain;
EXPECT_EQ(0U, chain.Read(mem_out, 1, true), "");
EXPECT_TRUE(chain.is_empty(), "");
END_TEST;
}
// Tests reading a datagram with a zero-length buffer.
static bool datagram_read_zero() {
BEGIN_TEST;
ktl::unique_ptr<UserMemory> mem = UserMemory::Create(1);
auto mem_in = make_user_in_ptr(mem->in());
auto mem_out = make_user_out_ptr(mem->out());
MBufChain chain;
size_t written = 7;
ASSERT_EQ(ZX_OK, chain.WriteDatagram(mem_in, 1, &written), "");
ASSERT_EQ(1U, written, "");
EXPECT_EQ(0U, chain.Read(mem_out, 0, true), "");
EXPECT_FALSE(chain.is_empty(), "");
END_TEST;
}
// Tests reading a datagram into a buffer that's too small.
static bool datagram_read_buffer_too_small() {
BEGIN_TEST;
constexpr size_t kWriteLen = 32;
ktl::unique_ptr<UserMemory> mem = UserMemory::Create(kWriteLen);
auto mem_in = make_user_in_ptr(mem->in());
auto mem_out = make_user_out_ptr(mem->out());
size_t written = 0;
MBufChain chain;
// Write the 'A' datagram.
char buf[kWriteLen] = {0};
memset(buf, 'A', sizeof(buf));
ASSERT_EQ(ZX_OK, mem_out.copy_array_to_user(buf, sizeof(buf)), "");
ASSERT_EQ(ZX_OK, chain.WriteDatagram(mem_in, kWriteLen, &written), "");
ASSERT_EQ(kWriteLen, written, "");
EXPECT_EQ(kWriteLen, chain.size(), "");
ASSERT_FALSE(chain.is_empty(), "");
// Write the 'B' datagram.
memset(buf, 'B', sizeof(buf));
ASSERT_EQ(ZX_OK, mem_out.copy_array_to_user(buf, sizeof(buf)), "");
ASSERT_EQ(ZX_OK, chain.WriteDatagram(mem_in, kWriteLen, &written), "");
ASSERT_EQ(kWriteLen, written, "");
EXPECT_EQ(2 * kWriteLen, chain.size(), "");
ASSERT_FALSE(chain.is_empty(), "");
// Read back the first datagram, but with a buffer that's too small. See that we get back a
// truncated 'A' datagram.
memset(buf, 0, sizeof(buf));
ASSERT_EQ(ZX_OK, mem_out.copy_array_to_user(buf, sizeof(buf)), "");
EXPECT_EQ(1U, chain.Read(mem_out, 1, true), "");
EXPECT_FALSE(chain.is_empty(), "");
ASSERT_EQ(ZX_OK, mem_in.copy_array_from_user(buf, sizeof(buf)), "");
EXPECT_EQ('A', buf[0], "");
EXPECT_EQ(0, buf[1], "");
// Read the next one and see that it's 'B' implying the remainder of 'A' was discarded.
EXPECT_EQ(kWriteLen, chain.size(), "");
memset(buf, 0, kWriteLen);
ASSERT_EQ(ZX_OK, mem_out.copy_array_to_user(buf, sizeof(buf)), "");
EXPECT_EQ(kWriteLen, chain.Read(mem_out, kWriteLen, true), "");
EXPECT_TRUE(chain.is_empty(), "");
EXPECT_EQ(0U, chain.size(), "");
ASSERT_EQ(ZX_OK, mem_in.copy_array_from_user(buf, sizeof(buf)), "");
char expected_buf[kWriteLen] = {0};
memset(expected_buf, 'B', kWriteLen);
EXPECT_EQ(0, memcmp(expected_buf, buf, kWriteLen), "");
END_TEST;
}
// Tests basic WriteDatagram/Read functionality.
static bool datagram_write_basic() {
BEGIN_TEST;
constexpr int kNumDatagrams = 100;
constexpr size_t kMaxLength = kNumDatagrams;
size_t written = 0;
size_t total_written = 0;
ktl::unique_ptr<UserMemory> mem = UserMemory::Create(kMaxLength);
auto mem_in = make_user_in_ptr(mem->in());
auto mem_out = make_user_out_ptr(mem->out());
MBufChain chain;
// Write a series of datagrams with different sizes.
for (unsigned i = 1; i <= kNumDatagrams; ++i) {
char buf[kMaxLength] = {0};
memset(buf, i, i);
ASSERT_EQ(ZX_OK, mem_out.copy_array_to_user(buf, sizeof(buf)), "");
ASSERT_EQ(ZX_OK, chain.WriteDatagram(mem_in, i, &written), "");
ASSERT_EQ(i, written, "");
total_written += written;
EXPECT_FALSE(chain.is_empty(), "");
EXPECT_FALSE(chain.is_full(), "");
}
// Verify size() returns correctly
EXPECT_EQ(1U, chain.size(true), "");
EXPECT_EQ(total_written, chain.size(), "");
// Read them back and verify their contents.
for (unsigned i = 1; i <= kNumDatagrams; ++i) {
EXPECT_EQ(i, chain.size(true), "");
char expected_buf[kMaxLength] = {0};
memset(expected_buf, i, i);
size_t result = chain.Read(mem_out, i, true);
ASSERT_EQ(i, result, "");
char actual_buf[kMaxLength] = {0};
ASSERT_EQ(ZX_OK, mem_in.copy_array_from_user(actual_buf, sizeof(actual_buf)), "");
EXPECT_EQ(0, memcmp(expected_buf, actual_buf, i), "");
}
EXPECT_TRUE(chain.is_empty(), "");
EXPECT_EQ(0U, chain.size(), "");
END_TEST;
}
// Tests writing a zero-length datagram to the chain.
static bool datagram_write_zero() {
BEGIN_TEST;
ktl::unique_ptr<UserMemory> mem = UserMemory::Create(1);
auto mem_in = make_user_in_ptr(mem->in());
size_t written = 7;
MBufChain chain;
EXPECT_EQ(ZX_ERR_INVALID_ARGS, chain.WriteDatagram(mem_in, 0, &written), "");
EXPECT_EQ(7U, written, "");
EXPECT_TRUE(chain.is_empty(), "");
EXPECT_FALSE(chain.is_full(), "");
EXPECT_EQ(0U, chain.size(true), "");
EXPECT_EQ(0U, chain.size(), "");
END_TEST;
}
// Tests writing datagrams to the chain until it stops accepting writes.
static bool datagram_write_too_much() {
BEGIN_TEST;
constexpr size_t kWriteLen = 65536;
ktl::unique_ptr<UserMemory> mem = UserMemory::Create(kWriteLen);
auto mem_in = make_user_in_ptr(mem->in());
auto mem_out = make_user_out_ptr(mem->out());
size_t written = 0;
MBufChain chain;
int num_datagrams_written = 0;
// Fill the chain until it refuses to take any more.
while (!chain.is_full() && chain.WriteDatagram(mem_in, kWriteLen, &written) == ZX_OK) {
++num_datagrams_written;
ASSERT_EQ(kWriteLen, written, "");
}
ASSERT_FALSE(chain.is_empty(), "");
EXPECT_EQ(kWriteLen * num_datagrams_written, chain.size(), "");
// Read it all back out and see that there's none left over.
int num_datagrams_read = 0;
while (!chain.is_empty() && chain.Read(mem_out, kWriteLen, true) > 0) {
++num_datagrams_read;
}
EXPECT_TRUE(chain.is_empty(), "");
EXPECT_EQ(0U, chain.size(), "");
EXPECT_EQ(num_datagrams_written, num_datagrams_read, "");
END_TEST;
}
// Tests writing a datagram packet larger than the mbuf's capacity.
static bool datagram_write_huge_packet() {
BEGIN_TEST;
MBufChain chain;
const size_t kHugePacketSize = chain.max_size() + 1;
ktl::unique_ptr<UserMemory> mem = UserMemory::Create(kHugePacketSize);
auto mem_in = make_user_in_ptr(mem->in());
size_t written;
zx_status_t status = chain.WriteDatagram(mem_in, kHugePacketSize, &written);
ASSERT_EQ(status, ZX_ERR_OUT_OF_RANGE, "");
END_TEST;
}
static bool datagram_peek() {
BEGIN_TEST;
MBufChain chain;
ASSERT_TRUE(WriteHelper(&chain, "abc", MessageType::kDatagram), "");
EXPECT_TRUE(Equal(ReadHelper(&chain, 1, MessageType::kDatagram, ReadType::kPeek), "a"), "");
EXPECT_TRUE(Equal(ReadHelper(&chain, 3, MessageType::kDatagram, ReadType::kPeek), "abc"), "");
// Make sure peeking didn't affect an actual read.
EXPECT_EQ(3u, chain.size(), "");
EXPECT_TRUE(Equal(ReadHelper(&chain, 3, MessageType::kDatagram, ReadType::kRead), "abc"), "");
END_TEST;
}
static bool datagram_peek_empty() {
BEGIN_TEST;
MBufChain chain;
EXPECT_TRUE(Equal(ReadHelper(&chain, 1, MessageType::kDatagram, ReadType::kPeek), ""), "");
END_TEST;
}
static bool datagram_peek_zero() {
BEGIN_TEST;
MBufChain chain;
ASSERT_TRUE(WriteHelper(&chain, "a", MessageType::kDatagram), "");
EXPECT_TRUE(Equal(ReadHelper(&chain, 0, MessageType::kDatagram, ReadType::kPeek), ""), "");
END_TEST;
}
static bool datagram_peek_underflow() {
BEGIN_TEST;
MBufChain chain;
ASSERT_TRUE(WriteHelper(&chain, "abc", MessageType::kDatagram), "");
ASSERT_TRUE(WriteHelper(&chain, "123", MessageType::kDatagram), "");
// Datagram peeks should not return more than a single message.
EXPECT_TRUE(Equal(ReadHelper(&chain, 10, MessageType::kDatagram, ReadType::kPeek), "abc"), "");
EXPECT_TRUE(Equal(ReadHelper(&chain, 3, MessageType::kDatagram, ReadType::kRead), "abc"), "");
EXPECT_TRUE(Equal(ReadHelper(&chain, 10, MessageType::kDatagram, ReadType::kPeek), "123"), "");
END_TEST;
}
} // namespace
UNITTEST_START_TESTCASE(mbuf_tests)
UNITTEST("initial_state", initial_state)
UNITTEST("stream_read_empty", stream_read_empty)
UNITTEST("stream_read_zero", stream_read_zero)
UNITTEST("stream_write_basic", stream_write_basic)
UNITTEST("stream_write_zero", stream_write_zero)
UNITTEST("stream_write_too_much", stream_write_too_much)
UNITTEST("stream_peek", stream_peek)
UNITTEST("stream_peek_empty", stream_peek_empty)
UNITTEST("stream_peek_zero", stream_peek_zero)
UNITTEST("stream_peek_underflow", stream_peek_underflow)
UNITTEST("datagram_read_empty", datagram_read_empty)
UNITTEST("datagram_read_zero", datagram_read_zero)
UNITTEST("datagram_read_buffer_too_small", datagram_read_buffer_too_small)
UNITTEST("datagram_write_basic", datagram_write_basic)
UNITTEST("datagram_write_zero", datagram_write_zero)
UNITTEST("datagram_write_too_much", datagram_write_too_much)
UNITTEST("datagram_write_huge_packet", datagram_write_huge_packet)
UNITTEST("datagram_peek", datagram_peek)
UNITTEST("datagram_peek_empty", datagram_peek_empty)
UNITTEST("datagram_peek_zero", datagram_peek_zero)
UNITTEST("datagram_peek_underflow", datagram_peek_underflow)
UNITTEST_END_TESTCASE(mbuf_tests, "mbuf", "MBuf test");