2 //=============================================================================
4 * @file Message_Block_Large_Copy_Test.cpp
6 * This test program tests large Message Block duplication and cloning.
8 * @author Phillip LaBanca <labancap@ociweb.com>
10 //=============================================================================
13 #include "test_config.h"
14 #include "ace/Message_Block.h"
15 #include "ace/OS_NS_string.h"
18 run_duplicate_test (const size_t msg_block_count
,
20 const size_t msg_block_size
)
24 ACE_Message_Block
* mb_top
= new ACE_Message_Block ();
25 ACE_Message_Block
* mb
= mb_top
;
27 for (size_t j
= 0; j
!= msg_block_count
; ++j
)
29 ACE_Message_Block
* next
= new ACE_Message_Block (block
, msg_block_size
);
30 next
->wr_ptr (msg_block_size
);
35 ACE_Message_Block
* mb_test
= mb_top
->duplicate ();
38 rc
= mb_test
->total_size();
40 ACE_TEXT ("(%P|%t) %u top reference_count ()\n"),
41 mb_top
->reference_count ()));
43 ACE_TEXT ("(%P|%t) duplicated: %@ %d %d\n"),
45 mb_test
->total_size(),
46 mb_test
->total_length()));
51 ACE_TEXT ("(%P|%t) %u top reference_count ()\n"),
52 mb_top
->reference_count ()));
59 run_clone_test (const size_t msg_block_count
,
61 const size_t msg_block_size
)
65 ACE_Message_Block
* mb_top
= new ACE_Message_Block ();
66 ACE_Message_Block
* mb
= mb_top
;
68 for (size_t j
= 0; j
!= msg_block_count
; ++j
)
70 ACE_Message_Block
* next
= new ACE_Message_Block (block
, msg_block_size
);
71 next
->wr_ptr (msg_block_size
);
76 ACE_Message_Block
* mb_test
= mb_top
->clone ();
79 rc
= mb_test
->total_size();
81 ACE_TEXT ("(%P|%t) %u top reference_count ()\n"),
82 mb_top
->reference_count ()));
84 ACE_TEXT ("(%P|%t) cloned: %@ %d %d\n"),
86 mb_test
->total_size(),
87 mb_test
->total_length()));
92 ACE_TEXT ("(%P|%t) %u top reference_count ()\n"),
93 mb_top
->reference_count ()));
100 run_main (int , ACE_TCHAR
*[])
104 ACE_START_TEST (ACE_TEXT ("Message_Block_Large_Copy_Test"));
106 // Message_Block size() and Length() of 24,000,000
107 const size_t MSG_BLOCK_COUNT
= 8000;
108 const size_t MSG_BLOCK_SIZE
= 3000;
109 const size_t MSG_BLOCK_TOTAL
= MSG_BLOCK_COUNT
* MSG_BLOCK_SIZE
;
111 ACE_ERROR ((LM_DEBUG
,
112 ACE_TEXT ("(%P|%t) %u blocks %u bytes each, total %u\n"),
117 char block
[MSG_BLOCK_SIZE
];
118 ACE_OS::memset (block
, 'A', MSG_BLOCK_SIZE
);
120 size_t duplicate_total
= run_duplicate_test (
124 if (duplicate_total
!= MSG_BLOCK_TOTAL
)
126 ACE_ERROR ((LM_ERROR
,
127 ACE_TEXT ("(%P|%t) duplicate(): returned total of %u\n"),
132 size_t clone_total
= run_clone_test (
136 if (clone_total
!= MSG_BLOCK_TOTAL
)
138 ACE_ERROR ((LM_ERROR
,
139 ACE_TEXT ("(%P|%t) clone(): returned total of %u \n"),