Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / ACE / tests / Dynamic_Priority_Test.cpp
blob136e29f0e44c97c3046c066e8dc551f044e3acf4
2 //=============================================================================
3 /**
4 * @file Dynamic_Priority_Test.cpp (based on Priority_Buffer_Test.cpp)
6 * This is a test to verify and illustrate the static and dynamic
7 * priority mechanisms of the <ACE_Message_Queue> class and the
8 * <ACE_Dynamic_Message_Queue> class. As in the
9 * <Priority_Buffer_Test>, a producer generates messages and
10 * enqueues them, and a consumer dequeues them and checks their
11 * ordering.
13 * In these tests, every effort is made to ensure that there is
14 * plenty of time for the messages to be enqueued and dequeued,
15 * with messages that *should* meet their deadlines actually
16 * meeting them, while messages that should miss their deadlines
17 * are delayed so that they actually miss them. It is, however,
18 * remotely possible that this test could yield a false negative:
19 * the dynamic queues could work correctly but due to timing
20 * variations the test could indicate failure.
22 * Three message queues are obtained from the message queue
23 * factory, one static, two dynamic (one deadline based, and one
24 * laxity based) and the same supplier behavior is used each time:
25 * the messages are preallocated and their static information
26 * valued, the current time is obtained and deadlines are set, with
27 * half of the messages given late deadlines, and the other half of
28 * the messages given reachable deadlines. The producer then
29 * immediately enqueues all messages.
31 * Two separate tests are run, one which verifies messages are
32 * correctly ordered my the given queues, and one which generates
33 * performance numbers for the various queues under increasing
34 * numbers of messages. In the first test, the consumer is passed
35 * the filled queue and a string with the expected order in which
36 * the messages should dequeue. In the second test, measurements
37 * are made as non-intrusive as possible, with no ordering checks.
39 * @author Chris Gill <cdgill@cs.wustl.edu>
41 //=============================================================================
44 #include "test_config.h" /* Include first to enable ACE_TEST_ASSERT. */
45 #include "ace/Message_Queue.h"
46 #include "ace/Thread_Manager.h"
47 #include "ace/High_Res_Timer.h"
48 #include "ace/Sched_Params.h"
50 #if defined (VXWORKS)
51 # include "ace/OS_NS_string.h"
52 #endif /* VXWORKS */
56 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
57 enum Test_Type {BEST, WORST, RANDOM};
59 /**
60 * @class ArgStruct
62 * @brief Structure used to pass arguments to test functions.
64 class ArgStruct
66 public:
68 /// message queue to test
69 ACE_Message_Queue<ACE_SYNCH> *queue_;
71 /// string of characters to indicate message order
72 const char *order_string_;
74 /// array of message blocks to use
75 ACE_Message_Block **array_;
77 /// expected message count
78 u_int expected_count_;
81 // Order in which messages are sent.
82 static const char send_order [] = "abcdefghijklmnop";
84 // Order in which messages are received with "FIFO prioritization"
85 // (i.e., none)
86 // Unused: static const char FIFO_receipt_order [] = "abcdefghijklmnop";
88 // Order in which messages are received with static prioritization.
89 static const char static_receipt_order [] = "ponmlkjihgfedcba";
91 // Order in which messages are received with deadline prioritization.
92 static const char deadline_receipt_order [] = "hgfedcbaponmlkji";
94 // Order in which messages are received with laxity prioritization.
95 static const char laxity_receipt_order [] = "hfgedbcapnomljki";
97 // Fast and slow execution time values (sec, usec), kept very small to
98 // allow comparison of deadline, laxity, and static strategies across
99 // a very wide range of message counts.
100 static const ACE_Time_Value fast_execution (0, 1);
101 static const ACE_Time_Value slow_execution (0, 2);
103 // Make the queue be capable of being *very* large.
104 static const long max_queue = LONG_MAX;
106 #if defined (VXWORKS)
107 // VxWorks Message Queue parameters.
108 const int vx_max_queue = INT_MAX;
109 const int vx_msg_size = 32;
110 #endif /* defined (VXWORKS) */
112 // Loading parameters (number of messages to push through queues) for
113 // performance tests.
114 static int MIN_LOAD = 20;
115 static int MAX_LOAD = 1000;
116 static int LOAD_STEP = 20;
118 // Time offsets for a minute in the past (for the best case test) and
119 // two seconds in the future (for the worst case and randomized
120 // tests).
121 static const ACE_Time_Value far_past_offset (-60, 0);
122 static const ACE_Time_Value near_future_offset (2, 0);
123 static const ACE_Time_Value offset_step (0, 5);
125 // The order consumer dequeues a message from the passed
126 // Message_Queue, and checks its data character against the passed
127 // string of characters which has the expected ordering. Suppliers
128 // and consumers do not allocate or deallocate messages, to avoid
129 // timing delays and timing jitter in the test: the main function is
130 // responsible for all initialization allocation and cleanup before,
131 // between, and after (but not during) the transfer of messages from a
132 // supplier to the corresponding consumer.
134 static void *
135 order_consumer (void *args)
137 ACE_TEST_ASSERT (args != 0);
139 ACE_Message_Queue<ACE_SYNCH> *msg_queue =
140 static_cast<ArgStruct *> (args)->queue_;
141 const char *receipt_order =
142 static_cast<ArgStruct *> (args)->order_string_;
143 u_int expected_count =
144 static_cast<ArgStruct *> (args)->expected_count_;
146 ACE_TEST_ASSERT (receipt_order != 0);
147 ACE_TEST_ASSERT (msg_queue != 0);
149 u_int local_count = 0;
151 // Keep looping, reading a message out of the queue, until we reach
152 // the end of the receipt order string, which signals us to quit.
154 for (const char *expected = receipt_order;
155 *expected != '\0';
156 ++expected)
158 ACE_Message_Block *mb = 0;
160 int result = msg_queue->dequeue_head (mb);
162 if (result == -1)
163 break;
165 local_count++;
167 ACE_TEST_ASSERT (*expected == *mb->rd_ptr ());
170 ACE_TEST_ASSERT (local_count == ACE_OS::strlen (receipt_order));
171 ACE_TEST_ASSERT (local_count == expected_count);
172 return 0;
175 // The order producer runs through the passed send string, setting the
176 // read pointer of the current message to the current character
177 // position in the string, and then queueing the message in the
178 // message list, where it is removed by the order consumer.
180 static void *
181 order_producer (void *args)
183 ACE_TEST_ASSERT (args != 0);
185 ACE_Message_Queue<ACE_SYNCH> *msg_queue =
186 static_cast<ArgStruct *> (args)->queue_;
187 const char *send_order =
188 static_cast<ArgStruct *> (args)->order_string_;
189 ACE_Message_Block **block_array =
190 static_cast<ArgStruct *> (args)->array_;
191 int expected_count =
192 static_cast<ArgStruct *> (args)->expected_count_;
194 ACE_TEST_ASSERT (send_order != 0);
195 ACE_TEST_ASSERT (block_array != 0);
197 // Iterate through the send order string and the message block
198 // array, setting the current message block's read pointer to the
199 // current position in the send order string.
200 int local_count = 0;
201 const char *c;
203 for (local_count = 0, c = send_order; *c != '\0'; ++local_count, ++c)
205 // point to the current message block
206 ACE_Message_Block *mb = block_array [local_count];
207 ACE_TEST_ASSERT (mb != 0);
209 // Set the current send character in the current message block
210 // at its read pointer position, and adjust the write pointer.
211 *mb->wr_ptr () = *c;
212 mb->wr_ptr (1);
215 // Enqueue the message block in priority order.
216 if (msg_queue->enqueue_prio (mb) == -1)
217 break;
220 ACE_TEST_ASSERT (local_count == expected_count);
222 return 0;
225 static int
226 run_order_test (ACE_Message_Queue<ACE_SYNCH>* msg_queue,
227 const char *send_order,
228 const char *receipt_order)
230 u_int i;
231 u_int array_size = ACE_OS::strlen (send_order);
233 ACE_TEST_ASSERT (msg_queue != 0);
234 ACE_TEST_ASSERT (send_order != 0);
235 ACE_TEST_ASSERT (receipt_order != 0);
236 ACE_TEST_ASSERT (ACE_OS::strlen (send_order) == ACE_OS::strlen (receipt_order));
238 ArgStruct supplier_args, consumer_args;
240 supplier_args.queue_ = msg_queue;
241 supplier_args.order_string_ = send_order;
242 supplier_args.expected_count_ = ACE_OS::strlen (send_order);
244 // Allocate message blocks, fill in pointer array, set static
245 // information.
246 ACE_NEW_RETURN (supplier_args.array_,
247 ACE_Message_Block *[array_size],
248 -1);
250 for (i = 0; i < array_size; ++i)
252 // Construct a message new block off the heap, to hold a single
253 // character.
254 ACE_NEW_RETURN (supplier_args.array_[i],
255 ACE_Message_Block (1),
256 -1);
258 // Assign static (minimal) message priority in ascending order.
259 supplier_args.array_[i]->msg_priority (i);
261 // Assign every other message short or long execution time.
262 supplier_args.array_[i]->msg_execution_time (((i % 2)
263 ? slow_execution
264 : fast_execution));
267 consumer_args.queue_ = msg_queue;
268 consumer_args.order_string_ = receipt_order;
269 consumer_args.expected_count_ = ACE_OS::strlen (receipt_order);
270 consumer_args.array_ = 0;
272 // Construct pending and late absolute deadline times.
274 ACE_Time_Value current_time (0, 0);
275 ACE_Time_Value future_deadline (1, 0);
276 ACE_Time_Value near_deadline (0, 500000);
277 ACE_Time_Value recent_deadline (0, -1);
278 ACE_Time_Value past_deadline (0, -500000);
280 current_time = ACE_OS::gettimeofday ();
282 future_deadline += current_time;
283 near_deadline += current_time;
284 recent_deadline += current_time;
285 past_deadline += current_time;
287 // Set absolute time of deadline associated with the message.
289 for (i = 0; i < array_size; ++i)
291 switch ((4 * i) / array_size)
293 case 0:
294 supplier_args.array_[i]->msg_deadline_time (future_deadline);
295 break;
296 case 1:
297 supplier_args.array_[i]->msg_deadline_time (near_deadline);
298 break;
299 case 2:
300 supplier_args.array_[i]->msg_deadline_time (recent_deadline);
301 break;
302 case 3:
303 supplier_args.array_[i]->msg_deadline_time (past_deadline);
304 break;
305 // should never reach here, but its better to make sure
306 default:
307 ACE_TEST_ASSERT ((4 * i) / array_size < 4);
308 break;
312 // run the order test producer
313 order_producer (&supplier_args);
315 // run the order test consumer
316 order_consumer (&consumer_args);
318 // free all the allocated message blocks
319 for (i = 0; i < array_size; ++i)
321 delete supplier_args.array_[i];
324 // free the allocated pointer array
325 delete [] supplier_args.array_;
327 return 0;
330 // The performance consumer starts a timer, dequeues all messages from
331 // the passed Message_Queue, stops the timer, and reports the number
332 // of dequeued messages, the elapsed time, and the average time per
333 // message.
335 static void *
336 performance_consumer (void * args)
338 ACE_High_Res_Timer timer;
340 ACE_TEST_ASSERT (args != 0);
342 ACE_Message_Queue<ACE_SYNCH> *msg_queue =
343 static_cast<ArgStruct *> (args)->queue_;
344 u_int expected_count =
345 static_cast<ArgStruct *> (args)->expected_count_;
347 ACE_TEST_ASSERT (msg_queue != 0);
349 u_int local_count = 0;
350 ACE_Message_Block *mb = 0;
352 // reset, then start timer
353 timer.reset ();
354 timer.start ();
356 // Keep looping, reading a message out of the queue, until the
357 // expected number of messages have been dequeued.
358 for (local_count = 0; local_count < expected_count; ++local_count)
359 if (msg_queue->dequeue_head (mb) == -1)
360 break;
362 // Stop timer, obtain and report its elapsed time.x
363 timer.stop ();
364 ACE_Time_Value tv;
365 timer.elapsed_time (tv);
366 ACE_DEBUG ((LM_INFO, ACE_TEXT ("%6u, %6u, %f"),
367 local_count,
368 tv.msec (),
369 (ACE_timer_t) tv.msec () / local_count));
371 ACE_TEST_ASSERT (local_count == expected_count);
372 return 0;
375 // The performance producer starts a timer, enqueues the passed
376 // messages setting the read pointer of each message to the first
377 // character position in the passed string, stops the timer, and
378 // reports the number of enqueued messages, the elapsed time, and the
379 // average time per message.
381 static void *
382 performance_producer (void *args)
384 ACE_High_Res_Timer timer;
386 ACE_TEST_ASSERT (args != 0);
388 ACE_Message_Queue<ACE_SYNCH> *msg_queue =
389 static_cast<ArgStruct *> (args)->queue_;
390 ACE_Message_Block **block_array =
391 static_cast<ArgStruct *> (args)->array_;
392 int expected_count =
393 static_cast<ArgStruct *> (args)->expected_count_;
395 ACE_TEST_ASSERT (send_order != 0);
396 ACE_TEST_ASSERT (block_array != 0);
398 // reset, then start timer
399 timer.reset ();
400 timer.start ();
402 // Iterate through the message block array, setting the character
403 // under the current message block's read pointer to null before
404 // enqueueing the message block.
406 int local_count = 0;
407 for (local_count = 0; local_count < expected_count; ++local_count)
409 // Point to the current message block.
410 ACE_Message_Block *mb = block_array [local_count];
411 ACE_TEST_ASSERT (mb != 0);
413 // Set a character in the current message block at its
414 // read pointer position, and adjust the write pointer.
415 mb->reset();
416 *mb->wr_ptr () = 'a';
417 mb->wr_ptr (1);
419 // Enqueue the message block in priority order.
420 if (msg_queue->enqueue_prio (mb) == -1)
421 break;
424 // Stop timer, obtain and report its elapsed time.
425 timer.stop ();
426 ACE_Time_Value tv;
427 timer.elapsed_time (tv);
428 ACE_DEBUG ((LM_INFO, ACE_TEXT ("%6u, %6u, %f, "),
429 local_count,
430 tv.msec (),
431 (ACE_timer_t) tv.msec () / local_count));
433 ACE_TEST_ASSERT (local_count == expected_count);
434 return 0;
437 static int
438 run_performance_test (u_int min_load,
439 u_int max_load,
440 u_int load_step,
441 Test_Type test_type)
443 ArgStruct supplier_args, consumer_args; // supplier and consumer argument strings
444 u_int load = 0; // message load
445 ACE_Time_Value *time_offsets; // pointer to array of time offsets
446 ACE_Time_Value current_time; // current time value
447 u_int shuffle_index; // used to shuffle arrays
448 int random_int = 0; // also used to shuffle arrays
449 ACE_Message_Block *temp_block; // temporary message block pointer
450 ACE_Time_Value temp_time; // temporary time value
452 // Build a static queue, a deadline based dynamic queue, and a
453 // laxity based dynamic queue.
455 ACE_Message_Queue<ACE_SYNCH> *static_queue =
456 ACE_Message_Queue_Factory<ACE_SYNCH>::create_static_message_queue (max_queue);
457 ACE_TEST_ASSERT (static_queue != 0);
459 ACE_Message_Queue<ACE_SYNCH> *deadline_queue =
460 ACE_Message_Queue_Factory<ACE_SYNCH>::create_deadline_message_queue (max_queue);
461 ACE_TEST_ASSERT (deadline_queue != 0);
463 ACE_Message_Queue<ACE_SYNCH> *laxity_queue =
464 ACE_Message_Queue_Factory<ACE_SYNCH>::create_laxity_message_queue (max_queue);
466 ACE_TEST_ASSERT (laxity_queue != 0);
468 // Zero out unused struct members.
469 supplier_args.order_string_ = 0;
470 consumer_args.order_string_ = 0;
471 consumer_args.array_ = 0;
473 // Print column headings for the specific test type.
474 switch (test_type)
476 case BEST:
477 ACE_DEBUG ((LM_INFO,
478 ACE_TEXT ("\n\nenqueued, best static time, best static avg, ")
479 ACE_TEXT ("dequeued, best static time, best static avg, ")
480 ACE_TEXT ("enqueued, best deadline time, best deadline avg, ")
481 ACE_TEXT ("dequeued, best deadline time, best deadline avg, ")
482 ACE_TEXT ("enqueued, best laxity time, best laxity avg, ")
483 ACE_TEXT ("dequeued, best laxity time, best laxity avg\n")));
484 break;
485 case WORST:
486 ACE_DEBUG ((LM_INFO,
487 ACE_TEXT ("\n\nenqueued, worst static time, worst static avg, ")
488 ACE_TEXT ("dequeued, worst static time, worst static avg, ")
489 ACE_TEXT ("enqueued, worst deadline time, worst deadline avg, ")
490 ACE_TEXT ("dequeued, worst deadline time, worst deadline avg, ")
491 ACE_TEXT ("enqueued, worst laxity time, worst laxity avg, ")
492 ACE_TEXT ("dequeued, worst laxity time, worst laxity avg\n")));
494 break;
495 case RANDOM:
496 ACE_DEBUG ((LM_INFO,
497 ACE_TEXT ("\n\nenqueued, random static time, random static avg, ")
498 ACE_TEXT ("dequeued, random static time, random static avg, ")
499 ACE_TEXT ("enqueued, random deadline time, random deadline avg, ")
500 ACE_TEXT ("dequeued, random deadline time, random deadline avg, ")
501 ACE_TEXT ("enqueued, random laxity time, random laxity avg, ")
502 ACE_TEXT ("dequeued, random laxity time, random laxity avg\n")));
503 break;
504 default:
505 ACE_ERROR_RETURN ((LM_ERROR,
506 ACE_TEXT ("unknown test type %d"),
507 test_type),
508 -1);
511 // Iterate through the message loads, and at each load do an
512 // identical test on all queues.
513 for (load = min_load; load <= max_load; load += load_step)
515 u_int i;
517 supplier_args.expected_count_ = load;
518 consumer_args.expected_count_ = load;
520 // Allocate message blocks, fill in pointer array, set static
521 // information.
522 ACE_NEW_RETURN (supplier_args.array_,
523 ACE_Message_Block *[load],
524 -1);
526 // Allocate array of timing offsets.
527 ACE_NEW_RETURN (time_offsets,
528 ACE_Time_Value [load],
529 -1);
531 // Fill in information for all types of tests.
532 for (i = 0; i < load; ++i)
534 // Construct a message new block off the heap, to hold a
535 // single character.
536 ACE_NEW_RETURN (supplier_args.array_[i],
537 ACE_Message_Block (1),
538 -1);
540 // Assign every other message short or long execution time.
541 supplier_args.array_[i]->msg_execution_time (((i % 2)
542 ? slow_execution
543 : fast_execution));
546 // Fill in information for the specific type of test.
547 switch (test_type)
549 case BEST:
550 // Fill in best case information.
551 time_offsets [0] = far_past_offset;
552 supplier_args.array_[0]->msg_priority (load);
554 for (i = 1; i < load; ++i)
556 // Assign static (minimal) message priority in
557 // descending order.
558 supplier_args.array_[i]->msg_priority (load - i);
560 // Assign time to deadline in descending order.
561 time_offsets [i] = time_offsets [i - 1] + offset_step;
564 break;
565 case WORST:
566 // Fill in worst case information.
567 time_offsets [0] = near_future_offset;
568 supplier_args.array_[0]->msg_priority (0);
570 for (i = 1; i < load; ++i)
572 // Assign static (minimal) message priority in ascending
573 // order.
574 supplier_args.array_[i]->msg_priority (i);
576 // Assign time to deadline in descending order (puts
577 // dynamic priority in ascending order).
578 time_offsets [i] = time_offsets [i - 1] - offset_step;
580 break;
581 case RANDOM:
582 // Fill in worst case information.
583 time_offsets [0] = near_future_offset;
584 supplier_args.array_[0]->msg_priority (0);
586 for (i = 1; i < load; ++i)
588 // Assign static (minimal) message priority in ascending
589 // order.
590 supplier_args.array_[i]->msg_priority (i);
592 // Assign time to deadline in descending order (puts
593 // dynamic priority in ascending order).
594 time_offsets [i] = time_offsets [i - 1] - offset_step;
597 // Then shuffle the arrays in tandem.
598 for (i = 0; i < load; ++i)
600 // Choose a (pseudo) random integer (evenly distributed
601 // over [0, load-1]).
602 if (RAND_MAX >= load)
604 // Discard integers in the tail of the random range
605 // that do not distribute evenly modulo the number
606 // of messages.
608 random_int = ACE_OS::rand ();
609 while (random_int >= (int)(RAND_MAX - (RAND_MAX % load)));
611 else if (RAND_MAX < load - 1)
612 // This should only happen for a *very* large messages
613 // relative to the system's representation size.
614 ACE_ERROR_RETURN ((LM_ERROR,
615 ACE_TEXT ("Insufficient range of random numbers")),
616 -1);
617 shuffle_index = random_int % load;
619 // Swap the message at the current index with the one at
620 // the shuffle index.
621 temp_block = supplier_args.array_[i];
622 supplier_args.array_[i] = supplier_args.array_[shuffle_index];
623 supplier_args.array_[shuffle_index] = temp_block;
625 // Swap the time at the current index with the one at
626 // the shuffle index.
627 temp_time = time_offsets [i];
628 time_offsets [i] = time_offsets [shuffle_index];
629 time_offsets [shuffle_index] = temp_time;
631 break;
632 default:
633 ACE_ERROR_RETURN ((LM_ERROR,
634 ACE_TEXT ("unknown test type %d"),
635 test_type),
636 -1);
639 // Set absolute time of deadline associated with each message.
640 current_time = ACE_OS::gettimeofday ();
642 for (i = 0; i < load; ++i)
643 supplier_args.array_[i]->msg_deadline_time (time_offsets [i] + current_time);
645 // Run the performance test producer and consumer on the static
646 // queue.
647 supplier_args.queue_ = static_queue;
648 performance_producer (&supplier_args);
649 consumer_args.queue_ = static_queue;
650 performance_consumer (&consumer_args);
652 // Add a comma delimiter for most recent outputs.
653 ACE_DEBUG ((LM_INFO,
654 ACE_TEXT (", ")));
656 // Run the performance test producer and consumer on the
657 // deadline queue.
658 supplier_args.queue_ = deadline_queue;
659 performance_producer (&supplier_args);
660 consumer_args.queue_ = deadline_queue;
661 performance_consumer (&consumer_args);
663 // Add a comma delimiter for most recent outputs.
664 ACE_DEBUG ((LM_INFO,
665 ACE_TEXT (", ")));
667 // Run the performance test producer and consumer on the laxity
668 // queue.
669 supplier_args.queue_ = laxity_queue;
670 performance_producer (&supplier_args);
671 consumer_args.queue_ = laxity_queue;
672 performance_consumer (&consumer_args);
674 // Move to the next line of output.
675 ACE_DEBUG ((LM_INFO,
676 ACE_TEXT ("\n")));
678 delete [] time_offsets;
680 // Free all the allocated message blocks.
681 for (i = 0; i < load; ++i)
682 delete supplier_args.array_[i];
684 // Free the allocated pointer array.
685 delete [] supplier_args.array_;
689 // Free resources and leave.
690 delete static_queue;
691 delete deadline_queue;
692 delete laxity_queue;
693 return 0;
695 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
698 run_main (int, ACE_TCHAR *[])
700 ACE_START_TEST (ACE_TEXT ("Dynamic_Priority_Test"));
702 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
703 // Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
704 if (ACE_OS::sched_params (
705 ACE_Sched_Params (
706 ACE_SCHED_FIFO,
707 ACE_Sched_Params::priority_min (ACE_SCHED_FIFO),
708 ACE_SCOPE_PROCESS)) != 0)
710 if (ACE_OS::last_error () == EPERM)
711 ACE_DEBUG ((LM_MAX,
712 ACE_TEXT ("user is not superuser, ")
713 ACE_TEXT ("so remain in time-sharing class\n")));
714 else if (ACE_OS::last_error () == ENOTSUP)
715 ACE_DEBUG ((LM_MAX,
716 ACE_TEXT ("process scope scheduling is not available, ")
717 ACE_TEXT ("so remain in time-sharing class\n")));
718 else
719 ACE_ERROR_RETURN ((LM_ERROR,
720 ACE_TEXT ("%n: ACE_OS::sched_params failed\n%a")),
721 -1);
724 // Test factory, static message queue.
725 ACE_Message_Queue<ACE_SYNCH> *test_queue =
726 ACE_Message_Queue_Factory<ACE_SYNCH>::create_static_message_queue (max_queue);
727 ACE_TEST_ASSERT (test_queue != 0);
728 run_order_test (test_queue,
729 send_order,
730 static_receipt_order);
731 delete test_queue;
733 // Test factory, dynamic message queue (deadline strategy).
734 test_queue =
735 ACE_Message_Queue_Factory<ACE_SYNCH>::create_deadline_message_queue (max_queue);
736 ACE_TEST_ASSERT (test_queue != 0);
737 run_order_test (test_queue,
738 send_order,
739 deadline_receipt_order);
740 delete test_queue;
742 // Test factory, dynamic message queue (laxity strategy).
743 test_queue =
744 ACE_Message_Queue_Factory<ACE_SYNCH>::create_laxity_message_queue (max_queue);
745 ACE_TEST_ASSERT (test_queue != 0);
746 run_order_test (test_queue,
747 send_order,
748 laxity_receipt_order);
749 delete test_queue;
751 #if defined (VXWORKS)
752 // test factory for VxWorks message queue.
753 ACE_Message_Queue_Vx *test_queue_vx =
754 ACE_Message_Queue_Factory<ACE_NULL_SYNCH>::create_Vx_message_queue (vx_max_queue,
755 vx_msg_size);
756 ACE_TEST_ASSERT (test_queue_vx != 0);
757 // (TBD - does message receipt order test make any sense for Vx Queue ?
758 // If so, uncomment order test, or if not remove order test, below)
759 // @@ % levine 22 Jul 1998 % It'd be nice to run the test, but:
760 // ACE_Message_Queue_Vx isa
761 // ACE_Message_Queue<ACE_NULL_SYNCH>, not an
762 // ACE_Message_Queue<ACE_MT_SYNCH>, so we're
763 // not type-compatible.
765 // run_order_test (test_queue, send_order, static_receipt_order);
766 delete test_queue_vx;
767 #endif /* VXWORKS */
769 // For each of an increasing number of message loads, run the same
770 // performance test (best case, worst case, and randomized, over
771 // each kind of queue).
772 run_performance_test (MIN_LOAD,
773 MAX_LOAD,
774 LOAD_STEP,
775 BEST);
777 run_performance_test (MIN_LOAD,
778 MAX_LOAD,
779 LOAD_STEP,
780 WORST);
782 run_performance_test (MIN_LOAD,
783 MAX_LOAD,
784 LOAD_STEP,
785 RANDOM);
786 #else
787 ACE_DEBUG ((LM_DEBUG,
788 ACE_TEXT ("ACE is not compiled with ACE_HAS_TIMED_MESSAGE_BLOCKS enabled\n")));
789 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
791 ACE_END_TEST;
792 return 0;