void *thread_main(void *arg) { int flag_iter; thread_data_t *td = (thread_data_t*) arg; myxml_node_t *tuning_root, *temp, *temp2; char buffer[100]; int skip_msg_printed = 0; #if GASNET_PAR int i; gasnet_image_t *imagearray = test_malloc(nodes * sizeof(gasnet_image_t)); for (i=0; i<nodes; ++i) { imagearray[i] = threads_per_node; } gasnet_coll_init(imagearray, td->mythread, NULL, 0, 0); test_free(imagearray); #else gasnet_coll_init(NULL, td->mythread, NULL, 0, 0); #endif return 0; #if 0 COLL_BARRIER(); tuning_root = myxml_createNode(NULL, (char*) "machine", (char*)"CONFIG", (char*) GASNET_CONFIG_STRING, NULL); temp = myxml_createNodeInt(tuning_root, (char*)"num_nodes", (char*)"val", nodes, NULL); temp = myxml_createNodeInt(temp, (char*)"threads_per_node", (char*)"val", threads_per_node, NULL); for(flag_iter=0; flag_iter<9; flag_iter++) { int flags; myxml_node_t *sync_node, *test_root; char buffer[8]; COLL_BARRIER(); switch(flag_iter) { case 0: flags = GASNET_COLL_IN_NOSYNC | GASNET_COLL_OUT_NOSYNC; break; case 1: flags = GASNET_COLL_IN_NOSYNC | GASNET_COLL_OUT_MYSYNC; break; case 2: flags = GASNET_COLL_IN_NOSYNC | GASNET_COLL_OUT_ALLSYNC; break; case 3: flags = GASNET_COLL_IN_MYSYNC | GASNET_COLL_OUT_NOSYNC; break; case 4: flags = GASNET_COLL_IN_MYSYNC | GASNET_COLL_OUT_MYSYNC; break; case 5: flags = GASNET_COLL_IN_MYSYNC | GASNET_COLL_OUT_ALLSYNC; break; case 6: flags = GASNET_COLL_IN_ALLSYNC | GASNET_COLL_OUT_NOSYNC; break; case 7: flags = GASNET_COLL_IN_ALLSYNC | GASNET_COLL_OUT_MYSYNC; break; case 8: flags = GASNET_COLL_IN_ALLSYNC | GASNET_COLL_OUT_ALLSYNC; break; default: continue; } sync_node = myxml_createNode(temp, (char*)"sync_mode", (char*)"val", fill_flag_str(flags, buffer), NULL); /*do single addr tests*/ if (!TEST_ALIGNED_SEGMENTS()) { if(td->mythread == 0 && !skip_msg_printed) MSG0("Skipping SINGLE/SINGLE (unaligned segments)"); } else if(threads_per_node != 1) { if(td->mythread == 0 && !skip_msg_printed) MSG0("skipping SINGLE/SINGLE (multiple threads per node)"); } else { /*call the single address (coll single) test routines with testroot*/ run_SINGLE_tree_tests(td, all_dsts, all_srcs, 0, flags | GASNET_COLL_SINGLE, sync_node); } #endif if(threads_per_node == 1) { /*call the single address (coll local) test routines with testroot*/ run_SINGLE_tree_tests(td, all_dsts, all_srcs, 0, flags | GASNET_COLL_LOCAL, sync_node); } else { if(td->mythread == 0 && !skip_msg_printed) MSG0("skipping SINGLE/LOCAL (multiple threads per node) (test unimplemetned for now)"); } skip_msg_printed = 1; /*do multi addr tests*/ #if GASNET_ALIGNED_SEGMENTS /* Why this conditional? -PHH */ if(threads_per_node > 1) #endif { /*call the multi address test (coll single) routines with testroot*/ run_MULTI_tree_tests(td, all_dsts, all_srcs, 0, flags | GASNET_COLL_SINGLE, sync_node); /*call the multi address test (coll local) routines with testroot*/ run_MULTI_tree_tests(td, my_dsts, my_srcs, 0, flags | GASNET_COLL_LOCAL, sync_node); } } if(td->mythread==0) MSG0("starting dump of tuning data"); if(td->mythread == 0){ FILE *outstream=fopen(outputfile, "w"); myxml_printTreeBIN(outstream, tuning_root); fclose(outstream); /* myxml_printTreeXML(stdout, tuning_root, " "); */ fflush(stdout); fflush(stdout); } if(td->mythread==0) MSG0("tuning data dumped"); COLL_BARRIER(); return 0; #endif }
static gpointer worker (gpointer d) { struct _threadinfo *info = d; gint i, j, id = info->id; gchar *sub, *content; GPtrArray *res; CamelMimeMessage *msg; GError *error = NULL; /* we add a message, search for it, twiddle some flags, delete it */ /* and flat out */ for (i = 0; i < MAX_MESSAGES; i++) { test_add_message (info->folder, id + i); sub = g_strdup_printf ("(match-all (header-contains \"subject\" \"message %08x subject\"))", id + i); push ("searching for message %d\n\tusing: %s", id + i, sub); res = camel_folder_search_by_expression (info->folder, sub, NULL, &error); check_msg (error == NULL, "%s", error->message); check_msg (res->len == 1, "res->len = %d", res->len); g_clear_error (&error); pull (); push ("getting message '%s'", res->pdata[0]); msg = camel_folder_get_message_sync ( info->folder, (gchar *) res->pdata[0], NULL, &error); check_msg (error == NULL, "%s", error->message); g_clear_error (&error); pull (); content = g_strdup_printf ("Test message %08x contents\n\n", id + i); push ("comparing content '%s': '%s'", res->pdata[0], content); test_message_compare_content (camel_medium_get_content ((CamelMedium *) msg), content, strlen (content)); test_free (content); pull (); push ("deleting message, cleanup"); j = (100.0 * rand () / (RAND_MAX + 1.0)); if (j <= 70) { camel_folder_delete_message (info->folder, res->pdata[0]); } camel_folder_search_free (info->folder, res); res = NULL; test_free (sub); check_unref (msg, 1); pull (); /* about 1-in 100 calls will expunge */ j = (200.0 * rand () / (RAND_MAX + 1.0)); if (j <= 2) { push ("expunging folder"); camel_folder_expunge_sync (info->folder, NULL, &error); check_msg (error == NULL, "%s", error->message); pull (); } } return info; }
int main(int argc, char **argv) { int i,j; static uint8_t *A, *B; thread_data_t *td_arr; GASNET_Safe(gasnet_init(&argc, &argv)); performance_iters = DEFAULT_PERFORMANCE_ITERS; for(i=1; i<argc; i++) { if(strcmp("-i", argv[i])==0 || strcmp("-iters", argv[i])==0) { performance_iters = atoi(argv[i+1]); i++; } else if(strcmp("-f", argv[i])==0 || strcmp("-tune-file", argv[i])==0) { outputfile = test_malloc(strlen(argv[i+1])+1); strcpy(outputfile, argv[i+1]); i++; } else if(strcmp("-p", argv[i])==0 || strcmp("-profile", argv[i])==0) { profile_file = test_malloc(strlen(argv[i+1])+1); strcpy(profile_file, argv[i+1]); i++; } else if(strcmp("-h", argv[i])==0 || strcmp("-help", argv[i])==0) { MSG0("usage: %s (-i iters) (-f output file)\n", argv[0]); gasnet_exit(0); } } max_data_size = 0; threads_per_node = 0; profile_info = load_file(profile_file); fill_meta_data(profile_info); printf("data loaded: %d %d\n", (int)max_data_size, threads_per_node); if(max_data_size <=0) { fprintf(stderr, "max data size(%d) should be >=0\n", (int) max_data_size); gasnet_exit(1); } if(threads_per_node<1) { fprintf(stderr, "threads_per_node (%d) should be > 0\n", threads_per_node); gasnet_exit(1); } if(performance_iters <=0) { gasnet_exit(0); } mynode = gasnet_mynode(); nodes = gasnet_nodes(); THREADS = nodes * threads_per_node; GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); /* ?? test_init("testcolltuner",0,"(-i iters) (-f output_file)"); */ A = TEST_MYSEG(); B = A+(SEG_PER_THREAD*threads_per_node); my_srcs = (uint8_t**) test_malloc(sizeof(uint8_t*)*threads_per_node); my_dsts = (uint8_t**) test_malloc(sizeof(uint8_t*)*threads_per_node); all_srcs = (uint8_t**) test_malloc(sizeof(uint8_t*)*THREADS); all_dsts = (uint8_t**) test_malloc(sizeof(uint8_t*)*THREADS); td_arr = (thread_data_t*) test_malloc(sizeof(thread_data_t)*threads_per_node); TEST_SET_WAITMODE(threads_per_node); for(i=0; i<threads_per_node; i++) { my_srcs[i] = A + i*SEG_PER_THREAD; my_dsts[i] = B + i*SEG_PER_THREAD; td_arr[i].my_local_thread = i; td_arr[i].mythread = mynode*threads_per_node+i; td_arr[i].mysrc = my_srcs[i]; td_arr[i].mydest = my_dsts[i]; } for(i=0; i<nodes; i++) { /* assert_always(TEST_SEG(i).size >= SEG_PER_THREAD*threads_per_node); */ for(j=0; j<threads_per_node; j++) { all_srcs[i*threads_per_node+j] = (uint8_t*) TEST_SEG(i) + j*SEG_PER_THREAD; all_dsts[i*threads_per_node+j] = (uint8_t*) TEST_SEG(i) + SEG_PER_THREAD*threads_per_node + j*SEG_PER_THREAD; } } #if GASNET_PAR test_createandjoin_pthreads(threads_per_node, &thread_main, td_arr, sizeof(thread_data_t)); #else thread_main(&td_arr[0]); #endif test_free(td_arr); BARRIER(); gasnet_exit(0); return 0; }
int main(int argc, char **argv) { for (size_t i = 0; i < 128; i++) { test_class(PN_OBJECT, i); test_class(PN_VOID, i); test_class(&noop_class, i); } for (size_t i = 0; i < 128; i++) { test_new(i, PN_OBJECT); test_new(i, &noop_class); } test_finalize(); test_free(); test_hashcode(); test_compare(); for (int i = 0; i < 1024; i++) { test_refcounting(i); } for (size_t i = 0; i < 4; i++) { test_list(i); } for (size_t i = 0; i < 4; i++) { test_list_refcount(i); } test_list_index(); test_map(); test_map_links(); test_hash(); test_string(NULL); test_string(""); test_string("this is a test"); test_string("012345678910111213151617181920212223242526272829303132333435363" "738394041424344454647484950515253545556575859606162636465666768"); test_string("this has an embedded \000 in it"); test_stringn("this has an embedded \000 in it", 28); test_string_format(); test_string_addf(); test_build_list(); test_build_map(); test_build_map_odd(); for (int i = 0; i < 64; i++) { test_map_iteration(i); } test_list_inspect(); test_map_inspect(); test_list_compare(); test_iterator(); for (int seed = 0; seed < 64; seed++) { for (int size = 1; size <= 64; size++) { test_heap(seed, size); } } return 0; }
gint main (gint argc, gchar **argv) { CamelSession *session; gint i, j, index; gchar *path; CamelStore *store; CamelService *service; GThread *threads[MAX_THREADS]; struct _threadinfo *info; CamelFolder *folder; GPtrArray *uids; GError *error = NULL; camel_test_init (argc, argv); camel_test_provider_init (1, local_drivers); /* clear out any camel-test data */ system ("/bin/rm -rf /tmp/camel-test"); session = camel_test_session_new ("/tmp/camel-test"); for (j = 0; j < G_N_ELEMENTS (local_providers); j++) { for (index = 0; index < 2; index++) { gchar *uid; path = g_strdup_printf ("method %s %s", local_providers[j], index?"indexed":"nonindexed"); camel_test_start (path); test_free (path); push ("trying %s index %d", local_providers[j], index); uid = g_strdup_printf ("test-uid-%d", j); path = g_strdup_printf ("%s:///tmp/camel-test/%s", local_providers[j], local_providers[j]); service = camel_session_add_service ( session, uid, path, CAMEL_PROVIDER_STORE, &error); g_free (uid); check_msg (error == NULL, "%s", error->message); check (CAMEL_IS_STORE (service)); store = CAMEL_STORE (service); test_free (path); if (index == 0) folder = camel_store_get_folder_sync ( store, "testbox", CAMEL_STORE_FOLDER_CREATE, NULL, &error); else folder = camel_store_get_folder_sync ( store, "testbox", CAMEL_STORE_FOLDER_CREATE | CAMEL_STORE_FOLDER_BODY_INDEX, NULL, &error); check_msg (error == NULL, "%s", error->message); g_clear_error (&error); for (i = 0; i < MAX_THREADS; i++) { GError *error = NULL; info = g_malloc (sizeof (*info)); info->id = i * MAX_MESSAGES; info->folder = folder; threads[i] = g_thread_new (NULL, worker, info); } for (i = 0; i < MAX_THREADS; i++) { if (threads[i]) { info = g_thread_join (threads[i]); g_free (info); } } pull (); push ("deleting remaining messages"); uids = camel_folder_get_uids (folder); for (i = 0; i < uids->len; i++) { camel_folder_delete_message (folder, uids->pdata[i]); } camel_folder_free_uids (folder, uids); camel_folder_expunge_sync (folder, NULL, &error); check_msg (error == NULL, "%s", error->message); check_unref (folder, 1); camel_store_delete_folder_sync ( store, "testbox", NULL, &error); check_msg (error == NULL, "%s", error->message); g_clear_error (&error); check_unref (store, 1); pull (); camel_test_end (); } } g_object_unref (session); return 0; }
void destroy_key_values(void **state) { test_free(*state); set_key_values(NULL, 0); }
int main(int argc, char **argv) { CamelSession *session; CamelStore *store; CamelException *ex; CamelFolder *folder; CamelMimeMessage *msg; int i, j; CamelStream *mbox; CamelFilterDriver *driver; camel_test_init(argc, argv); camel_test_provider_init(1, local_drivers); ex = camel_exception_new(); /* clear out any camel-test data */ system("/bin/rm -rf /tmp/camel-test"); camel_test_start("Simple filtering of mbox"); session = camel_test_session_new ("/tmp/camel-test"); /* todo: cross-check everything with folder_info checks as well */ /* todo: work out how to do imap/pop/nntp tests */ push("getting store"); store = camel_session_get_store(session, "mbox:///tmp/camel-test/mbox", ex); check_msg(!camel_exception_is_set(ex), "getting store: %s", camel_exception_get_description(ex)); check(store != NULL); pull(); push("Creating output folders"); for (i=0; i<ARRAY_LEN(mailboxes); i++) { push("creating %s", mailboxes[i].name); mailboxes[i].folder = folder = camel_store_get_folder(store, mailboxes[i].name, CAMEL_STORE_FOLDER_CREATE, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); check(folder != NULL); /* we need an empty folder for this to work */ test_folder_counts(folder, 0, 0); pull(); } pull(); /* append a bunch of messages with specific content */ push("creating 100 test message mbox"); mbox = camel_stream_fs_new_with_name("/tmp/camel-test/inbox", O_WRONLY|O_CREAT|O_EXCL, 0600); for (j=0; j<100; j++) { char *content, *subject; push("creating test message"); msg = test_message_create_simple(); content = g_strdup_printf("data%d content\n", j); test_message_set_content_simple((CamelMimePart *)msg, 0, "text/plain", content, strlen(content)); test_free(content); subject = g_strdup_printf("Test%d message%d subject", j, 100-j); camel_mime_message_set_subject(msg, subject); camel_mime_message_set_date(msg, j*60*24, 0); pull(); camel_stream_printf(mbox, "From \n"); check(camel_data_wrapper_write_to_stream((CamelDataWrapper *)msg, mbox) != -1); #if 0 push("appending simple message %d", j); camel_folder_append_message(folder, msg, NULL, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); pull(); #endif test_free(subject); check_unref(msg, 1); } check(camel_stream_close(mbox) != -1); check_unref(mbox, 1); pull(); push("Building filters"); driver = camel_filter_driver_new(session); camel_filter_driver_set_folder_func(driver, get_folder, NULL); for (i=0; i<ARRAY_LEN(rules); i++) { camel_filter_driver_add_rule(driver, rules[i].name, rules[i].match, rules[i].action); } pull(); push("Executing filters"); camel_filter_driver_set_default_folder(driver, mailboxes[0].folder); camel_filter_driver_filter_mbox(driver, "/tmp/camel-test/inbox", NULL, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); /* now need to check the folder counts/etc */ check_unref(driver, 1); pull(); /* this tests that invalid rules are caught */ push("Testing broken match rules"); for (i=0; i<ARRAY_LEN(brokens); i++) { push("rule %s", brokens[i].match); driver = camel_filter_driver_new(session); camel_filter_driver_set_folder_func(driver, get_folder, NULL); camel_filter_driver_add_rule(driver, brokens[i].name, brokens[i].match, brokens[i].action); camel_filter_driver_filter_mbox(driver, "/tmp/camel-test/inbox", NULL, ex); check(camel_exception_is_set(ex)); camel_exception_clear(ex); check_unref(driver, 1); pull(); } pull(); push("Testing broken action rules"); for (i=0; i<ARRAY_LEN(brokena); i++) { push("rule %s", brokena[i].action); driver = camel_filter_driver_new(session); camel_filter_driver_set_folder_func(driver, get_folder, NULL); camel_filter_driver_add_rule(driver, brokena[i].name, brokena[i].match, brokena[i].action); camel_filter_driver_filter_mbox(driver, "/tmp/camel-test/inbox", NULL, ex); check(camel_exception_is_set(ex)); camel_exception_clear(ex); check_unref(driver, 1); pull(); } pull(); for (i=0; i<ARRAY_LEN(mailboxes); i++) { check_unref(mailboxes[i].folder, 1); } check_unref(store, 1); check_unref(session, 1); camel_exception_free(ex); camel_test_end(); return 0; }
static void do_test (int argc, char *argv[]) { int rc; KEYDB_HANDLE hd1, hd2; KEYDB_SEARCH_DESC desc1, desc2; KBNODE kb1, kb2, p; char *uid1; char *uid2; char *fname; (void) argc; (void) argv; fname = prepend_srcdir ("t-keydb-keyring.kbx"); rc = keydb_add_resource (fname, 0); test_free (fname); if (rc) ABORT ("Failed to open keyring."); hd1 = keydb_new (); if (!hd1) ABORT (""); hd2 = keydb_new (); if (!hd2) ABORT (""); rc = classify_user_id ("2689 5E25 E844 6D44 A26D 8FAF 2F79 98F3 DBFC 6AD9", &desc1, 0); if (rc) ABORT ("Failed to convert fingerprint for DBFC6AD9"); rc = keydb_search (hd1, &desc1, 1, NULL); if (rc) ABORT ("Failed to lookup key associated with DBFC6AD9"); classify_user_id ("8061 5870 F5BA D690 3336 86D0 F2AD 85AC 1E42 B367", &desc2, 0); if (rc) ABORT ("Failed to convert fingerprint for 1E42B367"); rc = keydb_search (hd2, &desc2, 1, NULL); if (rc) ABORT ("Failed to lookup key associated with 1E42B367"); rc = keydb_get_keyblock (hd2, &kb2); if (rc) ABORT ("Failed to get keyblock for 1E42B367"); rc = keydb_get_keyblock (hd1, &kb1); if (rc) ABORT ("Failed to get keyblock for DBFC6AD9"); p = kb1; while (p && p->pkt->pkttype != PKT_USER_ID) p = p->next; if (! p) ABORT ("DBFC6AD9 has no user id packet"); uid1 = p->pkt->pkt.user_id->name; p = kb2; while (p && p->pkt->pkttype != PKT_USER_ID) p = p->next; if (! p) ABORT ("1E42B367 has no user id packet"); uid2 = p->pkt->pkt.user_id->name; if (verbose) { printf ("user id for DBFC6AD9: %s\n", uid1); printf ("user id for 1E42B367: %s\n", uid2); } TEST_P ("cache consistency", strcmp (uid1, uid2) != 0); release_kbnode (kb1); release_kbnode (kb2); keydb_release (hd1); keydb_release (hd2); }
int main(int argc, char **argv) { int i = 0; thread_data_t *td_arr; GASNET_Safe(gasnet_init(&argc, &argv)); GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); mynode = gasnet_mynode(); nodes = gasnet_nodes(); if (argc > 1) iters = atoi(argv[1]); if (!iters) iters = 10000; #if GASNET_PAR test_init("testteambarrier", 2, "(iters) (threadcount) (test sections)"); if (argc > 2) { threads_per_node = atoi(argv[2]); } else { if (gasnett_getenv_yesno_withdefault("GASNET_TEST_POLITE_SYNC",0)) { /* May overcommit only if somebody already expected it */ threads_per_node = gasnett_cpu_count(); } else { threads_per_node = gasnett_cpu_count() / TEST_LOCALPROCS(); } threads_per_node = MIN(threads_per_node, 8); threads_per_node = test_thread_limit(threads_per_node); threads_per_node = MAX(threads_per_node, 1); } if (threads_per_node > TEST_MAXTHREADS || threads_per_node < 1) { printf("ERROR: Threads must be between 1 and %d\n", TEST_MAXTHREADS); exit(EXIT_FAILURE); } if (argc > 3) TEST_SECTION_PARSE(argv[3]); if (argc > 4) test_usage(); #else test_init("testteambarrier", 1, "(iters) (test sections)"); threads_per_node = 1; if (argc > 3) test_usage(); if (argc > 2) TEST_SECTION_PARSE(argv[2]); #endif TEST_SET_WAITMODE(threads_per_node); td_arr = (thread_data_t*) test_malloc(sizeof(thread_data_t)*threads_per_node); for(i=0; i<threads_per_node; i++) { td_arr[i].my_local_thread = i; td_arr[i].mythread = mynode*threads_per_node+i; } #if GASNET_PAR test_createandjoin_pthreads(threads_per_node, &thread_main, td_arr, sizeof(thread_data_t)); #else thread_main(&td_arr[0]); #endif test_free(td_arr); gasnet_coll_barrier_notify(GASNET_TEAM_ALL, 0, GASNET_BARRIERFLAG_ANONYMOUS); GASNET_Safe(gasnet_coll_barrier_wait(GASNET_TEAM_ALL, 0, GASNET_BARRIERFLAG_ANONYMOUS)); MSG("done."); gasnet_exit(0); return 0; }
int main(int argc, char **argv) { int iters = 0; int arg; void *myseg; int firstlastmode = 0; int fullduplexmode = 0; int crossmachinemode = 0; int skipwarmup = 0; int help = 0; /* call startup */ GASNET_Safe(gasnet_init(&argc, &argv)); /* parse arguments */ arg = 1; while (argc > arg) { if (!strcmp(argv[arg], "-f")) { firstlastmode = 1; ++arg; } else if (!strcmp(argv[arg], "-c")) { crossmachinemode = 1; ++arg; } else if (!strcmp(argv[arg], "-a")) { fullduplexmode = 1; ++arg; } else if (!strcmp(argv[arg], "-m")) { unitsMB = 1; ++arg; } else if (!strcmp(argv[arg], "-s")) { skipwarmup = 1; ++arg; } else if (argv[arg][0] == '-') { help = 1; ++arg; } else break; } if (argc > arg) { iters = atoi(argv[arg]); arg++; } if (!iters) iters = 1000; if (argc > arg) { maxsz = atoi(argv[arg]); arg++; } if (!maxsz) maxsz = 1024*1024; /* 1 MB default */ if (argc > arg) { TEST_SECTION_PARSE(argv[arg]); arg++; } #ifdef GASNET_SEGMENT_EVERYTHING if (maxsz > TEST_SEGSZ) { ERR("maxsz must be <= %lu on GASNET_SEGMENT_EVERYTHING",(unsigned long)TEST_SEGSZ); gasnet_exit(1); } #endif GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); test_init("testmemset",1, "[options] (iters) (maxsz) (test_sections)\n" " The -s option skips warm-up iterations\n" " The -m option enables MB/sec units for bandwidth output (MB=2^20 bytes).\n" " The -a option enables full-duplex mode, where all nodes send.\n" " The -c option enables cross-machine pairing, default is nearest neighbor.\n" " The -f option enables 'first/last' mode, where the first/last\n" " nodes communicate with each other, while all other nodes sit idle."); if (help || argc > arg) test_usage(); min_payload = 1; max_payload = maxsz; if (max_payload < min_payload) { ERR("maxsz must be >= %i\n",min_payload); test_usage(); } /* get SPMD info */ myproc = gasnet_mynode(); numprocs = gasnet_nodes(); if (!firstlastmode) { /* Only allow 1 or even number for numprocs */ if (numprocs > 1 && numprocs % 2 != 0) { MSG("WARNING: This test requires a unary or even number of nodes. Test skipped.\n"); gasnet_exit(0); /* exit 0 to prevent false negatives in test harnesses for smp-conduit */ } } /* Setting peer thread rank */ if (firstlastmode) { peerproc = (myproc == 0 ? numprocs-1 : 0); iamsender = (fullduplexmode ? myproc == 0 || myproc == numprocs-1 : myproc == 0); } else if (numprocs == 1) { peerproc = 0; iamsender = 1; } else if (crossmachinemode) { if (myproc < numprocs / 2) { peerproc = myproc + numprocs/2; iamsender = 1; } else { peerproc = myproc - numprocs/2; iamsender = fullduplexmode; } } else { peerproc = (myproc % 2) ? (myproc - 1) : (myproc + 1); iamsender = (fullduplexmode || myproc % 2 == 0); } myseg = TEST_SEG(myproc); tgtmem = TEST_SEG(peerproc); if (myproc == 0) MSG("Running %i iterations of %s%s%smemset for sizes: %i...%i\n", iters, (firstlastmode ? "first/last " : ""), (fullduplexmode ? "full-duplex ": ""), (crossmachinemode ? "cross-machine ": ""), min_payload, max_payload); BARRIER(); if (iamsender && !skipwarmup) { /* pay some warm-up costs */ int i; int warm_iters = MIN(iters, 32767); /* avoid hitting 65535-handle limit */ gasnet_handle_t *h = test_malloc(sizeof(gasnet_handle_t)*warm_iters); for (i = 0; i < warm_iters; i++) { gasnet_memset(peerproc, tgtmem, 0xff, 8); gasnet_memset_nbi(peerproc, tgtmem, 0xff, 8); h[i] = gasnet_memset_nb(peerproc, tgtmem, 0xff, 8); } gasnet_memset(peerproc, tgtmem, 0xff, max_payload); gasnet_wait_syncnb_all(h, warm_iters); gasnet_wait_syncnbi_puts(); test_free(h); } BARRIER(); if (TEST_SECTION_BEGIN_ENABLED()) bulk_test(iters); if (TEST_SECTION_BEGIN_ENABLED()) bulk_test_nbi(iters); if (TEST_SECTION_BEGIN_ENABLED()) bulk_test_nb(iters); BARRIER(); gasnet_exit(0); return 0; }
static void tfree(void * ptr) { test_free(ptr); }
static void test_heap_resize_block(void) { void *p1, *p2, *p3; uintptr_t new_alloc_size = 0; Heap_Block *block = NULL; puts( "run tests for _Heap_Resize_Block()" ); puts( "\tgive a block outside the heap to the function" ); test_heap_init( TEST_DEFAULT_PAGE_SIZE ); p1 = TestHeap.first_block - TEST_DEFAULT_PAGE_SIZE; new_alloc_size = 1; test_simple_resize_block( p1, new_alloc_size, HEAP_RESIZE_FATAL_ERROR ); puts( "\tincrease size"); puts( "\t\tlet the next block be used alredy and try to get a size bigger than the actual block" ); test_heap_init( TEST_DEFAULT_PAGE_SIZE ); p1 = test_alloc_one_page(); rtems_test_assert( p1 ); p2 = test_alloc_one_page(); rtems_test_assert( p2 ); new_alloc_size = 3 * TEST_DEFAULT_PAGE_SIZE / 2; test_simple_resize_block( p1, new_alloc_size, HEAP_RESIZE_UNSATISFIED ); puts( "\t\tnext block not used and try to set the new allocation size between the page-alignments" ); test_heap_init( TEST_DEFAULT_PAGE_SIZE ); p1 = test_alloc_one_page(); new_alloc_size = 3 * TEST_DEFAULT_PAGE_SIZE / 2; test_simple_resize_block( p1, new_alloc_size, HEAP_RESIZE_SUCCESSFUL ); puts( "\t\tlet the block after the next be used and try to allocate more then one pagesize more" ); test_heap_init( TEST_DEFAULT_PAGE_SIZE ); p1 = test_alloc_one_page(); rtems_test_assert( p1 ); p2 = test_alloc_one_page(); rtems_test_assert( p2 ); p3 = test_alloc_one_page(); rtems_test_assert( p3 ); test_free( p2 ); new_alloc_size = 5 * TEST_DEFAULT_PAGE_SIZE / 2; test_simple_resize_block( p1, new_alloc_size, HEAP_RESIZE_UNSATISFIED ); puts( "\ttry to resize to the same size" ); test_heap_init( TEST_DEFAULT_PAGE_SIZE ); p1 = test_alloc_one_page(); block = _Heap_Block_of_alloc_area( (uintptr_t) p1, TestHeap.page_size ); new_alloc_size = _Heap_Block_size( block ); test_simple_resize_block( p1, new_alloc_size, HEAP_RESIZE_SUCCESSFUL ); puts( "\tdecrease size"); puts( "\t\tdecrease a block with two pages to one page" ); test_heap_init( TEST_DEFAULT_PAGE_SIZE ); p1 = test_alloc_two_pages(); new_alloc_size = 1; test_simple_resize_block( p1, new_alloc_size, HEAP_RESIZE_SUCCESSFUL ); puts( "\t\tresize the block to the size 0" ); test_heap_init( TEST_DEFAULT_PAGE_SIZE ); p1 = test_alloc_one_page(); new_alloc_size = 0; test_simple_resize_block( p1, new_alloc_size, HEAP_RESIZE_SUCCESSFUL ); }
static void test_block_alloc( int free_variant, int alloc_variant, uintptr_t alloc_begin, uintptr_t alloc_size ) { void *p1 = NULL; void *p2 = NULL; void *p3 = NULL; uintptr_t size_fresh_heap = 0; uintptr_t pages_per_default_block = 0; uint32_t exp_free_pages = 0; uint32_t exp_free_blocks = 0; uint32_t exp_used_blocks = 0; test_heap_init( TEST_DEFAULT_PAGE_SIZE ); size_fresh_heap = _Heap_Get_size( &TestHeap ); exp_free_pages = size_fresh_heap / TestHeap.page_size; p1 = test_create_used_block(); p2 = test_create_used_block(); p3 = test_create_used_block(); pages_per_default_block = _Heap_Block_size( _Heap_Block_of_alloc_area( (uintptr_t) p1, TestHeap.page_size ) ) / TestHeap.page_size; if (free_variant == 1) { test_free( p1 ); } else if (free_variant == 2) { test_free( p3 ); } else if (free_variant == 3) { test_free( p2 ); test_free( p3 ); } _Heap_Block_allocate( &TestHeap, _Heap_Block_of_alloc_area( (uintptr_t) p2, test_page_size()), alloc_begin, alloc_size ); test_check_alloc_simple( (void *) alloc_begin, alloc_size, 0, 0 ); /* check statistics */ switch( free_variant ) { case 1: exp_free_pages = exp_free_pages - 2 * pages_per_default_block; exp_used_blocks = 2; switch( alloc_variant ) { case 1: /* allocate block full space */ exp_free_blocks = 2; break; case 2: /* allocate block in the middle */ exp_free_pages = exp_free_pages + pages_per_default_block - 1; exp_free_blocks = 3; break; case 3: /* allocate block at the end */ exp_free_pages = exp_free_pages + pages_per_default_block - 2; exp_free_blocks = 2; break; default: /* allocate block at the beginning */ exp_free_pages = exp_free_pages + pages_per_default_block - 1; exp_free_blocks = 3; break; } break; case 2: exp_free_pages = exp_free_pages - 2 * pages_per_default_block; exp_used_blocks = 2; switch( alloc_variant ) { case 1: /* allocate block full space */ exp_free_blocks = 1; break; case 2: /* allocate block in the middle */ exp_free_pages = exp_free_pages + pages_per_default_block - 1; exp_free_blocks = 2; break; case 3: /* allocate block at the end */ exp_free_pages = exp_free_pages + pages_per_default_block - 1; exp_free_blocks = 2; break; default: /* allocate block at the beginning */ exp_free_pages = exp_free_pages + pages_per_default_block - 1; exp_free_blocks = 1; break; } break; case 3: exp_free_pages = exp_free_pages - pages_per_default_block; exp_used_blocks = 2; switch( alloc_variant ) { case 1: /* allocate block full space */ exp_free_pages = exp_free_pages - pages_per_default_block; exp_free_blocks = 1; break; case 2: /* allocate block in the middle */ exp_free_pages = exp_free_pages - 1; exp_free_blocks = 2; break; case 3: /* allocate block at the end */ exp_free_pages = exp_free_pages - 2; exp_free_blocks = 2; break; default: /* allocate block at the beginning */ exp_free_pages = exp_free_pages - 1; exp_free_blocks = 1; break; } break; default: exp_free_pages = exp_free_pages - 3 * pages_per_default_block; exp_used_blocks = 3; switch( alloc_variant ) { case 1: /* allocate block full space */ exp_free_blocks = 1; break; case 2: /* allocate block in the middle */ exp_free_blocks = 3; exp_free_pages = exp_free_pages + pages_per_default_block - 1; break; case 3: /* allocate block at the end */ exp_free_blocks = 2; exp_free_pages = exp_free_pages + pages_per_default_block - 1; break; default: /* allocate block at the beginning */ exp_free_blocks = 2; exp_free_pages = exp_free_pages + pages_per_default_block - 1; } } rtems_test_assert( TestHeap.stats.free_size == exp_free_pages * TestHeap.page_size ); rtems_test_assert( TestHeap.stats.free_blocks == exp_free_blocks ); rtems_test_assert( TestHeap.stats.used_blocks == exp_used_blocks ); }
static void test_heap_allocate(void) { void *p1 = NULL; void *p2 = NULL; void *p3 = NULL; uintptr_t alloc_size = 0; uintptr_t alignment = 0; uintptr_t boundary = 0; uintptr_t page_size = 0; uintptr_t first_page_begin = 0; uintptr_t previous_last_block_begin = 0; uintptr_t previous_last_page_begin = 0; uintptr_t last_block_begin = 0; uintptr_t last_alloc_begin = 0; test_heap_init( TEST_DEFAULT_PAGE_SIZE ); last_block_begin = (uintptr_t) TestHeap.last_block; last_alloc_begin = _Heap_Alloc_area_of_block( TestHeap.last_block ); puts( "run tests for _Heap_Allocate_aligned_with_boundary()"); puts( "\tcheck if NULL will be returned if size causes integer overflow" ); alloc_size = (uintptr_t ) -1; alignment = 0; boundary = 0; test_init_and_alloc( alloc_size, alignment, boundary, NULL ); puts( "\ttry to allocate more space than the one which fits in the boundary" ); alloc_size = 2; alignment = 0; boundary = alloc_size - 1; test_init_and_alloc( alloc_size, alignment, boundary, NULL ); puts( "\tcheck if alignment will be set to page size if only a boundary is given" ); alloc_size = 1; boundary = 1; alignment = 0; p1 = test_init_and_alloc_simple( alloc_size, alignment, boundary ); alignment = test_page_size(); test_init_and_alloc( alloc_size, alignment, boundary, p1 ); puts( "\tcreate a block which is bigger then the first free space" ); alignment = 0; boundary = 0; alloc_size = test_page_size(); p1 = test_init_and_alloc_simple( alloc_size, alignment, boundary ); p2 = test_alloc_simple( alloc_size, alignment, boundary ); rtems_test_assert( p2 ); test_free( p1 ); alloc_size = 2 * alloc_size; p3 = test_alloc_simple( alloc_size, alignment, boundary ); rtems_test_assert( p1 != p3 ); puts( "\tset boundary before allocation begin" ); alloc_size = 1; alignment = 0; boundary = last_alloc_begin - test_page_size(); p1 = test_init_and_alloc_simple( alloc_size, alignment, boundary ); rtems_test_assert( (uintptr_t ) p1 >= boundary ); puts( "\tset boundary between allocation begin and end" ); alloc_size = test_page_size(); alignment = 0; boundary = last_alloc_begin - alloc_size / 2; p1 = test_init_and_alloc_simple( alloc_size, alignment, boundary ); rtems_test_assert( (uintptr_t ) p1 + alloc_size <= boundary ); puts( "\tset boundary after allocation end" ); alloc_size = 1; alignment = 0; boundary = last_alloc_begin; p1 = test_init_and_alloc_simple( alloc_size, alignment, boundary ); rtems_test_assert( (uintptr_t ) p1 + alloc_size < boundary ); puts( "\tset boundary on allocation end" ); alloc_size = TEST_DEFAULT_PAGE_SIZE - HEAP_BLOCK_HEADER_SIZE; alignment = 0; boundary = last_block_begin; p1 = (void *) (last_alloc_begin - TEST_DEFAULT_PAGE_SIZE); test_init_and_alloc( alloc_size, alignment, boundary, p1); puts( "\talign the allocation to different positions in the block header" ); page_size = sizeof(uintptr_t); alloc_size = 1; boundary = 0; test_heap_init( page_size ); /* Force the page size to a small enough value */ TestHeap.page_size = page_size; alignment = first_page_begin - sizeof(uintptr_t); p1 = test_alloc( alloc_size, alignment, boundary, NULL ); first_page_begin = ((uintptr_t) TestHeap.first_block ) + HEAP_BLOCK_HEADER_SIZE; alignment = first_page_begin + sizeof(uintptr_t); p1 = test_alloc( alloc_size, alignment, boundary, NULL ); first_page_begin = ((uintptr_t) TestHeap.first_block ) + HEAP_BLOCK_HEADER_SIZE; alignment = first_page_begin; p1 = test_alloc_simple( alloc_size, alignment, boundary ); puts( "\tallocate last block with different boundarys" ); page_size = TEST_DEFAULT_PAGE_SIZE; test_heap_init( page_size ); previous_last_block_begin = ((uintptr_t) TestHeap.last_block ) - TestHeap.min_block_size; previous_last_page_begin = previous_last_block_begin + HEAP_BLOCK_HEADER_SIZE; alloc_size = TestHeap.page_size - HEAP_BLOCK_HEADER_SIZE; alignment = sizeof(uintptr_t); boundary = 0; p1 = test_alloc( alloc_size, alignment, boundary, (void *) (previous_last_page_begin + sizeof(uintptr_t))); test_heap_init( page_size ); boundary = ((uintptr_t) TestHeap.last_block ); p1 = test_alloc( alloc_size, alignment, boundary, (void *) previous_last_page_begin ); puts( "\tbreak the boundaries and aligns more than one time" ); page_size = CPU_ALIGNMENT * 20; alloc_size = page_size / 4; alignment = page_size / 5; boundary = page_size / 4; test_heap_init( page_size ); p1 = (void *) (_Heap_Alloc_area_of_block( TestHeap.last_block ) - page_size ); test_alloc( alloc_size, alignment, boundary, p1); puts( "\tdifferent combinations, so that there is no valid block at the end" ); page_size = sizeof(uintptr_t); test_heap_init( 0 ); /* Force the page size to a small enough value */ TestHeap.page_size = page_size; alloc_size = 1; alignment = (uintptr_t) TestHeap.last_block; boundary = 0; p1 = test_alloc( alloc_size, alignment, boundary, NULL ); boundary = (uintptr_t) TestHeap.last_block; p1 = test_alloc( alloc_size, alignment, boundary, NULL ); alloc_size = 0; p1 = test_alloc( alloc_size, alignment, boundary, NULL ); alloc_size = 1; alignment = sizeof(uintptr_t); boundary = 0; p1 = test_alloc_simple( alloc_size, alignment, boundary ); puts( "\ttry to create a block, which is not possible because of the alignment and boundary" ); alloc_size = 2; boundary = _Heap_Alloc_area_of_block( TestHeap.first_block ) + _Heap_Block_size( TestHeap.first_block ) / 2; alignment = boundary - 1; p1 = test_init_and_alloc( alloc_size, alignment, boundary, NULL ); alloc_size = 2; alignment = _Heap_Alloc_area_of_block( TestHeap.first_block ); boundary = alignment + 1; p1 = test_init_and_alloc( alloc_size, alignment, boundary, NULL ); }
gint main (gint argc, gchar **argv) { CamelService *service; CamelSession *session; CamelStore *store; CamelFolder *folder; CamelMimeMessage *msg; gint i, j; gint indexed; GPtrArray *uids; GError *error = NULL; camel_test_init (argc, argv); camel_test_provider_init (1, local_drivers); /* clear out any camel-test data */ system ("/bin/rm -rf /tmp/camel-test"); session = camel_test_session_new ("/tmp/camel-test"); /* todo: cross-check everything with folder_info checks as well */ /* todo: work out how to do imap/pop/nntp tests */ /* we iterate over all stores we want to test, with indexing or indexing turned on or off */ for (i = 0; i < G_N_ELEMENTS (stores); i++) { const gchar *name = stores[i]; for (indexed = 0; indexed < 2; indexed++) { gchar *what = g_strdup_printf ("folder search: %s (%sindexed)", name, indexed?"":"non-"); gchar *uid; gint flags; camel_test_start (what); test_free (what); push ("getting store"); uid = g_strdup_printf ("test-uid-%d", i); service = camel_session_add_service ( session, uid, stores[i], CAMEL_PROVIDER_STORE, &error); g_free (uid); check_msg (error == NULL, "adding store: %s", error->message); check (CAMEL_IS_STORE (service)); store = CAMEL_STORE (service); g_clear_error (&error); pull (); push ("creating %sindexed folder", indexed?"":"non-"); if (indexed) flags = CAMEL_STORE_FOLDER_CREATE | CAMEL_STORE_FOLDER_BODY_INDEX; else flags = CAMEL_STORE_FOLDER_CREATE; folder = camel_store_get_folder_sync ( store, "testbox", flags, NULL, &error); check_msg (error == NULL, "%s", error->message); check (folder != NULL); /* we need an empty folder for this to work */ test_folder_counts (folder, 0, 0); g_clear_error (&error); pull (); /* append a bunch of messages with specific content */ push ("appending 100 test messages"); for (j = 0; j < 100; j++) { gchar *content, *subject; push ("creating test message"); msg = test_message_create_simple (); content = g_strdup_printf ("data%d content\n", j); test_message_set_content_simple ( (CamelMimePart *) msg, 0, "text/plain", content, strlen (content)); test_free (content); subject = g_strdup_printf ("Test%d message%d subject", j, 100 - j); camel_mime_message_set_subject (msg, subject); camel_mime_message_set_date (msg, j * 60 * 24, 0); pull (); push ("appending simple message %d", j); camel_folder_append_message_sync ( folder, msg, NULL, NULL, NULL, &error); check_msg (error == NULL, "%s", error->message); g_clear_error (&error); pull (); test_free (subject); check_unref (msg, 1); } pull (); push ("Setting up some flags &c"); uids = camel_folder_get_uids (folder); check (uids->len == 100); for (j = 0; j < 100; j++) { gchar *uid = uids->pdata[j]; if ((j / 13) * 13 == j) { camel_folder_set_message_user_flag (folder, uid, "every13", TRUE); } if ((j / 17) * 17 == j) { camel_folder_set_message_user_flag (folder, uid, "every17", TRUE); } if ((j / 7) * 7 == j) { gchar *tag = g_strdup_printf ("7tag%d", j / 7); camel_folder_set_message_user_tag (folder, uid, "every7", tag); test_free (tag); } if ((j / 11) * 11 == j) { camel_folder_set_message_user_tag (folder, uid, "every11", "11tag"); } } camel_folder_free_uids (folder, uids); pull (); camel_test_nonfatal ("Index not guaranteed to be accurate before sync: should be fixed eventually"); push ("Search before sync"); run_search (folder, 100); pull (); camel_test_fatal (); push ("syncing folder, searching"); camel_folder_synchronize_sync ( folder, FALSE, NULL, NULL); run_search (folder, 100); pull (); push ("syncing wiht expunge, search"); camel_folder_synchronize_sync ( folder, TRUE, NULL, NULL); run_search (folder, 100); pull (); push ("deleting every 2nd message"); uids = camel_folder_get_uids (folder); check (uids->len == 100); for (j = 0; j < uids->len; j+=2) { camel_folder_delete_message (folder, uids->pdata[j]); } camel_folder_free_uids (folder, uids); run_search (folder, 100); push ("syncing"); camel_folder_synchronize_sync ( folder, FALSE, NULL, &error); check_msg (error == NULL, "%s", error->message); run_search (folder, 100); g_clear_error (&error); pull (); push ("expunging"); camel_folder_expunge_sync (folder, NULL, &error); check_msg (error == NULL, "%s", error->message); run_search (folder, 50); g_clear_error (&error); pull (); pull (); push ("closing and re-opening folder"); check_unref (folder, 1); folder = camel_store_get_folder_sync ( store, "testbox", flags & ~(CAMEL_STORE_FOLDER_CREATE), NULL, &error); check_msg (error == NULL, "%s", error->message); check (folder != NULL); g_clear_error (&error); push ("deleting remaining messages"); uids = camel_folder_get_uids (folder); check (uids->len == 50); for (j = 0; j < uids->len; j++) { camel_folder_delete_message (folder, uids->pdata[j]); } camel_folder_free_uids (folder, uids); run_search (folder, 50); push ("syncing"); camel_folder_synchronize_sync ( folder, FALSE, NULL, &error); check_msg (error == NULL, "%s", error->message); run_search (folder, 50); g_clear_error (&error); pull (); push ("expunging"); camel_folder_expunge_sync (folder, NULL, &error); check_msg (error == NULL, "%s", error->message); run_search (folder, 0); g_clear_error (&error); pull (); pull (); check_unref (folder, 1); pull (); push ("deleting test folder, with no messages in it"); camel_store_delete_folder_sync ( store, "testbox", NULL, &error); check_msg (error == NULL, "%s", error->message); g_clear_error (&error); pull (); check_unref (store, 1); camel_test_end (); } } check_unref (session, 1); return 0; }
int main(int argc, char **argv) { int iters = 0; int arg; void *alloc = NULL; int firstlastmode = 0; int fullduplexmode = 0; int crossmachinemode = 0; int singlesender = 0; int help = 0; /* call startup */ GASNET_Safe(gasnet_init(&argc, &argv)); /* parse arguments */ arg = 1; while (argc > arg) { if (!strcmp(argv[arg], "-in")) { insegment = 1; ++arg; } else if (!strcmp(argv[arg], "-out")) { insegment = 0; ++arg; } else if (!strcmp(argv[arg], "-sl")) { ++arg; if (argc > arg) { stridelevels = atoi(argv[arg]); arg++; } else help = 1; } else if (!strcmp(argv[arg], "-mincontig")) { ++arg; if (argc > arg) { min_contig = atoi(argv[arg]); arg++; } else help = 1; } else if (!strcmp(argv[arg], "-maxcontig")) { ++arg; if (argc > arg) { max_contig = atoi(argv[arg]); arg++; } else help = 1; } else if (!strcmp(argv[arg], "-contigfactor")) { ++arg; if (argc > arg) { contigfactor = atoi(argv[arg]); arg++; } else help = 1; } else if (!strcmp(argv[arg], "-mindata")) { ++arg; if (argc > arg) { min_payload = atoi(argv[arg]); arg++; } else help = 1; } else if (!strcmp(argv[arg], "-maxdata")) { ++arg; if (argc > arg) { max_payload = atoi(argv[arg]); arg++; } else help = 1; } else if (!strcmp(argv[arg], "-datafactor")) { ++arg; if (argc > arg) { datafactor = atoi(argv[arg]); arg++; } else help = 1; } else if (!strcmp(argv[arg], "-densitysteps")) { ++arg; if (argc > arg) { densitysteps = atoi(argv[arg]); arg++; } else help = 1; } else if (!strcmp(argv[arg], "-f")) { firstlastmode = 1; ++arg; } else if (!strcmp(argv[arg], "-c")) { crossmachinemode = 1; ++arg; } else if (!strcmp(argv[arg], "-a")) { fullduplexmode = 1; ++arg; } else if (!strcmp(argv[arg], "-p")) { dogets = 0; doputs = 1; ++arg; } else if (!strcmp(argv[arg], "-g")) { dogets = 1; doputs = 0; ++arg; } else if (!strcmp(argv[arg], "-r")) { remotecontig = 1; ++arg; } else if (!strcmp(argv[arg], "-l")) { localcontig = 1; ++arg; } else if (argv[arg][0] == '-') { help = 1; ++arg; } else break; } if (argc > arg) { iters = atoi(argv[arg]); arg++; } if (!iters) iters = 1000; if (argc > arg) { TEST_SECTION_PARSE(argv[arg]); arg++; } if (min_contig && max_contig && min_contig > max_contig) { ERR("min_contig > max_contig"); help = 1; } if (min_payload && max_payload && min_payload > max_payload) { ERR("min_payload > max_payload"); help = 1; } if (min_payload && min_contig && min_payload < min_contig) { ERR("min_payload < min_contig"); help = 1; } if (max_contig && max_payload && max_contig > max_payload) { ERR("max_contig > max_payload"); help = 1; } if (contigfactor < 2) { ERR("contigfactor < 2"); help = 1; } if (datafactor < 2) { ERR("datafactor < 2"); help = 1; } if (!max_payload) max_payload = 2*1024*1024; /* 2 MB default */ #ifdef GASNET_SEGMENT_EVERYTHING maxsz = gasnet_getMaxGlobalSegmentSize(); #else maxsz = 16*1024*1024; #endif max_payload = (int)MIN(maxsz, max_payload); maxsz = MIN(((uint64_t)max_payload) * densitysteps,maxsz); if (!min_contig) min_contig = 8; if (!max_contig) max_contig = MIN(256*1024,max_payload); if (!min_payload) min_payload = min_contig; GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); test_init("testvisperf",1, "[options] (iters) (test_sections)\n" " -p/-g selects puts only or gets only (default is both).\n" " -r/-l selects remotely contiguous or locally contiguous (default is neither).\n" " -mindata/-maxdata <sz> \n" " selects sz as min/max data payload per operation.\n" " -mincontig/-maxcontig <sz> \n" " selects sz as min/max contig size.\n" " -datafactor/-contigfactor <f> \n" " selects f as growth factor for data/contig sizes.\n" " -densitysteps <d> \n" " selects d density steps, inclusive from 100%..100/d%\n" " -sl <n> selects n striding levels (default is 2).\n" " -in/-out selects whether the initiator-side\n" " memory is in the GASNet segment or not (default is not).\n" " -a enables full-duplex mode, where all nodes send.\n" " -c enables cross-machine pairing, default is nearest neighbor.\n" " -f enables 'first/last' mode, where the first/last\n" " nodes communicate with each other, while all other nodes sit idle."); if (help || argc > arg) test_usage(); /* get SPMD info */ myproc = gasnet_mynode(); numprocs = gasnet_nodes(); if (!firstlastmode) { /* Only allow 1 or even number for numprocs */ if (numprocs > 1 && numprocs % 2 != 0) { MSG0("WARNING: This test requires a unary or even number of nodes. Test skipped.\n"); gasnet_exit(0); /* exit 0 to prevent false negatives in test harnesses for smp-conduit */ } } /* Setting peer thread rank */ if (firstlastmode) { peerproc = (myproc == 0 ? numprocs-1 : 0); iamsender = (fullduplexmode ? myproc == 0 || myproc == numprocs-1 : myproc == 0); } else if (numprocs == 1) { peerproc = 0; iamsender = 1; } else if (crossmachinemode) { if (myproc < numprocs / 2) { peerproc = myproc + numprocs/2; iamsender = 1; } else { peerproc = myproc - numprocs/2; iamsender = fullduplexmode; } } else { peerproc = (myproc % 2) ? (myproc - 1) : (myproc + 1); iamsender = (fullduplexmode || myproc % 2 == 0); } singlesender = (numprocs == 1) || ((numprocs == 2 || firstlastmode) && !fullduplexmode); Rbase = TEST_SEG(peerproc); if (insegment) { Lbase = TEST_SEG(myproc); } else { alloc = test_calloc(maxsz+PAGESZ,1); /* use calloc to prevent valgrind warnings */ Lbase = alignup_ptr(alloc, PAGESZ); /* ensure page alignment of base */ } assert(((uintptr_t)Lbase) % PAGESZ == 0); if (myproc == 0) { MSG0("Running %i iterations of %s%s%snon-contiguous put/get%s%s\n local data %s-segment for sizes: %i...%i\n", iters, (firstlastmode ? "first/last " : ""), (fullduplexmode ? "full-duplex ": ""), (crossmachinemode ? "cross-machine ": ""), (remotecontig?"(remotely-contiguous)":""), (localcontig?"(locally-contiguous)":""), insegment ? "in" : "out", min_payload, max_payload); printf("rows are databytes/op : bandwidth values in MB/s\n"); } BARRIER(); { int contigsz; int rawdatasz; int isget; test_vis_t viscat; for (viscat = TEST_V; viscat <= TEST_S; viscat++) { for (isget = 0; isget < 2; isget++) { if (TEST_SECTION_BEGIN_ENABLED()) { if (isget && !dogets) continue; if (!isget && !doputs) continue; if (!dovis[viscat]) continue; for (contigsz = min_contig; contigsz <= max_contig; contigsz *= contigfactor) { int di; size_t lastdatasz = 0; if (contigsz > max_payload) continue; if (!myproc) { printf("\n%c: %s %s CONTIGSZ = %i\n", TEST_SECTION_NAME(), visdesc[(int)viscat], (isget?"GET":"PUT"), contigsz); printf(" density:"); for (di = 0; di < densitysteps; di++) { printf("%8i%%", (int)((densitysteps-di)*100.0/densitysteps)); } printf("\n"); } for (rawdatasz = min_payload; rawdatasz <= max_payload; rawdatasz *= datafactor) { char mystr[255]; size_t datasz = aligndown(rawdatasz,contigsz); if (datasz == lastdatasz) continue; lastdatasz = datasz; if (singlesender) snprintf(mystr, sizeof(mystr), "%8i: ", (int)datasz); else snprintf(mystr, sizeof(mystr), "P%i: %6i: ", myproc, (int)datasz); for (di = 0; di < densitysteps; di++) { gasnett_tick_t begin=0, end=0; size_t Lcnt = (localcontig ? 1 : datasz/contigsz); size_t Rcnt = (remotecontig? 1 : datasz/contigsz); size_t Lsz = datasz/Lcnt; size_t Rsz = datasz/Rcnt; void **Lilist = NULL; void **Rilist = NULL; gasnet_memvec_t *Lvlist = NULL; gasnet_memvec_t *Rvlist = NULL; size_t *Lstrides = NULL; size_t *Rstrides = NULL; size_t *LRcount = NULL; size_t stride = contigsz*(((double)densitysteps)/(densitysteps-di)); if (stride * MAX(Lcnt,Rcnt) > maxsz) { strcat(mystr," - "); continue; } if (iamsender) { /* setup metadata */ switch (viscat) { case TEST_V: Lvlist = make_vlist(Lbase, stride, Lcnt, Lsz); Rvlist = make_vlist(Rbase, stride, Rcnt, Rsz); break; case TEST_I: Lilist = make_ilist(Lbase, stride, Lcnt, Lsz); Rilist = make_ilist(Rbase, stride, Rcnt, Rsz); break; case TEST_S: { size_t chunkcnt = datasz/contigsz; int dim; Lstrides = test_malloc(sizeof(size_t)*stridelevels); Rstrides = test_malloc(sizeof(size_t)*stridelevels); LRcount = test_malloc(sizeof(size_t)*(stridelevels+1)); LRcount[0] = contigsz; Lstrides[0] = (localcontig ? contigsz : stride); Rstrides[0] = (remotecontig ? contigsz : stride); for (dim = 1; dim < stridelevels; dim++) { size_t factor = 1, fi; for (fi = 1; fi <= chunkcnt/(2*(stridelevels-dim)); fi++) /* choose a reasonable factor */ if (chunkcnt/fi*fi == chunkcnt) factor = fi; LRcount[dim] = factor; chunkcnt /= factor; Lstrides[dim] = LRcount[dim]*Lstrides[dim-1]; Rstrides[dim] = LRcount[dim]*Rstrides[dim-1]; } LRcount[stridelevels] = chunkcnt; { size_t tmp = 1; for (dim = 0; dim <= stridelevels; dim++) tmp *= LRcount[dim]; assert(tmp == datasz); } break; } } } #define DOIT(iters) do { \ int i; \ switch (viscat) { \ case TEST_V: \ for (i = 0; i < iters; i++) { \ if (isget) gasnet_getv_nbi_bulk(Lcnt,Lvlist,peerproc,Rcnt,Rvlist); \ else gasnet_putv_nbi_bulk(peerproc,Rcnt,Rvlist,Lcnt,Lvlist); \ } \ break; \ case TEST_I: \ for (i = 0; i < iters; i++) { \ if (isget) gasnet_geti_nbi_bulk(Lcnt,Lilist,Lsz,peerproc,Rcnt,Rilist,Rsz); \ else gasnet_puti_nbi_bulk(peerproc,Rcnt,Rilist,Rsz,Lcnt,Lilist,Lsz); \ } \ break; \ case TEST_S: \ for (i = 0; i < iters; i++) { \ if (isget) gasnet_gets_nbi_bulk(Lbase,Lstrides,peerproc,Rbase,Rstrides, \ LRcount,stridelevels); \ else gasnet_puts_nbi_bulk(peerproc,Rbase,Rstrides,Lbase,Lstrides, \ LRcount,stridelevels); \ } \ break; \ } \ gasnet_wait_syncnbi_all(); \ } while (0) if (iamsender) DOIT(1); /* pay some warm-up costs */ BARRIER(); if (iamsender) { begin = gasnett_ticks_now(); DOIT(iters); end = gasnett_ticks_now(); } BARRIER(); if (iamsender) { char tmp[80]; double secs = gasnett_ticks_to_ns(end - begin)/1.0E9; double dataMB = ((double)datasz) * iters / (1024*1024); snprintf(tmp, sizeof(tmp), " %8.3f", dataMB / secs); strcat(mystr, tmp); } if (Lilist) test_free(Lilist); if (Rilist) test_free(Rilist); if (Lvlist) test_free(Lvlist); if (Rvlist) test_free(Rvlist); if (Lstrides) test_free(Lstrides); if (Rstrides) test_free(Rstrides); if (LRcount) test_free(LRcount); } if (iamsender) { printf("%s\n", mystr); fflush(stdout); } BARRIER(); } } } } } } BARRIER(); if (alloc) test_free(alloc); gasnet_exit(0); return 0; }
/* TODO: Add subscription stuff */ void test_folder_basic (CamelSession *session, const gchar *storename, gint local, gint spool) { CamelStore *store; CamelFolder *folder; gchar *what = g_strdup_printf ("testing store: %s", storename); GError *error = NULL; camel_test_start (what); test_free (what); push ("getting store"); store = camel_session_get_store (session, storename, &error); check_msg (error == NULL, "getting store: %s", error->message); check (store != NULL); g_clear_error (&error); pull (); /* local providers == no inbox */ push ("getting inbox folder"); folder = camel_store_get_inbox_folder_sync (store, NULL, &error); if (local) { /* Well, maildir can have an inbox */ if (folder) { check (error == NULL); check_unref (folder, 1); } else { check (error != NULL); } } else { check_msg (error == NULL, "%s", error->message); check (folder != NULL); check_unref (folder, 2); } g_clear_error (&error); pull (); push ("getting a non-existant folder, no create"); folder = camel_store_get_folder_sync ( store, "unknown", 0, NULL, &error); check (error != NULL); check (folder == NULL); g_clear_error (&error); pull (); if (!spool) { push ("getting a non-existant folder, with create"); folder = camel_store_get_folder_sync ( store, "testbox", CAMEL_STORE_FOLDER_CREATE, NULL, &error); check_msg (error == NULL, "%s", error->message); check (folder != NULL); if (local) check_unref (folder, 1); else check_unref (folder, 2); g_clear_error (&error); pull (); push ("getting an existing folder"); folder = camel_store_get_folder_sync ( store, "testbox", 0, NULL, &error); check_msg (error == NULL, "%s", error->message); check (folder != NULL); if (local) check_unref (folder, 1); else check_unref (folder, 2); g_clear_error (&error); pull (); push ("renaming a non-existant folder"); camel_store_rename_folder_sync ( store, "unknown1", "unknown2", NULL, &error); check (error != NULL); g_clear_error (&error); pull (); push ("renaming an existing folder"); camel_store_rename_folder_sync ( store, "testbox", "testbox2", NULL, &error); check_msg (error == NULL, "%s", error->message); g_clear_error (&error); pull (); push ("opening the old name of a renamed folder"); folder = camel_store_get_folder_sync ( store, "testbox", 0, NULL, &error); check (error != NULL); check (folder == NULL); g_clear_error (&error); pull (); push ("opening the new name of a renamed folder"); folder = camel_store_get_folder_sync ( store, "testbox2", 0, NULL, &error); check_msg (error == NULL, "%s", error->message); check (folder != NULL); if (local) check_unref (folder, 1); else check_unref (folder, 2); pull (); } push ("deleting a non-existant folder"); camel_store_delete_folder_sync (store, "unknown", NULL, &error); check (error != NULL); g_clear_error (&error); pull (); if (!spool) { push ("deleting an existing folder"); camel_store_delete_folder_sync ( store, "testbox2", NULL, &error); check_msg (error == NULL, "%s", error->message); g_clear_error (&error); pull (); } push ("opening a folder that has been deleted"); folder = camel_store_get_folder_sync ( store, "testbox2", 0, NULL, &error); check (error != NULL); check (folder == NULL); g_clear_error (&error); pull (); check_unref (store, 1); camel_test_end (); }
void test_mpi(threaddata_t *tdata) { MPI_Request sendhandle = MPI_REQUEST_NULL; MPI_Request recvhandle = MPI_REQUEST_NULL; int peer = tdata->tid_peer; int node = tt_thread_map[peer]; int mpipeer = gasnetnode_to_mpirank[node]; int sz; char *sendbuf; char *recvbuf; int tag = tdata->tid; int i; do { sz = RANDOM_SIZE(); } while (sz == 0); /* some MPI's may barf on 0 byte send/recv */ sendbuf = (char*)test_malloc(sz); recvbuf = (char*)test_malloc(sz); for (i=0; i < MIN(sz,4096); i++) { /* randomize at least the first 4 KB */ sendbuf[i] = (char)rand(); } ACTION_PRINTF("tid=%3d> starting MPI ping-pong with tid=%3d.\n", tdata->tid, peer); MPI_LOCK(); ACTION_PRINTF("tid=%3d> setting MPI_Irecv, %i bytes\n", tdata->tid, sz); MPI_SAFE(MPI_Irecv(recvbuf, sz, MPI_BYTE, mpipeer, 10000+tag, MPI_COMM_WORLD, &recvhandle)); assert(recvhandle != MPI_REQUEST_NULL); ACTION_PRINTF("tid=%3d> sending MPI message, %i bytes\n", tdata->tid, sz); MPI_SAFE(MPI_Isend(sendbuf, sz, MPI_BYTE, mpipeer, tag, MPI_COMM_WORLD, &sendhandle)); assert(sendhandle != MPI_REQUEST_NULL); MPI_UNLOCK(); tdata->flag = -1; gasnett_local_wmb(); ACTION_PRINTF("tid=%3d> MPI AMShortRequest to tid=%3d\n", tdata->tid, peer); GASNET_Safe(gasnet_AMRequestShort2(node, hidx_mpi_handler, tdata->tid, sz)); while (tdata->flag != 0) { ACTION_PRINTF("tid=%3d> MPI probe AMShortRequest to tid=%3d\n", tdata->tid, peer); GASNET_Safe(gasnet_AMRequestShort1(node, hidx_mpi_probehandler, tdata->tid)); gasnett_sched_yield(); test_sleep(tdata); GASNET_Safe(gasnet_AMPoll()); mpi_test(&sendhandle); /* occasional testing may be required for progress */ mpi_test(&recvhandle); } tdata->flag = -1; mpi_complete(&sendhandle); mpi_complete(&recvhandle); /* verify */ for (i=0; i < sz; i++) { if (sendbuf[i] != recvbuf[i]) FATALERR("mismatch at element %i in MPI test.", i); } test_free(sendbuf); test_free(recvbuf); ACTION_PRINTF("tid=%3d> MPI ping-pong with tid=%3d complete.\n", tdata->tid, peer); }