FreeRDP
Loading...
Searching...
No Matches
TestStream.c
1#include <winpr/crt.h>
2#include <winpr/print.h>
3#include <winpr/crypto.h>
4#include <winpr/stream.h>
5
6static BOOL TestStream_Verify(wStream* s, size_t mincap, size_t len, size_t pos)
7{
8 if (Stream_Buffer(s) == nullptr)
9 {
10 printf("stream buffer is null\n");
11 return FALSE;
12 }
13
14 if (Stream_ConstPointer(s) == nullptr)
15 {
16 printf("stream pointer is null\n");
17 return FALSE;
18 }
19
20 if (Stream_PointerAs(s, BYTE) < Stream_Buffer(s))
21 {
22 printf("stream pointer (%p) or buffer (%p) is invalid\n", Stream_ConstPointer(s),
23 (void*)Stream_Buffer(s));
24 return FALSE;
25 }
26
27 if (Stream_Capacity(s) < mincap)
28 {
29 printf("stream capacity is %" PRIuz " but minimum expected value is %" PRIuz "\n",
30 Stream_Capacity(s), mincap);
31 return FALSE;
32 }
33
34 if (Stream_Length(s) != len)
35 {
36 printf("stream has unexpected length (%" PRIuz " instead of %" PRIuz ")\n",
37 Stream_Length(s), len);
38 return FALSE;
39 }
40
41 if (Stream_GetPosition(s) != pos)
42 {
43 printf("stream has unexpected position (%" PRIuz " instead of %" PRIuz ")\n",
44 Stream_GetPosition(s), pos);
45 return FALSE;
46 }
47
48 if (Stream_GetPosition(s) > Stream_Length(s))
49 {
50 printf("stream position (%" PRIuz ") exceeds length (%" PRIuz ")\n", Stream_GetPosition(s),
51 Stream_Length(s));
52 return FALSE;
53 }
54
55 if (Stream_GetPosition(s) > Stream_Capacity(s))
56 {
57 printf("stream position (%" PRIuz ") exceeds capacity (%" PRIuz ")\n",
58 Stream_GetPosition(s), Stream_Capacity(s));
59 return FALSE;
60 }
61
62 if (Stream_Length(s) > Stream_Capacity(s))
63 {
64 printf("stream length (%" PRIuz ") exceeds capacity (%" PRIuz ")\n", Stream_Length(s),
65 Stream_Capacity(s));
66 return FALSE;
67 }
68
69 if (Stream_GetRemainingLength(s) != len - pos)
70 {
71 printf("stream remaining length (%" PRIuz " instead of %" PRIuz ")\n",
72 Stream_GetRemainingLength(s), len - pos);
73 return FALSE;
74 }
75
76 return TRUE;
77}
78
79static BOOL TestStream_New(void)
80{
81 /* Test creation of a 0-size stream with no buffer */
82 wStream* s = Stream_New(nullptr, 0);
83
84 if (s)
85 return FALSE;
86 Stream_Free(s, TRUE);
87
88 return TRUE;
89}
90
91static BOOL TestStream_Static(void)
92{
93 BYTE buffer[20] = WINPR_C_ARRAY_INIT;
94 wStream staticStream = WINPR_C_ARRAY_INIT;
95 wStream* s = &staticStream;
96 UINT16 v = 0;
97 /* Test creation of a static stream */
98 Stream_StaticInit(s, buffer, sizeof(buffer));
99 Stream_Write_UINT16(s, 0xcab1);
100 Stream_ResetPosition(s);
101 Stream_Read_UINT16(s, v);
102
103 if (v != 0xcab1)
104 return FALSE;
105
106 Stream_ResetPosition(s);
107 Stream_Write_UINT16(s, 1);
108
109 if (!Stream_EnsureRemainingCapacity(s, 10)) /* we can ask for 10 bytes */
110 return FALSE;
111
112 /* 30 is bigger than the buffer, it will be reallocated on the heap */
113 if (!Stream_EnsureRemainingCapacity(s, 30) || !s->isOwner)
114 return FALSE;
115
116 Stream_Write_UINT16(s, 2);
117 Stream_ResetPosition(s);
118 Stream_Read_UINT16(s, v);
119
120 if (v != 1)
121 return FALSE;
122
123 Stream_Read_UINT16(s, v);
124
125 if (v != 2)
126 return FALSE;
127
128 // Intentional warning as the stream is not allocated.
129 // Still, Stream_Free should not release such memory, therefore this statement
130 // is required to test that.
131 WINPR_PRAGMA_DIAG_PUSH
132 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
133 Stream_Free(s, TRUE);
134 WINPR_PRAGMA_DIAG_POP
135 return TRUE;
136}
137
138static BOOL TestStream_Create(size_t count, BOOL selfAlloc)
139{
140 size_t len = 0;
141 size_t cap = 0;
142 wStream* s = nullptr;
143 void* buffer = nullptr;
144
145 for (size_t i = 0; i < count; i++)
146 {
147 len = cap = i + 1;
148
149 if (selfAlloc)
150 {
151 if (!(buffer = malloc(cap)))
152 {
153 printf("%s: failed to allocate buffer of size %" PRIuz "\n", __func__, cap);
154 goto fail;
155 }
156 }
157
158 if (!(s = Stream_New(selfAlloc ? buffer : nullptr, len)))
159 {
160 printf("%s: Stream_New failed for stream #%" PRIuz "\n", __func__, i);
161 goto fail;
162 }
163
164 if (!TestStream_Verify(s, cap, len, 0))
165 {
166 goto fail;
167 }
168
169 for (size_t pos = 0; pos < len; pos++)
170 {
171 if (!Stream_SetPosition(s, pos))
172 goto fail;
173 Stream_SealLength(s);
174
175 if (!TestStream_Verify(s, cap, pos, pos))
176 {
177 goto fail;
178 }
179 }
180
181 if (selfAlloc)
182 {
183 memset(buffer, (BYTE)(i % 256), cap);
184
185 if (memcmp(buffer, Stream_Buffer(s), cap) != 0)
186 {
187 printf("%s: buffer memory corruption\n", __func__);
188 goto fail;
189 }
190 }
191
192 Stream_Free(s, buffer == nullptr);
193 free(buffer);
194 }
195
196 return TRUE;
197fail:
198 free(buffer);
199
200 if (s)
201 {
202 Stream_Free(s, buffer == nullptr);
203 }
204
205 return FALSE;
206}
207
208static BOOL TestStream_Extent(UINT32 maxSize)
209{
210 wStream* s = nullptr;
211 BOOL result = FALSE;
212
213 if (!(s = Stream_New(nullptr, 1)))
214 {
215 printf("%s: Stream_New failed\n", __func__);
216 return FALSE;
217 }
218
219 for (UINT32 i = 1; i < maxSize; i++)
220 {
221 if (i % 2)
222 {
223 if (!Stream_EnsureRemainingCapacity(s, i))
224 goto fail;
225 }
226 else
227 {
228 if (!Stream_EnsureCapacity(s, i))
229 goto fail;
230 }
231
232 if (!Stream_SetPosition(s, i))
233 goto fail;
234 Stream_SealLength(s);
235
236 if (!TestStream_Verify(s, i, i, i))
237 {
238 printf("%s: failed to verify stream in iteration %" PRIu32 "\n", __func__, i);
239 goto fail;
240 }
241 }
242
243 result = TRUE;
244fail:
245
246 if (s)
247 {
248 Stream_Free(s, TRUE);
249 }
250
251 return result;
252}
253
254#define Stream_Peek_UINT8_BE Stream_Peek_UINT8
255#define Stream_Read_UINT8_BE Stream_Read_UINT8
256#define Stream_Peek_Get_UINT8_BE Stream_Peek_Get_UINT8
257#define Stream_Get_UINT8_BE Stream_Get_UINT8
258#define Stream_Peek_INT8_BE Stream_Peek_INT8
259#define Stream_Peek_Get_INT8_BE Stream_Peek_Get_INT8
260#define Stream_Read_INT8_BE Stream_Read_INT8
261#define Stream_Get_INT8_BE Stream_Get_INT8
262
263#define TestStream_PeekAndRead(_s, _r, _t) \
264 do \
265 { \
266 _t _a = 0; \
267 _t _b = 0; \
268 BYTE* _p = Stream_Buffer(_s); \
269 Stream_ResetPosition(_s); \
270 Stream_Peek_##_t(_s, _a); \
271 Stream_Read_##_t(_s, _b); \
272 if (_a != _b) \
273 { \
274 printf("%s: test1 " #_t "_LE failed\n", __func__); \
275 (_r) = FALSE; \
276 } \
277 Stream_Rewind(_s, sizeof(_t)); \
278 const _t _d = Stream_Peek_Get_##_t(_s); \
279 const _t _c = Stream_Get_##_t(_s); \
280 if (_c != _d) \
281 { \
282 printf("%s: test1 " #_t "_LE failed\n", __func__); \
283 (_r) = FALSE; \
284 } \
285 for (size_t _i = 0; _i < sizeof(_t); _i++) \
286 { \
287 if (((_a >> (_i * 8)) & 0xFF) != _p[_i]) \
288 { \
289 printf("%s: test2 " #_t "_LE failed\n", __func__); \
290 (_r) = FALSE; \
291 break; \
292 } \
293 } \
294 /* printf("a: 0x%016llX\n", a); */ \
295 Stream_ResetPosition(_s); \
296 Stream_Peek_##_t##_BE(_s, _a); \
297 Stream_Read_##_t##_BE(_s, _b); \
298 if (_a != _b) \
299 { \
300 printf("%s: test1 " #_t "_BE failed\n", __func__); \
301 (_r) = FALSE; \
302 } \
303 Stream_Rewind(_s, sizeof(_t)); \
304 const _t _e = Stream_Peek_Get_##_t##_BE(_s); \
305 const _t _f = Stream_Get_##_t##_BE(_s); \
306 if (_e != _f) \
307 { \
308 printf("%s: test1 " #_t "_BE failed\n", __func__); \
309 (_r) = FALSE; \
310 } \
311 for (size_t _i = 0; _i < sizeof(_t); _i++) \
312 { \
313 if (((_a >> (_i * 8)) & 0xFF) != _p[sizeof(_t) - _i - 1]) \
314 { \
315 printf("%s: test2 " #_t "_BE failed\n", __func__); \
316 (_r) = FALSE; \
317 break; \
318 } \
319 } \
320 /* printf("a: 0x%016llX\n", a); */ \
321 } while (0)
322
323static BOOL TestStream_WriteAndRead(UINT64 value)
324{
325 union
326 {
327 UINT8 u8;
328 UINT16 u16;
329 UINT32 u32;
330 UINT64 u64;
331 INT8 i8;
332 INT16 i16;
333 INT32 i32;
334 INT64 i64;
335 } val;
336 val.u64 = value;
337
338 wStream* s = Stream_New(nullptr, 1024);
339 if (!s)
340 return FALSE;
341 BOOL rc = FALSE;
342
343 {
344 Stream_Write_UINT8(s, val.u8);
345 Stream_Rewind_UINT8(s);
346 const UINT8 ru8 = Stream_Get_UINT8(s);
347 Stream_Rewind_UINT8(s);
348 if (val.u8 != ru8)
349 goto fail;
350 }
351 {
352 Stream_Write_UINT16(s, val.u16);
353 Stream_Rewind_UINT16(s);
354 const UINT16 ru = Stream_Get_UINT16(s);
355 Stream_Rewind_UINT16(s);
356 if (val.u16 != ru)
357 goto fail;
358 }
359 {
360 Stream_Write_UINT16_BE(s, val.u16);
361 Stream_Rewind_UINT16(s);
362 const UINT16 ru = Stream_Get_UINT16_BE(s);
363 Stream_Rewind_UINT16(s);
364 if (val.u16 != ru)
365 goto fail;
366 }
367 {
368 Stream_Write_UINT32(s, val.u32);
369 Stream_Rewind_UINT32(s);
370 const UINT32 ru = Stream_Get_UINT32(s);
371 Stream_Rewind_UINT32(s);
372 if (val.u32 != ru)
373 goto fail;
374 }
375 {
376 Stream_Write_UINT32_BE(s, val.u32);
377 Stream_Rewind_UINT32(s);
378 const UINT32 ru = Stream_Get_UINT32_BE(s);
379 Stream_Rewind_UINT32(s);
380 if (val.u32 != ru)
381 goto fail;
382 }
383 {
384 Stream_Write_UINT64(s, val.u64);
385 Stream_Rewind_UINT64(s);
386 const UINT64 ru = Stream_Get_UINT64(s);
387 Stream_Rewind_UINT64(s);
388 if (val.u64 != ru)
389 goto fail;
390 }
391 {
392 Stream_Write_UINT64_BE(s, val.u64);
393 Stream_Rewind_UINT64(s);
394 const UINT64 ru = Stream_Get_UINT64_BE(s);
395 Stream_Rewind_UINT64(s);
396 if (val.u64 != ru)
397 goto fail;
398 }
399 {
400 Stream_Write_INT8(s, val.i8);
401 Stream_Rewind(s, 1);
402 const INT8 ru8 = Stream_Get_INT8(s);
403 Stream_Rewind(s, 1);
404 if (val.i8 != ru8)
405 goto fail;
406 }
407 {
408 Stream_Write_INT16(s, val.i16);
409 Stream_Rewind(s, 2);
410 const INT16 ru = Stream_Get_INT16(s);
411 Stream_Rewind(s, 2);
412 if (val.i16 != ru)
413 goto fail;
414 }
415 {
416 Stream_Write_INT16_BE(s, val.i16);
417 Stream_Rewind(s, 2);
418 const INT16 ru = Stream_Get_INT16_BE(s);
419 Stream_Rewind(s, 2);
420 if (val.i16 != ru)
421 goto fail;
422 }
423 {
424 Stream_Write_INT32(s, val.i32);
425 Stream_Rewind(s, 4);
426 const INT32 ru = Stream_Get_INT32(s);
427 Stream_Rewind(s, 4);
428 if (val.i32 != ru)
429 goto fail;
430 }
431 {
432 Stream_Write_INT32_BE(s, val.i32);
433 Stream_Rewind(s, 4);
434 const INT32 ru = Stream_Get_INT32_BE(s);
435 Stream_Rewind(s, 4);
436 if (val.i32 != ru)
437 goto fail;
438 }
439 {
440 Stream_Write_INT64(s, val.i64);
441 Stream_Rewind(s, 8);
442 const INT64 ru = Stream_Get_INT64(s);
443 Stream_Rewind(s, 8);
444 if (val.i64 != ru)
445 goto fail;
446 }
447 {
448 Stream_Write_INT64_BE(s, val.i64);
449 Stream_Rewind(s, 8);
450 const INT64 ru = Stream_Get_INT64_BE(s);
451 Stream_Rewind(s, 8);
452 if (val.i64 != ru)
453 goto fail;
454 }
455
456 rc = TRUE;
457fail:
458 Stream_Free(s, TRUE);
459 return rc;
460}
461
462static BOOL TestStream_Reading(void)
463{
464 BYTE src[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
465 wStream* s = nullptr;
466 BOOL result = TRUE;
467
468 if (!(s = Stream_New(src, sizeof(src))))
469 {
470 printf("%s: Stream_New failed\n", __func__);
471 return FALSE;
472 }
473
474 TestStream_PeekAndRead(s, result, UINT8);
475 TestStream_PeekAndRead(s, result, INT8);
476 TestStream_PeekAndRead(s, result, UINT16);
477 TestStream_PeekAndRead(s, result, INT16);
478 TestStream_PeekAndRead(s, result, UINT32);
479 TestStream_PeekAndRead(s, result, INT32);
480 TestStream_PeekAndRead(s, result, UINT64);
481 TestStream_PeekAndRead(s, result, INT64);
482 Stream_Free(s, FALSE);
483 return result;
484}
485
486static BOOL TestStream_Write(void)
487{
488 BOOL rc = FALSE;
489 UINT8 u8 = 0;
490 UINT16 u16 = 0;
491 UINT32 u32 = 0;
492 UINT64 u64 = 0;
493 const BYTE data[] = "someteststreamdata";
494 wStream* s = Stream_New(nullptr, 100);
495
496 if (!s)
497 goto out;
498
499 if (s->pointer != s->buffer)
500 goto out;
501
502 Stream_Write(s, data, sizeof(data));
503
504 if (memcmp(Stream_Buffer(s), data, sizeof(data)) == 0)
505 rc = TRUE;
506
507 if (s->pointer != s->buffer + sizeof(data))
508 goto out;
509
510 Stream_ResetPosition(s);
511
512 if (s->pointer != s->buffer)
513 goto out;
514
515 Stream_Write_UINT8(s, 42);
516
517 if (s->pointer != s->buffer + 1)
518 goto out;
519
520 Stream_ResetPosition(s);
521
522 if (s->pointer != s->buffer)
523 goto out;
524
525 Stream_Peek_UINT8(s, u8);
526
527 if (u8 != 42)
528 goto out;
529
530 Stream_Write_UINT16(s, 0x1234);
531
532 if (s->pointer != s->buffer + 2)
533 goto out;
534
535 Stream_ResetPosition(s);
536
537 if (s->pointer != s->buffer)
538 goto out;
539
540 Stream_Peek_UINT16(s, u16);
541
542 if (u16 != 0x1234)
543 goto out;
544
545 Stream_Write_UINT32(s, 0x12345678UL);
546
547 if (s->pointer != s->buffer + 4)
548 goto out;
549
550 Stream_ResetPosition(s);
551
552 if (s->pointer != s->buffer)
553 goto out;
554
555 Stream_Peek_UINT32(s, u32);
556
557 if (u32 != 0x12345678UL)
558 goto out;
559
560 Stream_Write_UINT64(s, 0x1234567890ABCDEFULL);
561
562 if (s->pointer != s->buffer + 8)
563 goto out;
564
565 Stream_ResetPosition(s);
566
567 if (s->pointer != s->buffer)
568 goto out;
569
570 Stream_Peek_UINT64(s, u64);
571
572 if (u64 != 0x1234567890ABCDEFULL)
573 goto out;
574
575out:
576 Stream_Free(s, TRUE);
577 return rc;
578}
579
580static BOOL TestStream_Seek(void)
581{
582 BOOL rc = FALSE;
583 wStream* s = Stream_New(nullptr, 100);
584
585 if (!s)
586 goto out;
587
588 if (s->pointer != s->buffer)
589 goto out;
590
591 Stream_Seek(s, 5);
592
593 if (s->pointer != s->buffer + 5)
594 goto out;
595
596 Stream_Seek_UINT8(s);
597
598 if (s->pointer != s->buffer + 6)
599 goto out;
600
601 Stream_Seek_UINT16(s);
602
603 if (s->pointer != s->buffer + 8)
604 goto out;
605
606 Stream_Seek_UINT32(s);
607
608 if (s->pointer != s->buffer + 12)
609 goto out;
610
611 Stream_Seek_UINT64(s);
612
613 if (s->pointer != s->buffer + 20)
614 goto out;
615
616 rc = TRUE;
617out:
618 Stream_Free(s, TRUE);
619 return rc;
620}
621
622static BOOL TestStream_Rewind(void)
623{
624 BOOL rc = FALSE;
625 wStream* s = Stream_New(nullptr, 100);
626
627 if (!s)
628 goto out;
629
630 if (s->pointer != s->buffer)
631 goto out;
632
633 Stream_Seek(s, 100);
634
635 if (s->pointer != s->buffer + 100)
636 goto out;
637
638 Stream_Rewind(s, 10);
639
640 if (s->pointer != s->buffer + 90)
641 goto out;
642
643 Stream_Rewind_UINT8(s);
644
645 if (s->pointer != s->buffer + 89)
646 goto out;
647
648 Stream_Rewind_UINT16(s);
649
650 if (s->pointer != s->buffer + 87)
651 goto out;
652
653 Stream_Rewind_UINT32(s);
654
655 if (s->pointer != s->buffer + 83)
656 goto out;
657
658 Stream_Rewind_UINT64(s);
659
660 if (s->pointer != s->buffer + 75)
661 goto out;
662
663 rc = TRUE;
664out:
665 Stream_Free(s, TRUE);
666 return rc;
667}
668
669static BOOL TestStream_Zero(void)
670{
671 BOOL rc = FALSE;
672 const BYTE data[] = "someteststreamdata";
673 wStream* s = Stream_New(nullptr, sizeof(data));
674
675 if (!s)
676 goto out;
677
678 Stream_Write(s, data, sizeof(data));
679
680 if (memcmp(Stream_Buffer(s), data, sizeof(data)) != 0)
681 goto out;
682
683 Stream_ResetPosition(s);
684
685 if (s->pointer != s->buffer)
686 goto out;
687
688 Stream_Zero(s, 5);
689
690 if (s->pointer != s->buffer + 5)
691 goto out;
692
693 if (memcmp(Stream_ConstPointer(s), data + 5, sizeof(data) - 5) != 0)
694 goto out;
695
696 Stream_ResetPosition(s);
697
698 if (s->pointer != s->buffer)
699 goto out;
700
701 for (UINT32 x = 0; x < 5; x++)
702 {
703 UINT8 val = 0;
704 Stream_Read_UINT8(s, val);
705
706 if (val != 0)
707 goto out;
708 }
709
710 rc = TRUE;
711out:
712 Stream_Free(s, TRUE);
713 return rc;
714}
715
716static BOOL TestStream_Fill(void)
717{
718 BOOL rc = FALSE;
719 const BYTE fill[7] = "XXXXXXX";
720 const BYTE data[] = "someteststreamdata";
721 wStream* s = Stream_New(nullptr, sizeof(data));
722
723 if (!s)
724 goto out;
725
726 Stream_Write(s, data, sizeof(data));
727
728 if (memcmp(Stream_Buffer(s), data, sizeof(data)) != 0)
729 goto out;
730
731 Stream_ResetPosition(s);
732
733 if (s->pointer != s->buffer)
734 goto out;
735
736 Stream_Fill(s, fill[0], sizeof(fill));
737
738 if (s->pointer != s->buffer + sizeof(fill))
739 goto out;
740
741 if (memcmp(Stream_ConstPointer(s), data + sizeof(fill), sizeof(data) - sizeof(fill)) != 0)
742 goto out;
743
744 Stream_ResetPosition(s);
745
746 if (s->pointer != s->buffer)
747 goto out;
748
749 if (memcmp(Stream_ConstPointer(s), fill, sizeof(fill)) != 0)
750 goto out;
751
752 rc = TRUE;
753out:
754 Stream_Free(s, TRUE);
755 return rc;
756}
757
758static BOOL TestStream_Copy(void)
759{
760 BOOL rc = FALSE;
761 const BYTE data[] = "someteststreamdata";
762 wStream* s = Stream_New(nullptr, sizeof(data));
763 wStream* d = Stream_New(nullptr, sizeof(data));
764
765 if (!s || !d)
766 goto out;
767
768 if (s->pointer != s->buffer)
769 goto out;
770
771 Stream_Write(s, data, sizeof(data));
772
773 if (memcmp(Stream_Buffer(s), data, sizeof(data)) != 0)
774 goto out;
775
776 if (s->pointer != s->buffer + sizeof(data))
777 goto out;
778
779 Stream_ResetPosition(s);
780
781 if (s->pointer != s->buffer)
782 goto out;
783
784 Stream_Copy(s, d, sizeof(data));
785
786 if (s->pointer != s->buffer + sizeof(data))
787 goto out;
788
789 if (d->pointer != d->buffer + sizeof(data))
790 goto out;
791
792 if (Stream_GetPosition(s) != Stream_GetPosition(d))
793 goto out;
794
795 if (memcmp(Stream_Buffer(s), data, sizeof(data)) != 0)
796 goto out;
797
798 if (memcmp(Stream_Buffer(d), data, sizeof(data)) != 0)
799 goto out;
800
801 rc = TRUE;
802out:
803 Stream_Free(s, TRUE);
804 Stream_Free(d, TRUE);
805 return rc;
806}
807
808int TestStream(int argc, char* argv[])
809{
810 WINPR_UNUSED(argc);
811 WINPR_UNUSED(argv);
812
813 if (!TestStream_Create(200, FALSE))
814 return 1;
815
816 if (!TestStream_Create(200, TRUE))
817 return 2;
818
819 if (!TestStream_Extent(4096))
820 return 3;
821
822 if (!TestStream_Reading())
823 return 4;
824
825 if (!TestStream_New())
826 return 5;
827
828 if (!TestStream_Write())
829 return 6;
830
831 if (!TestStream_Seek())
832 return 7;
833
834 if (!TestStream_Rewind())
835 return 8;
836
837 if (!TestStream_Zero())
838 return 9;
839
840 if (!TestStream_Fill())
841 return 10;
842
843 if (!TestStream_Copy())
844 return 11;
845
846 if (!TestStream_Static())
847 return 12;
848
849 if (!TestStream_WriteAndRead(0x1234567890abcdef))
850 return 13;
851
852 for (size_t x = 0; x < 10; x++)
853 {
854 UINT64 val = 0;
855 if (winpr_RAND(&val, sizeof(val)) < 0)
856 return -1;
857 if (!TestStream_WriteAndRead(val))
858 return 14;
859 }
860 return 0;
861}