VALUE run() { test_scgi(); test_yaml_parser(); test_queue(); test_util(); }
int main(void) { LOG_SUITE_START("queue"); test_queue(); return 0; }
void run_tests() { test_entry_expansion(); test_table_expansion(); test_automaton_eval(); test_list(); test_bs_build(); test_stack(); test_queue(); }
int main(int argc, char* argv[]) { if (argc > 1) freq = atol(argv[1]); if (argc > 2) onlinepercent = atol(argv[2]); if (argc > 3) enterpercent = atol(argv[3]); test_queue(); return 0; }
void test_enqueue() { Queue q = new_queue(10); QueueError e = new_queue_error(); QueueOpt opts[] = { { Enqueue, 10 }, }; test_queue(q, e, opts, 1, True); ASSERT(*e == QueueErrorNone); queue_free(q); queue_error_free(e); }
// tests void test_overflow() { Queue q = new_queue(20); QueueError e = new_queue_error(); QueueOpt opts[] = { { Enqueue, 21 }, }; test_queue(q, e, opts, 1, True); ASSERT(*e == QueueErrorOverflow); queue_free(q); queue_error_free(e); }
bool test_all() { printf("Test Stack: %s\n", test_stack()?"PASS":"******"); printf("Test Queue: %s\n", test_queue()?"PASS":"******"); printf("Test List: %s\n", test_list()?"PASS":"******"); printf("Test MinHeap: %s\n",test_minheap()?"PASS":"******"); printf("Test MaxHeap: %s\n",test_maxheap()?"PASS":"******"); printf("Test RedBlack: %s\n", /*test_redblack()*/false?"PASS":"******"); printf("Test BST: %s\n", test_bst()?"PASS":"******"); printf("Test HashTable: %s\n",test_hashtable()?"PASS":"******"); printf("Test Tuple: %s\n",test_tuple()?"PASS":"******"); if(DEBUG)functional_tests(); return 1; }
void test_rotation() { Queue q = new_queue(20); QueueError e = new_queue_error(); QueueOpt opts[] = { { Enqueue, 20 }, { Dequeue, 15 }, { Enqueue, 10 }, { Dequeue, 15 }, // size = 0 }; test_queue(q, e, opts, 4, True); ASSERT(*e == QueueErrorNone); queue_free(q); queue_error_free(e); }
int main() { print_testname("Doubly Linked List"); test_doublylinkedlist(); print_testname("BST"); test_binarysearchtree(); print_testname("Undirected Graph"); test_undirectedgraph(); print_testname("Stack"); test_stack(); print_testname("Queue"); test_queue(); return 0; }
void test_container::TC_04_03() { BOOLEAN ret; UINT32 used; HQConcurrentRingQueue<UINT32> test_queue(QUEUESIZE, 0); HQThread push_thread; HQThread pop_thread; push_thread.Create(push_function, &test_queue); pop_thread.Create(pop_function, &test_queue); push_thread.Destroy(NULL); pop_thread.Destroy(NULL); ret = test_queue.IsFull(); CPPUNIT_ASSERT_EQUAL(TRUE, ret); used = test_queue.GetUsed(); CPPUNIT_ASSERT_EQUAL((UINT32)QUEUESIZE, used); }
void test_container::TC_04_01() { BOOLEAN ret; UINT32 value; HQConcurrentRingQueue<UINT32> test_queue(QUEUESIZE, 0); for (UINT32 i = 0; i < QUEUESIZE; ++i) { ret = test_queue.PushBack(i); CPPUNIT_ASSERT_EQUAL(TRUE, ret); } ret = test_queue.PushBack(100); CPPUNIT_ASSERT_EQUAL(FALSE, ret); for (UINT32 i = 0; i < QUEUESIZE; ++i) { ret = test_queue.PopFront(&value); CPPUNIT_ASSERT(ret == TRUE); CPPUNIT_ASSERT_EQUAL(i, value); } ret = test_queue.PopFront(&value); CPPUNIT_ASSERT(ret == FALSE); }
int main (int , char **) { test_vector (); test_map (); test_integer_vector (); test_double_vector (); test_string_vector (); test_integer (); test_double (); test_map_exchanges (); test_vector_exchanges (); test_native_vectors (); test_queue (); test_vector_transfer (); test_flex_map (); test_collection (); return 0; }
int uORBTest::UnitTest::test() { int ret = test_single(); if (ret != OK) { return ret; } ret = test_multi(); if (ret != OK) { return ret; } ret = test_multi_reversed(); if (ret != OK) { return ret; } ret = test_unadvertise(); if (ret != OK) { return ret; } ret = test_multi2(); if (ret != OK) { return ret; } ret = test_queue(); if (ret != OK) { return ret; } return test_queue_poll_notify(); }
void test_stress() { time_t start, end; unsigned int queue_size = 2*0x0FFFFFFF; Queue q = new_queue(queue_size); QueueError e = new_queue_error(); QueueOpt opts[] = { { Enqueue, queue_size }, { Dequeue, queue_size }, }; time(&start); test_queue(q, e, opts, 2, False); time(&end); double time_diff = difftime(end, start); printf("500 Million int queue+dequeue stress test completed in %.21f seconds\n\n\n", time_diff); queue_free(q); queue_error_free(e); }
void run_test(){ test_scgi(); test_yaml_parser(); test_queue(); test_util(); }
int main(void) { test_queue(); return 0; }
int main(int argc, char *argv[]) { struct mq_attr attr, result; if (argc != 2) { fprintf(stderr, "Must pass a valid queue name\n\n"); fprintf(stderr, usage, argv[0]); exit(1); } if (*argv[1] == '/') queue_path = strdup(argv[1]); else { queue_path = malloc(strlen(argv[1]) + 2); if (!queue_path) { perror("malloc()"); exit(1); } queue_path[0] = '/'; queue_path[1] = 0; strcat(queue_path, argv[1]); } if (getuid() != 0) { fprintf(stderr, "Not running as root, but almost all tests " "require root in order to modify\nsystem settings. " "Exiting.\n"); exit(1); } /* Find out what files there are for us to make tweaks in */ def_msgs = fopen(DEF_MSGS, "r+"); def_msgsize = fopen(DEF_MSGSIZE, "r+"); max_msgs = fopen(MAX_MSGS, "r+"); max_msgsize = fopen(MAX_MSGSIZE, "r+"); if (!max_msgs) shutdown(2, "Failed to open msg_max", __LINE__); if (!max_msgsize) shutdown(2, "Failed to open msgsize_max", __LINE__); if (def_msgs || def_msgsize) default_settings = 1; /* Load up the current system values for everything we can */ getr(RLIMIT_MSGQUEUE, &saved_limits); cur_limits = saved_limits; if (default_settings) { saved_def_msgs = cur_def_msgs = get(def_msgs); saved_def_msgsize = cur_def_msgsize = get(def_msgsize); } saved_max_msgs = cur_max_msgs = get(max_msgs); saved_max_msgsize = cur_max_msgsize = get(max_msgsize); /* Tell the user our initial state */ printf("\nInitial system state:\n"); printf("\tUsing queue path:\t\t%s\n", queue_path); printf("\tRLIMIT_MSGQUEUE(soft):\t\t%d\n", saved_limits.rlim_cur); printf("\tRLIMIT_MSGQUEUE(hard):\t\t%d\n", saved_limits.rlim_max); printf("\tMaximum Message Size:\t\t%d\n", saved_max_msgsize); printf("\tMaximum Queue Size:\t\t%d\n", saved_max_msgs); if (default_settings) { printf("\tDefault Message Size:\t\t%d\n", saved_def_msgsize); printf("\tDefault Queue Size:\t\t%d\n", saved_def_msgs); } else { printf("\tDefault Message Size:\t\tNot Supported\n"); printf("\tDefault Queue Size:\t\tNot Supported\n"); } printf("\n"); validate_current_settings(); printf("Adjusted system state for testing:\n"); printf("\tRLIMIT_MSGQUEUE(soft):\t\t%d\n", cur_limits.rlim_cur); printf("\tRLIMIT_MSGQUEUE(hard):\t\t%d\n", cur_limits.rlim_max); printf("\tMaximum Message Size:\t\t%d\n", cur_max_msgsize); printf("\tMaximum Queue Size:\t\t%d\n", cur_max_msgs); if (default_settings) { printf("\tDefault Message Size:\t\t%d\n", cur_def_msgsize); printf("\tDefault Queue Size:\t\t%d\n", cur_def_msgs); } printf("\n\nTest series 1, behavior when no attr struct " "passed to mq_open:\n"); if (!default_settings) { test_queue(NULL, &result); printf("Given sane system settings, mq_open without an attr " "struct succeeds:\tPASS\n"); if (result.mq_maxmsg != cur_max_msgs || result.mq_msgsize != cur_max_msgsize) { printf("Kernel does not support setting the default " "mq attributes,\nbut also doesn't tie the " "defaults to the maximums:\t\t\tPASS\n"); } else { set(max_msgs, ++cur_max_msgs); set(max_msgsize, ++cur_max_msgsize); test_queue(NULL, &result); if (result.mq_maxmsg == cur_max_msgs && result.mq_msgsize == cur_max_msgsize) printf("Kernel does not support setting the " "default mq attributes and\n" "also ties system wide defaults to " "the system wide maximums:\t\t" "FAIL\n"); else printf("Kernel does not support setting the " "default mq attributes,\n" "but also doesn't tie the defaults to " "the maximums:\t\t\tPASS\n"); } } else { printf("Kernel supports setting defaults separately from " "maximums:\t\tPASS\n"); /* * While we are here, go ahead and test that the kernel * properly follows the default settings */ test_queue(NULL, &result); printf("Given sane values, mq_open without an attr struct " "succeeds:\t\tPASS\n"); if (result.mq_maxmsg != cur_def_msgs || result.mq_msgsize != cur_def_msgsize) printf("Kernel supports setting defaults, but does " "not actually honor them:\tFAIL\n\n"); else { set(def_msgs, ++cur_def_msgs); set(def_msgsize, ++cur_def_msgsize); /* In case max was the same as the default */ set(max_msgs, ++cur_max_msgs); set(max_msgsize, ++cur_max_msgsize); test_queue(NULL, &result); if (result.mq_maxmsg != cur_def_msgs || result.mq_msgsize != cur_def_msgsize) printf("Kernel supports setting defaults, but " "does not actually honor them:\t" "FAIL\n"); else printf("Kernel properly honors default setting " "knobs:\t\t\t\tPASS\n"); } set(def_msgs, cur_max_msgs + 1); cur_def_msgs = cur_max_msgs + 1; set(def_msgsize, cur_max_msgsize + 1); cur_def_msgsize = cur_max_msgsize + 1; if (cur_def_msgs * (cur_def_msgsize + 2 * sizeof(void *)) >= cur_limits.rlim_cur) { cur_limits.rlim_cur = (cur_def_msgs + 2) * (cur_def_msgsize + 2 * sizeof(void *)); cur_limits.rlim_max = 2 * cur_limits.rlim_cur; setr(RLIMIT_MSGQUEUE, &cur_limits); } if (test_queue_fail(NULL, &result)) { if (result.mq_maxmsg == cur_max_msgs && result.mq_msgsize == cur_max_msgsize) printf("Kernel properly limits default values " "to lesser of default/max:\t\tPASS\n"); else printf("Kernel does not properly set default " "queue parameters when\ndefaults > " "max:\t\t\t\t\t\t\t\tFAIL\n"); } else printf("Kernel fails to open mq because defaults are " "greater than maximums:\tFAIL\n"); set(def_msgs, --cur_def_msgs); set(def_msgsize, --cur_def_msgsize); cur_limits.rlim_cur = cur_limits.rlim_max = cur_def_msgs * cur_def_msgsize; setr(RLIMIT_MSGQUEUE, &cur_limits); if (test_queue_fail(NULL, &result)) printf("Kernel creates queue even though defaults " "would exceed\nrlimit setting:" "\t\t\t\t\t\t\t\tFAIL\n"); else printf("Kernel properly fails to create queue when " "defaults would\nexceed rlimit:" "\t\t\t\t\t\t\t\tPASS\n"); } /* * Test #2 - open with an attr struct that exceeds rlimit */ printf("\n\nTest series 2, behavior when attr struct is " "passed to mq_open:\n"); cur_max_msgs = 32; cur_max_msgsize = cur_limits.rlim_max >> 4; set(max_msgs, cur_max_msgs); set(max_msgsize, cur_max_msgsize); attr.mq_maxmsg = cur_max_msgs; attr.mq_msgsize = cur_max_msgsize; if (test_queue_fail(&attr, &result)) printf("Queue open in excess of rlimit max when euid = 0 " "succeeded:\t\tFAIL\n"); else printf("Queue open in excess of rlimit max when euid = 0 " "failed:\t\tPASS\n"); attr.mq_maxmsg = cur_max_msgs + 1; attr.mq_msgsize = 10; if (test_queue_fail(&attr, &result)) printf("Queue open with mq_maxmsg > limit when euid = 0 " "succeeded:\t\tPASS\n"); else printf("Queue open with mq_maxmsg > limit when euid = 0 " "failed:\t\tFAIL\n"); attr.mq_maxmsg = 1; attr.mq_msgsize = cur_max_msgsize + 1; if (test_queue_fail(&attr, &result)) printf("Queue open with mq_msgsize > limit when euid = 0 " "succeeded:\t\tPASS\n"); else printf("Queue open with mq_msgsize > limit when euid = 0 " "failed:\t\tFAIL\n"); attr.mq_maxmsg = 65536; attr.mq_msgsize = 65536; if (test_queue_fail(&attr, &result)) printf("Queue open with total size > 2GB when euid = 0 " "succeeded:\t\tFAIL\n"); else printf("Queue open with total size > 2GB when euid = 0 " "failed:\t\t\tPASS\n"); seteuid(99); attr.mq_maxmsg = cur_max_msgs; attr.mq_msgsize = cur_max_msgsize; if (test_queue_fail(&attr, &result)) printf("Queue open in excess of rlimit max when euid = 99 " "succeeded:\t\tFAIL\n"); else printf("Queue open in excess of rlimit max when euid = 99 " "failed:\t\tPASS\n"); attr.mq_maxmsg = cur_max_msgs + 1; attr.mq_msgsize = 10; if (test_queue_fail(&attr, &result)) printf("Queue open with mq_maxmsg > limit when euid = 99 " "succeeded:\t\tFAIL\n"); else printf("Queue open with mq_maxmsg > limit when euid = 99 " "failed:\t\tPASS\n"); attr.mq_maxmsg = 1; attr.mq_msgsize = cur_max_msgsize + 1; if (test_queue_fail(&attr, &result)) printf("Queue open with mq_msgsize > limit when euid = 99 " "succeeded:\t\tFAIL\n"); else printf("Queue open with mq_msgsize > limit when euid = 99 " "failed:\t\tPASS\n"); attr.mq_maxmsg = 65536; attr.mq_msgsize = 65536; if (test_queue_fail(&attr, &result)) printf("Queue open with total size > 2GB when euid = 99 " "succeeded:\t\tFAIL\n"); else printf("Queue open with total size > 2GB when euid = 99 " "failed:\t\t\tPASS\n"); shutdown(0,"",0); }