static void bmk7_execute(void) { uint32_t n; threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread3, NULL); threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()+4, thread3, NULL); threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()+3, thread3, NULL); threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()+2, thread3, NULL); threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()+1, thread3, NULL); n = 0; test_wait_tick(); test_start_timer(1000); do { chSemReset(&sem1, 0); n++; #if defined(SIMULATOR) ChkIntSources(); #endif } while (!test_timer_done); test_terminate_threads(); chSemReset(&sem1, 0); test_wait_threads(); test_print("--- Score : "); test_printn(n); test_print(" reschedules/S, "); test_printn(n * 6); test_println(" ctxswc/S"); }
static void bmk2_execute(void) { uint32_t n; threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread1, NULL); n = msg_loop_test(threads[0]); test_wait_threads(); test_print("--- Score : "); test_printn(n); test_print(" msgs/S, "); test_printn(n << 1); test_println(" ctxswc/S"); }
static FlowPacket * write_to_shunt (FlowShunt *shunt, gpointer data) { FlowPacket *packet; guint pause_ms; if (writes_are_blocked) test_end (TEST_RESULT_FAILED, "got write while blocked"); if (data != shunt) test_end (TEST_RESULT_FAILED, "write callback user_data does not match"); if (finished_writing) test_end (TEST_RESULT_FAILED, "got write callback after sending end-of-stream"); if (src_index == BUFFER_SIZE) { packet = flow_create_simple_event_packet (FLOW_STREAM_DOMAIN, FLOW_STREAM_END); finished_writing = TRUE; flow_shunt_block_writes (shunt); test_print ("Write: End of stream marker\n"); } else { guint len; len = g_random_int_range (PACKET_MIN_SIZE, PACKET_MAX_SIZE + 1); if (src_index + len > BUFFER_SIZE) len = BUFFER_SIZE - src_index; packet = flow_packet_new (FLOW_PACKET_FORMAT_BUFFER, buffer + src_index, len); test_print ("Write: %d byte packet at offset %d\n", len, src_index); src_index += len; } if (!packet) test_end (TEST_RESULT_FAILED, "failed to create a packet"); pause_ms = get_pause_interval_ms (); if (pause_ms > 0) { test_print ("Blocking writes for %.2fs\n", (float) pause_ms / 1000.0); writes_are_blocked = TRUE; flow_shunt_block_writes (shunt); g_timeout_add (pause_ms, (GSourceFunc) write_pause_ended, shunt); } return packet; }
static void resolved (GList *addr_list, GList *name_list, FlowIPResolver *ip_resolver) { GList *l; if (!name_list && addr_list) { for (l = addr_list; l; l = g_list_next (l)) { FlowIPAddr *ip_addr = l->data; gchar *ip_addr_str = flow_ip_addr_get_string (ip_addr); test_print ("%-20.20s -> %s\n", "[NULL]", ip_addr_str); g_free (ip_addr_str); } } else if (name_list && !addr_list) { for (l = name_list; l; l = g_list_next (l)) { gchar *name = l->data; test_print ("%-20.20s -> %s\n", name, "[NULL]"); } } else if (!name_list && !addr_list) { test_end (TEST_RESULT_FAILED, "none-to-none resolution"); } else /* name_list && addr_list */ { for ( ; name_list; name_list = g_list_next (name_list)) { gchar *name = name_list->data; for (l = addr_list; l; l = g_list_next (l)) { FlowIPAddr *ip_addr = l->data; gchar *ip_addr_str = flow_ip_addr_get_string (ip_addr); test_print ("%-20.20s -> %s\n", name, ip_addr_str); g_free (ip_addr_str); } } } to_resolve--; if (!to_resolve) test_quit_main_loop (); }
static void do_test(char *buf, size_t len) { int i, j; char *code; protect_mem(buf, len, ALLOW_READ|ALLOW_WRITE); for (i = 0; i < 7; i++) { for (j = 0; j < 7; j++) { code = copy_to_buf(buf, len, NULL, CODE_INC, COPY_NORMAL); protect_mem_check(buf, len, prot_codes[i], ALLOW_READ|ALLOW_WRITE); protect_mem_check(buf, len, prot_codes[j], prot_codes[i]); test_print(code, 5); test_print(code, 2); if (j > 1 && j < 6) { code = copy_to_buf(buf, len, NULL, CODE_DEC, COPY_NORMAL); test_print(code, 3); test_print(code, 1); code = copy_to_buf(buf, len, NULL, CODE_SELF_MOD, COPY_NORMAL); test_print(code, 43981); test_print(code, 4660); } buf++; len--; if (j > 1 && j < 6) { protect_mem_check(buf, len, ALLOW_READ|ALLOW_WRITE, prot_codes[j]); code = copy_to_buf(buf, len, NULL, CODE_SELF_MOD, COPY_NORMAL); protect_mem_check(buf, len, prot_codes[i], ALLOW_READ|ALLOW_WRITE); protect_mem_check(buf, len, prot_codes[j], prot_codes[i]); test_print(code, 4660); test_print(code, 43981); } protect_mem_check(buf, len, ALLOW_READ|ALLOW_WRITE, prot_codes[j]); } } }
static void bmk13_execute(void) { test_print("--- System: "); test_printn(sizeof(ReadyList) + sizeof(VTList) + PORT_IDLE_THREAD_STACK_SIZE + (sizeof(Thread) + sizeof(struct intctx) + sizeof(struct extctx) + PORT_INT_REQUIRED_STACK) * 2); test_println(" bytes"); test_print("--- Thread: "); test_printn(sizeof(Thread)); test_println(" bytes"); test_print("--- Timer : "); test_printn(sizeof(VirtualTimer)); test_println(" bytes"); #if CH_USE_SEMAPHORES || defined(__DOXYGEN__) test_print("--- Semaph: "); test_printn(sizeof(Semaphore)); test_println(" bytes"); #endif #if CH_USE_EVENTS || defined(__DOXYGEN__) test_print("--- EventS: "); test_printn(sizeof(EventSource)); test_println(" bytes"); test_print("--- EventL: "); test_printn(sizeof(EventListener)); test_println(" bytes"); #endif #if CH_USE_MUTEXES || defined(__DOXYGEN__) test_print("--- Mutex : "); test_printn(sizeof(Mutex)); test_println(" bytes"); #endif #if CH_USE_CONDVARS || defined(__DOXYGEN__) test_print("--- CondV.: "); test_printn(sizeof(CondVar)); test_println(" bytes"); #endif #if CH_USE_QUEUES || defined(__DOXYGEN__) test_print("--- Queue : "); test_printn(sizeof(GenericQueue)); test_println(" bytes"); #endif #if CH_USE_MAILBOXES || defined(__DOXYGEN__) test_print("--- MailB.: "); test_printn(sizeof(Mailbox)); test_println(" bytes"); #endif }
int main(int argc, char **argv) { unif01_Gen *gen; int rc; gen = unif01_CreateExternGenBits("arc4random", arc4random); /* XXX: The following battery does not set pVal, so we cannot check * the results. */ bbattery_FIPS_140_2(gen); /* XXX: The following battery fails one test. */ bbattery_pseudoDIEHARD(gen); test_battery_result(); bbattery_Rabbit(gen, 33554432); test_battery_result(); bbattery_SmallCrush(gen); test_battery_result(); unif01_DeleteExternGenBits(gen); if (test_failed) { test_print("failed tests = %d", test_failed); /* XXX: We should probably FAIL the test, but we currently * have one test always failing. */ rc = TEST_SKIP; } else { rc = TEST_OK; } return rc; }
static void test_battery_result(void) { char **testNames = bbattery_TestNames; double *pVal = bbattery_pVal; double pSuspect = 0.001; test_print("bbattery_NTests = %d", bbattery_NTests); for (int i = 0; i < bbattery_NTests; i++) { /* That test was not done: pVal = -1. */ if (pVal[i] < 0.0) { test_res(i, testNames, pVal, "SKIP"); continue; } /* That test passed or failed. */ if ((pVal[i] >= pSuspect) && (pVal[i] <= 1.0 - pSuspect)) { test_res(i, testNames, pVal, "PASS"); } else { test_res(i, testNames, pVal, "FAIL"); test_failed++; } } }
static void bmk9_execute(void) { uint32_t n; static uint8_t ib[16]; static InputQueue iq; chIQInit(&iq, ib, sizeof(ib), NULL); n = 0; test_wait_tick(); test_start_timer(1000); do { chIQPutI(&iq, 0); chIQPutI(&iq, 1); chIQPutI(&iq, 2); chIQPutI(&iq, 3); (void)chIQGet(&iq); (void)chIQGet(&iq); (void)chIQGet(&iq); (void)chIQGet(&iq); n++; #if defined(SIMULATOR) ChkIntSources(); #endif } while (!test_timer_done); test_print("--- Score : "); test_printn(n * 4); test_println(" bytes/S"); }
static void bmk4_execute(void) { Thread *tp; uint32_t n; tp = threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread4, NULL); n = 0; test_wait_tick(); test_start_timer(1000); do { chSysLock(); chSchWakeupS(tp, RDY_OK); chSchWakeupS(tp, RDY_OK); chSchWakeupS(tp, RDY_OK); chSchWakeupS(tp, RDY_OK); chSysUnlock(); n += 4; #if defined(SIMULATOR) ChkIntSources(); #endif } while (!test_timer_done); chSysLock(); chSchWakeupS(tp, RDY_TIMEOUT); chSysUnlock(); test_wait_threads(); test_print("--- Score : "); test_printn(n * 2); test_println(" ctxswc/S"); }
void test_print(MdsObject* r) { if (!r) { cout << "something error" << endl; return; } switch (r->obj_type) { case Type_Int:{ MdsIntObject* res1 = (MdsIntObject*)r; cout << res1->get_value() << endl; break; } case Type_String:{ MdsStringObject* res2 = (MdsStringObject*)r; cout << res2->get_value() << endl; break; } case Type_List:{ MdsListObject* res3 = (MdsListObject*)r; vector<MdsObject*> vec = res3->get_value(); cout << "[" << endl; for (size_t i = 0; i < vec.size(); i++) { cout << '\t'; test_print(vec[i]); } cout << "]" << endl; break; } } }
static void list_member_print_and_free (gchar *member, gpointer user_data) { test_print (" %s\n", member); g_free (member); }
int main(void) { /* test_guarded_memcpy(); */ test_typesizes(); test_carray_typedef(); printf("per: %d %d file\n", 3, 45); test_sscanf("010.001.001.008"); test_sscanf("10.1.1.8"); test_print(); test_fd(); test_ieee754(); test_stackpp(); test_signs(); test_pathparseSRCV_cstr("gimp-2.0.tar.bz2"); test_pathparseSRCV_cstr("gimp-2.0.1.tar.bz2"); test_pathparseSRCV_cstr("gimp-2.0.1beta1.tar.bz2"); test_pathparseSRCV_cstr("jpegsrc.v6b.tar.bz2"); test_no_branching(); test_binpow(); return 0; }
static void test_get_supported_fields_sync (ETestServerFixture *fixture, gconstpointer user_data) { EBook *book; GList *fields; book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook); fields = ebook_test_utils_book_get_supported_fields (book); test_print ("successfully retrieved supported fields:\n"); g_list_foreach (fields, (GFunc) list_member_print_and_free, NULL); test_print ("----------------\n"); g_list_free (fields); }
/* performance test */ static void BM_sprintf_overhead(benchmark::State& state) { while (state.KeepRunning()) { test_print("BM_sprintf_overhead:%zu", state.iterations()); state.PauseTiming(); logd_yield(); state.ResumeTiming(); } }
void test_print_port_info(void) { #ifdef PORT_COMPILER_NAME test_print("*** Compiler: "); test_println(PORT_COMPILER_NAME); #endif test_print("*** Architecture: "); test_println(PORT_ARCHITECTURE_NAME); #ifdef PORT_CORE_VARIANT_NAME test_print("*** Core Variant: "); test_println(PORT_CORE_VARIANT_NAME); #endif #ifdef PORT_INFO test_print("*** Port Info: "); test_println(PORT_INFO); #endif }
int main(int argc, char **argv) { test_init(); test_print(); return 0; }
static gboolean read_pause_ended (FlowShunt *shunt) { test_print ("Resuming reads\n"); reads_are_blocked = FALSE; flow_shunt_unblock_reads (shunt); return FALSE; }
static gboolean write_pause_ended (FlowShunt *shunt) { test_print ("Resuming writes\n"); writes_are_blocked = FALSE; flow_shunt_unblock_writes (shunt); return FALSE; }
static void contacts_removed (EBookView *book_view, const GList *ids) { GList *l; for (l = (GList*)ids; l; l = l->next) { test_print ("Removed contact: %s\n", (gchar *)l->data); } }
static void print_contact (EContact *contact) { GList *emails, *e; test_print ("Contact: %s\n", (gchar *)e_contact_get_const (contact, E_CONTACT_FULL_NAME)); test_print ("UID: %s\n", (gchar *)e_contact_get_const (contact, E_CONTACT_UID)); test_print ("Email addresses:\n"); emails = e_contact_get (contact, E_CONTACT_EMAIL); for (e = emails; e; e = e->next) { test_print ("\t%s\n", (gchar *)e->data); } g_list_foreach (emails, (GFunc) g_free, NULL); g_list_free (emails); test_print ("\n"); }
void test_exec(t_lst_elem *elem) { t_test *test; test = elem->data; test_exec_do(test); test_print(elem); // usleep(300 * 1000); }
int main() { char str[3][20] = {{"a"}, {"b"}, {"c"}}; int i = 0; for (; i < 3; i++) { printf("i=%d, str_len = %d\n", i, strlen(str[i])); test_print(str[i], strlen(str[i])); } return 0; }
int main() { test_create(1); test_add(2); test_print(3); test_remove(4); test_remove_last_node(); test_remove_first_node(); test_add_with_index(0); test_add_with_index(1); test_add_with_index(2); return 0; }
int main() { struct tnode *root; char node_urls[10][MAX_URL_LENGTH]; int url_frequency[10]; root = NULL; root = add_to_tree(root, "google.com"); root = add_to_tree(root, "google.com"); assert( root->count == 2); root = add_to_tree(root, "amazon.com"); assert(treeprint(0,root,node_urls, url_frequency) == 2); populate_tree("small_url", &root); test_print(root, 7, Expected_URLs_small, Expected_Url_Freq_small); populate_tree("long_url", &root); assert( lookup(root, "vonage.com") == 2323); test_print(root, 10, Expected_URLs, Expected_Url_Freq); return 0; }
static void test_get_static_capabilities_sync (ETestServerFixture *fixture, gconstpointer user_data) { EBook *book; const gchar *caps; book = E_TEST_SERVER_UTILS_SERVICE (fixture, EBook); caps = ebook_test_utils_book_get_static_capabilities (book); test_print ("successfully retrieved static capabilities: '%s'\n", caps); }
int main() { test_print(); test_memory(); test_metrics(); test_find(); test_locate(); fputs("All tests passed\n", stdout); return 0; }
static void get_supported_fields_cb (EBookTestClosure *closure) { /* XXX: assuming an empty list is valid, we'll just print out anything * we do get */ if (closure->list) { EIterator *iter; const gchar *field; test_print ("supported fields:\n"); iter = e_list_get_iterator (closure->list); while ((field = e_iterator_get (iter))) { test_print (" %s\n", field); e_iterator_next (iter); } test_print ("----------------\n"); g_object_unref (closure->list); } g_main_loop_quit ((GMainLoop *) (closure->user_data)); }
static void test_get_alarm_email_address (ETestServerFixture *fixture, gconstpointer user_data) { ECal *cal; gchar *address; cal = E_TEST_SERVER_UTILS_SERVICE (fixture, ECal); address = ecal_test_utils_cal_get_alarm_email_address (cal); test_print ("alarm email address: '%s'\n", address); g_free (address); }
//void test_print (int * A, int size); int main (int argc, char *argv[]) { if (argc !=2) { printf("pass the array size as argument \n"); exit (EXIT_FAILURE); } int size = atoi (argv[1]); int * A = new int [size]; for (int i = 0; i < size; i++) { A[i] = rand()%size; } //test initial array Quicksort * sort = new Quicksort (); test_print (A, 0, size-1); //delare an object of class quicksort sort->Sort(A, 0, size-1); //test final array test_print (A, 0, size-1); }