Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / tests / Dynamic_Priority_Test.cpp
blob0d2ec3ff127cc9e669cb9c6f5d946ed1b1947e3b
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 */
55 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
56 enum Test_Type {BEST, WORST, RANDOM};
58 /**
59 * @class ArgStruct
61 * @brief Structure used to pass arguments to test functions.
63 class ArgStruct
65 public:
66 /// message queue to test
67 ACE_Message_Queue<ACE_SYNCH> *queue_;
69 /// string of characters to indicate message order
70 const char *order_string_;
72 /// array of message blocks to use
73 ACE_Message_Block **array_;
75 /// expected message count
76 u_int expected_count_;
79 // Order in which messages are sent.
80 static const char send_order [] = "abcdefghijklmnop";
82 // Order in which messages are received with "FIFO prioritization"
83 // (i.e., none)
84 // Unused: static const char FIFO_receipt_order [] = "abcdefghijklmnop";
86 // Order in which messages are received with static prioritization.
87 static const char static_receipt_order [] = "ponmlkjihgfedcba";
89 // Order in which messages are received with deadline prioritization.
90 static const char deadline_receipt_order [] = "hgfedcbaponmlkji";
92 // Order in which messages are received with laxity prioritization.
93 static const char laxity_receipt_order [] = "hfgedbcapnomljki";
95 // Fast and slow execution time values (sec, usec), kept very small to
96 // allow comparison of deadline, laxity, and static strategies across
97 // a very wide range of message counts.
98 static const ACE_Time_Value fast_execution (0, 1);
99 static const ACE_Time_Value slow_execution (0, 2);
101 // Make the queue be capable of being *very* large.
102 static const long max_queue = LONG_MAX;
104 #if defined (VXWORKS)
105 // VxWorks Message Queue parameters.
106 const int vx_max_queue = INT_MAX;
107 const int vx_msg_size = 32;
108 #endif /* defined (VXWORKS) */
110 // Loading parameters (number of messages to push through queues) for
111 // performance tests.
112 static int MIN_LOAD = 20;
113 static int MAX_LOAD = 1000;
114 static int LOAD_STEP = 20;
116 // Time offsets for a minute in the past (for the best case test) and
117 // two seconds in the future (for the worst case and randomized
118 // tests).
119 static const ACE_Time_Value far_past_offset (-60, 0);
120 static const ACE_Time_Value near_future_offset (2, 0);
121 static const ACE_Time_Value offset_step (0, 5);
123 // The order consumer dequeues a message from the passed
124 // Message_Queue, and checks its data character against the passed
125 // string of characters which has the expected ordering. Suppliers
126 // and consumers do not allocate or deallocate messages, to avoid
127 // timing delays and timing jitter in the test: the main function is
128 // responsible for all initialization allocation and cleanup before,
129 // between, and after (but not during) the transfer of messages from a
130 // supplier to the corresponding consumer.
132 static void *
133 order_consumer (void *args)
135 ACE_TEST_ASSERT (args != 0);
137 ACE_Message_Queue<ACE_SYNCH> *msg_queue =
138 static_cast<ArgStruct *> (args)->queue_;
139 const char *receipt_order =
140 static_cast<ArgStruct *> (args)->order_string_;
141 u_int expected_count =
142 static_cast<ArgStruct *> (args)->expected_count_;
144 ACE_TEST_ASSERT (receipt_order != 0);
145 ACE_TEST_ASSERT (msg_queue != 0);
147 u_int local_count = 0;
149 // Keep looping, reading a message out of the queue, until we reach
150 // the end of the receipt order string, which signals us to quit.
152 for (const char *expected = receipt_order;
153 *expected != '\0';
154 ++expected)
156 ACE_Message_Block *mb = 0;
158 int result = msg_queue->dequeue_head (mb);
160 if (result == -1)
161 break;
163 local_count++;
165 ACE_TEST_ASSERT (*expected == *mb->rd_ptr ());
168 ACE_TEST_ASSERT (local_count == ACE_OS::strlen (receipt_order));
169 ACE_TEST_ASSERT (local_count == expected_count);
170 return 0;
173 // The order producer runs through the passed send string, setting the
174 // read pointer of the current message to the current character
175 // position in the string, and then queueing the message in the
176 // message list, where it is removed by the order consumer.
178 static void *
179 order_producer (void *args)
181 ACE_TEST_ASSERT (args != 0);
183 ACE_Message_Queue<ACE_SYNCH> *msg_queue =
184 static_cast<ArgStruct *> (args)->queue_;
185 const char *send_order =
186 static_cast<ArgStruct *> (args)->order_string_;
187 ACE_Message_Block **block_array =
188 static_cast<ArgStruct *> (args)->array_;
189 int expected_count =
190 static_cast<ArgStruct *> (args)->expected_count_;
192 ACE_TEST_ASSERT (send_order != 0);
193 ACE_TEST_ASSERT (block_array != 0);
195 // Iterate through the send order string and the message block
196 // array, setting the current message block's read pointer to the
197 // current position in the send order string.
198 int local_count = 0;
199 const char *c;
201 for (local_count = 0, c = send_order; *c != '\0'; ++local_count, ++c)
203 // point to the current message block
204 ACE_Message_Block *mb = block_array [local_count];
205 ACE_TEST_ASSERT (mb != 0);
207 // Set the current send character in the current message block
208 // at its read pointer position, and adjust the write pointer.
209 *mb->wr_ptr () = *c;
210 mb->wr_ptr (1);
213 // Enqueue the message block in priority order.
214 if (msg_queue->enqueue_prio (mb) == -1)
215 break;
218 ACE_TEST_ASSERT (local_count == expected_count);
220 return 0;
223 static int
224 run_order_test (ACE_Message_Queue<ACE_SYNCH>* msg_queue,
225 const char *send_order,
226 const char *receipt_order)
228 u_int i;
229 u_int array_size = ACE_OS::strlen (send_order);
231 ACE_TEST_ASSERT (msg_queue != 0);
232 ACE_TEST_ASSERT (send_order != 0);
233 ACE_TEST_ASSERT (receipt_order != 0);
234 ACE_TEST_ASSERT (ACE_OS::strlen (send_order) == ACE_OS::strlen (receipt_order));
236 ArgStruct supplier_args, consumer_args;
238 supplier_args.queue_ = msg_queue;
239 supplier_args.order_string_ = send_order;
240 supplier_args.expected_count_ = ACE_OS::strlen (send_order);
242 // Allocate message blocks, fill in pointer array, set static
243 // information.
244 ACE_NEW_RETURN (supplier_args.array_,
245 ACE_Message_Block *[array_size],
246 -1);
248 for (i = 0; i < array_size; ++i)
250 // Construct a message new block off the heap, to hold a single
251 // character.
252 ACE_NEW_RETURN (supplier_args.array_[i],
253 ACE_Message_Block (1),
254 -1);
256 // Assign static (minimal) message priority in ascending order.
257 supplier_args.array_[i]->msg_priority (i);
259 // Assign every other message short or long execution time.
260 supplier_args.array_[i]->msg_execution_time (((i % 2)
261 ? slow_execution
262 : fast_execution));
265 consumer_args.queue_ = msg_queue;
266 consumer_args.order_string_ = receipt_order;
267 consumer_args.expected_count_ = ACE_OS::strlen (receipt_order);
268 consumer_args.array_ = 0;
270 // Construct pending and late absolute deadline times.
272 ACE_Time_Value current_time (0, 0);
273 ACE_Time_Value future_deadline (1, 0);
274 ACE_Time_Value near_deadline (0, 500000);
275 ACE_Time_Value recent_deadline (0, -1);
276 ACE_Time_Value past_deadline (0, -500000);
278 current_time = ACE_OS::gettimeofday ();
280 future_deadline += current_time;
281 near_deadline += current_time;
282 recent_deadline += current_time;
283 past_deadline += current_time;
285 // Set absolute time of deadline associated with the message.
287 for (i = 0; i < array_size; ++i)
289 switch ((4 * i) / array_size)
291 case 0:
292 supplier_args.array_[i]->msg_deadline_time (future_deadline);
293 break;
294 case 1:
295 supplier_args.array_[i]->msg_deadline_time (near_deadline);
296 break;
297 case 2:
298 supplier_args.array_[i]->msg_deadline_time (recent_deadline);
299 break;
300 case 3:
301 supplier_args.array_[i]->msg_deadline_time (past_deadline);
302 break;
303 // should never reach here, but its better to make sure
304 default:
305 ACE_TEST_ASSERT ((4 * i) / array_size < 4);
306 break;
310 // run the order test producer
311 order_producer (&supplier_args);
313 // run the order test consumer
314 order_consumer (&consumer_args);
316 // free all the allocated message blocks
317 for (i = 0; i < array_size; ++i)
319 delete supplier_args.array_[i];
322 // free the allocated pointer array
323 delete [] supplier_args.array_;
325 return 0;
328 // The performance consumer starts a timer, dequeues all messages from
329 // the passed Message_Queue, stops the timer, and reports the number
330 // of dequeued messages, the elapsed time, and the average time per
331 // message.
333 static void *
334 performance_consumer (void * args)
336 ACE_High_Res_Timer timer;
338 ACE_TEST_ASSERT (args != 0);
340 ACE_Message_Queue<ACE_SYNCH> *msg_queue =
341 static_cast<ArgStruct *> (args)->queue_;
342 u_int expected_count =
343 static_cast<ArgStruct *> (args)->expected_count_;
345 ACE_TEST_ASSERT (msg_queue != 0);
347 u_int local_count = 0;
348 ACE_Message_Block *mb = 0;
350 // reset, then start timer
351 timer.reset ();
352 timer.start ();
354 // Keep looping, reading a message out of the queue, until the
355 // expected number of messages have been dequeued.
356 for (local_count = 0; local_count < expected_count; ++local_count)
357 if (msg_queue->dequeue_head (mb) == -1)
358 break;
360 // Stop timer, obtain and report its elapsed time.x
361 timer.stop ();
362 ACE_Time_Value tv;
363 timer.elapsed_time (tv);
364 ACE_DEBUG ((LM_INFO, ACE_TEXT ("%6u, %6u, %f"),
365 local_count,
366 tv.msec (),
367 (ACE_timer_t) tv.msec () / local_count));
369 ACE_TEST_ASSERT (local_count == expected_count);
370 return 0;
373 // The performance producer starts a timer, enqueues the passed
374 // messages setting the read pointer of each message to the first
375 // character position in the passed string, stops the timer, and
376 // reports the number of enqueued messages, the elapsed time, and the
377 // average time per message.
379 static void *
380 performance_producer (void *args)
382 ACE_High_Res_Timer timer;
384 ACE_TEST_ASSERT (args != 0);
386 ACE_Message_Queue<ACE_SYNCH> *msg_queue =
387 static_cast<ArgStruct *> (args)->queue_;
388 ACE_Message_Block **block_array =
389 static_cast<ArgStruct *> (args)->array_;
390 int expected_count =
391 static_cast<ArgStruct *> (args)->expected_count_;
393 ACE_TEST_ASSERT (send_order != 0);
394 ACE_TEST_ASSERT (block_array != 0);
396 // reset, then start timer
397 timer.reset ();
398 timer.start ();
400 // Iterate through the message block array, setting the character
401 // under the current message block's read pointer to null before
402 // enqueueing the message block.
404 int local_count = 0;
405 for (local_count = 0; local_count < expected_count; ++local_count)
407 // Point to the current message block.
408 ACE_Message_Block *mb = block_array [local_count];
409 ACE_TEST_ASSERT (mb != 0);
411 // Set a character in the current message block at its
412 // read pointer position, and adjust the write pointer.
413 mb->reset();
414 *mb->wr_ptr () = 'a';
415 mb->wr_ptr (1);
417 // Enqueue the message block in priority order.
418 if (msg_queue->enqueue_prio (mb) == -1)
419 break;
422 // Stop timer, obtain and report its elapsed time.
423 timer.stop ();
424 ACE_Time_Value tv;
425 timer.elapsed_time (tv);
426 ACE_DEBUG ((LM_INFO, ACE_TEXT ("%6u, %6u, %f, "),
427 local_count,
428 tv.msec (),
429 (ACE_timer_t) tv.msec () / local_count));
431 ACE_TEST_ASSERT (local_count == expected_count);
432 return 0;
435 static int
436 run_performance_test (u_int min_load,
437 u_int max_load,
438 u_int load_step,
439 Test_Type test_type)
441 ArgStruct supplier_args, consumer_args; // supplier and consumer argument strings
442 u_int load = 0; // message load
443 ACE_Time_Value *time_offsets; // pointer to array of time offsets
444 ACE_Time_Value current_time; // current time value
445 u_int shuffle_index; // used to shuffle arrays
446 int random_int = 0; // also used to shuffle arrays
447 ACE_Message_Block *temp_block; // temporary message block pointer
448 ACE_Time_Value temp_time; // temporary time value
450 // Build a static queue, a deadline based dynamic queue, and a
451 // laxity based dynamic queue.
453 ACE_Message_Queue<ACE_SYNCH> *static_queue =
454 ACE_Message_Queue_Factory<ACE_SYNCH>::create_static_message_queue (max_queue);
455 ACE_TEST_ASSERT (static_queue != 0);
457 ACE_Message_Queue<ACE_SYNCH> *deadline_queue =
458 ACE_Message_Queue_Factory<ACE_SYNCH>::create_deadline_message_queue (max_queue);
459 ACE_TEST_ASSERT (deadline_queue != 0);
461 ACE_Message_Queue<ACE_SYNCH> *laxity_queue =
462 ACE_Message_Queue_Factory<ACE_SYNCH>::create_laxity_message_queue (max_queue);
464 ACE_TEST_ASSERT (laxity_queue != 0);
466 // Zero out unused struct members.
467 supplier_args.order_string_ = 0;
468 consumer_args.order_string_ = 0;
469 consumer_args.array_ = 0;
471 // Print column headings for the specific test type.
472 switch (test_type)
474 case BEST:
475 ACE_DEBUG ((LM_INFO,
476 ACE_TEXT ("\n\nenqueued, best static time, best static avg, ")
477 ACE_TEXT ("dequeued, best static time, best static avg, ")
478 ACE_TEXT ("enqueued, best deadline time, best deadline avg, ")
479 ACE_TEXT ("dequeued, best deadline time, best deadline avg, ")
480 ACE_TEXT ("enqueued, best laxity time, best laxity avg, ")
481 ACE_TEXT ("dequeued, best laxity time, best laxity avg\n")));
482 break;
483 case WORST:
484 ACE_DEBUG ((LM_INFO,
485 ACE_TEXT ("\n\nenqueued, worst static time, worst static avg, ")
486 ACE_TEXT ("dequeued, worst static time, worst static avg, ")
487 ACE_TEXT ("enqueued, worst deadline time, worst deadline avg, ")
488 ACE_TEXT ("dequeued, worst deadline time, worst deadline avg, ")
489 ACE_TEXT ("enqueued, worst laxity time, worst laxity avg, ")
490 ACE_TEXT ("dequeued, worst laxity time, worst laxity avg\n")));
492 break;
493 case RANDOM:
494 ACE_DEBUG ((LM_INFO,
495 ACE_TEXT ("\n\nenqueued, random static time, random static avg, ")
496 ACE_TEXT ("dequeued, random static time, random static avg, ")
497 ACE_TEXT ("enqueued, random deadline time, random deadline avg, ")
498 ACE_TEXT ("dequeued, random deadline time, random deadline avg, ")
499 ACE_TEXT ("enqueued, random laxity time, random laxity avg, ")
500 ACE_TEXT ("dequeued, random laxity time, random laxity avg\n")));
501 break;
502 default:
503 ACE_ERROR_RETURN ((LM_ERROR,
504 ACE_TEXT ("unknown test type %d"),
505 test_type),
506 -1);
509 // Iterate through the message loads, and at each load do an
510 // identical test on all queues.
511 for (load = min_load; load <= max_load; load += load_step)
513 u_int i;
515 supplier_args.expected_count_ = load;
516 consumer_args.expected_count_ = load;
518 // Allocate message blocks, fill in pointer array, set static
519 // information.
520 ACE_NEW_RETURN (supplier_args.array_,
521 ACE_Message_Block *[load],
522 -1);
524 // Allocate array of timing offsets.
525 ACE_NEW_RETURN (time_offsets,
526 ACE_Time_Value [load],
527 -1);
529 // Fill in information for all types of tests.
530 for (i = 0; i < load; ++i)
532 // Construct a message new block off the heap, to hold a
533 // single character.
534 ACE_NEW_RETURN (supplier_args.array_[i],
535 ACE_Message_Block (1),
536 -1);
538 // Assign every other message short or long execution time.
539 supplier_args.array_[i]->msg_execution_time (((i % 2)
540 ? slow_execution
541 : fast_execution));
544 // Fill in information for the specific type of test.
545 switch (test_type)
547 case BEST:
548 // Fill in best case information.
549 time_offsets [0] = far_past_offset;
550 supplier_args.array_[0]->msg_priority (load);
552 for (i = 1; i < load; ++i)
554 // Assign static (minimal) message priority in
555 // descending order.
556 supplier_args.array_[i]->msg_priority (load - i);
558 // Assign time to deadline in descending order.
559 time_offsets [i] = time_offsets [i - 1] + offset_step;
562 break;
563 case WORST:
564 // Fill in worst case information.
565 time_offsets [0] = near_future_offset;
566 supplier_args.array_[0]->msg_priority (0);
568 for (i = 1; i < load; ++i)
570 // Assign static (minimal) message priority in ascending
571 // order.
572 supplier_args.array_[i]->msg_priority (i);
574 // Assign time to deadline in descending order (puts
575 // dynamic priority in ascending order).
576 time_offsets [i] = time_offsets [i - 1] - offset_step;
578 break;
579 case RANDOM:
580 // Fill in worst case information.
581 time_offsets [0] = near_future_offset;
582 supplier_args.array_[0]->msg_priority (0);
584 for (i = 1; i < load; ++i)
586 // Assign static (minimal) message priority in ascending
587 // order.
588 supplier_args.array_[i]->msg_priority (i);
590 // Assign time to deadline in descending order (puts
591 // dynamic priority in ascending order).
592 time_offsets [i] = time_offsets [i - 1] - offset_step;
595 // Then shuffle the arrays in tandem.
596 for (i = 0; i < load; ++i)
598 // Choose a (pseudo) random integer (evenly distributed
599 // over [0, load-1]).
600 if (RAND_MAX >= load)
602 // Discard integers in the tail of the random range
603 // that do not distribute evenly modulo the number
604 // of messages.
606 random_int = ACE_OS::rand ();
607 while (random_int >= (int)(RAND_MAX - (RAND_MAX % load)));
609 else if (RAND_MAX < load - 1)
610 // This should only happen for a *very* large messages
611 // relative to the system's representation size.
612 ACE_ERROR_RETURN ((LM_ERROR,
613 ACE_TEXT ("Insufficient range of random numbers")),
614 -1);
615 shuffle_index = random_int % load;
617 // Swap the message at the current index with the one at
618 // the shuffle index.
619 temp_block = supplier_args.array_[i];
620 supplier_args.array_[i] = supplier_args.array_[shuffle_index];
621 supplier_args.array_[shuffle_index] = temp_block;
623 // Swap the time at the current index with the one at
624 // the shuffle index.
625 temp_time = time_offsets [i];
626 time_offsets [i] = time_offsets [shuffle_index];
627 time_offsets [shuffle_index] = temp_time;
629 break;
630 default:
631 ACE_ERROR_RETURN ((LM_ERROR,
632 ACE_TEXT ("unknown test type %d"),
633 test_type),
634 -1);
637 // Set absolute time of deadline associated with each message.
638 current_time = ACE_OS::gettimeofday ();
640 for (i = 0; i < load; ++i)
641 supplier_args.array_[i]->msg_deadline_time (time_offsets [i] + current_time);
643 // Run the performance test producer and consumer on the static
644 // queue.
645 supplier_args.queue_ = static_queue;
646 performance_producer (&supplier_args);
647 consumer_args.queue_ = static_queue;
648 performance_consumer (&consumer_args);
650 // Add a comma delimiter for most recent outputs.
651 ACE_DEBUG ((LM_INFO,
652 ACE_TEXT (", ")));
654 // Run the performance test producer and consumer on the
655 // deadline queue.
656 supplier_args.queue_ = deadline_queue;
657 performance_producer (&supplier_args);
658 consumer_args.queue_ = deadline_queue;
659 performance_consumer (&consumer_args);
661 // Add a comma delimiter for most recent outputs.
662 ACE_DEBUG ((LM_INFO,
663 ACE_TEXT (", ")));
665 // Run the performance test producer and consumer on the laxity
666 // queue.
667 supplier_args.queue_ = laxity_queue;
668 performance_producer (&supplier_args);
669 consumer_args.queue_ = laxity_queue;
670 performance_consumer (&consumer_args);
672 // Move to the next line of output.
673 ACE_DEBUG ((LM_INFO,
674 ACE_TEXT ("\n")));
676 delete [] time_offsets;
678 // Free all the allocated message blocks.
679 for (i = 0; i < load; ++i)
680 delete supplier_args.array_[i];
682 // Free the allocated pointer array.
683 delete [] supplier_args.array_;
686 // Free resources and leave.
687 delete static_queue;
688 delete deadline_queue;
689 delete laxity_queue;
690 return 0;
692 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
695 run_main (int, ACE_TCHAR *[])
697 ACE_START_TEST (ACE_TEXT ("Dynamic_Priority_Test"));
699 #if defined (ACE_HAS_TIMED_MESSAGE_BLOCKS)
700 // Enable FIFO scheduling
701 if (ACE_OS::sched_params (
702 ACE_Sched_Params (
703 ACE_SCHED_FIFO,
704 ACE_Sched_Params::priority_min (ACE_SCHED_FIFO),
705 ACE_SCOPE_PROCESS)) != 0)
707 if (ACE_OS::last_error () == EPERM)
708 ACE_DEBUG ((LM_MAX,
709 ACE_TEXT ("user is not superuser, ")
710 ACE_TEXT ("so remain in time-sharing class\n")));
711 else if (ACE_OS::last_error () == ENOTSUP)
712 ACE_DEBUG ((LM_MAX,
713 ACE_TEXT ("process scope scheduling is not available, ")
714 ACE_TEXT ("so remain in time-sharing class\n")));
715 else
716 ACE_ERROR_RETURN ((LM_ERROR,
717 ACE_TEXT ("%n: ACE_OS::sched_params failed\n%a")),
718 -1);
721 // Test factory, static message queue.
722 ACE_Message_Queue<ACE_SYNCH> *test_queue =
723 ACE_Message_Queue_Factory<ACE_SYNCH>::create_static_message_queue (max_queue);
724 ACE_TEST_ASSERT (test_queue != 0);
725 run_order_test (test_queue,
726 send_order,
727 static_receipt_order);
728 delete test_queue;
730 // Test factory, dynamic message queue (deadline strategy).
731 test_queue =
732 ACE_Message_Queue_Factory<ACE_SYNCH>::create_deadline_message_queue (max_queue);
733 ACE_TEST_ASSERT (test_queue != 0);
734 run_order_test (test_queue,
735 send_order,
736 deadline_receipt_order);
737 delete test_queue;
739 // Test factory, dynamic message queue (laxity strategy).
740 test_queue =
741 ACE_Message_Queue_Factory<ACE_SYNCH>::create_laxity_message_queue (max_queue);
742 ACE_TEST_ASSERT (test_queue != 0);
743 run_order_test (test_queue,
744 send_order,
745 laxity_receipt_order);
746 delete test_queue;
748 #if defined (VXWORKS)
749 // test factory for VxWorks message queue.
750 ACE_Message_Queue_Vx *test_queue_vx =
751 ACE_Message_Queue_Factory<ACE_NULL_SYNCH>::create_Vx_message_queue (vx_max_queue,
752 vx_msg_size);
753 ACE_TEST_ASSERT (test_queue_vx != 0);
754 // (TBD - does message receipt order test make any sense for Vx Queue ?
755 // If so, uncomment order test, or if not remove order test, below)
756 // @@ % levine 22 Jul 1998 % It'd be nice to run the test, but:
757 // ACE_Message_Queue_Vx isa
758 // ACE_Message_Queue<ACE_NULL_SYNCH>, not an
759 // ACE_Message_Queue<ACE_MT_SYNCH>, so we're
760 // not type-compatible.
762 // run_order_test (test_queue, send_order, static_receipt_order);
763 delete test_queue_vx;
764 #endif /* VXWORKS */
766 // For each of an increasing number of message loads, run the same
767 // performance test (best case, worst case, and randomized, over
768 // each kind of queue).
769 run_performance_test (MIN_LOAD,
770 MAX_LOAD,
771 LOAD_STEP,
772 BEST);
774 run_performance_test (MIN_LOAD,
775 MAX_LOAD,
776 LOAD_STEP,
777 WORST);
779 run_performance_test (MIN_LOAD,
780 MAX_LOAD,
781 LOAD_STEP,
782 RANDOM);
783 #else
784 ACE_DEBUG ((LM_DEBUG,
785 ACE_TEXT ("ACE is not compiled with ACE_HAS_TIMED_MESSAGE_BLOCKS enabled\n")));
786 #endif /* ACE_HAS_TIMED_MESSAGE_BLOCKS */
788 ACE_END_TEST;
789 return 0;