void eval_calls(std::vector<strvcfentry> entries, std::vector<strsimul> simul, int max_allowed_dist, std::string output) { strreport notfound = init_report(); strreport additional = init_report(); strreport found = init_report(); FILE * right; FILE * addition; std::string out = output; out += "_right.vcf"; right = fopen(out.c_str(), "w"); out = output; out += "addition.vcf"; addition = fopen(out.c_str(), "w"); //for (size_t i = 0; i < entries.size(); i++) { // std::cout<<entries[i].start.chr<<" "<<entries[i].start.pos<<" "<<entries[i].stop.chr<<" "<<entries[i].stop.pos<<" "<<entries[i].type<<std::endl; //} // std::cout<<"type dv"<<" "<<"rv"<<" "<<"dr"<<" "<<"rr"<<" "<<"gq"<<std::endl; for (size_t i = 0; i < entries.size(); i++) { bool found = false; for (size_t j = 0; j < simul.size(); j++) { if (simul[j].type == entries[i].type) { if (match_coords(simul[j], entries[i], max_allowed_dist)) { //check if order is perserved! simul[j].identified = true; found = true; } } } if (!found) { fprintf(addition, "%s", entries[i].header.c_str()); for (std::map<std::string, std::string>::iterator tz = entries[i].calls.begin(); tz != entries[i].calls.end(); tz++) { fprintf(addition, "%s", (*tz).second.c_str()); } fprintf(addition, "%c", '\n'); add_to_report(additional, entries[i].type); // std::cout<<"additional found: "<<entries[i].type<<" "<<entries[i].start.chr<<" "<<entries[i].start.pos<<" "<<entries[i].stop.chr<<" "<<entries[i].stop.pos<<std::endl; } else { fprintf(right, "%s", entries[i].header.c_str()); for (std::map<std::string, std::string>::iterator tz = entries[i].calls.begin(); tz != entries[i].calls.end(); tz++) { fprintf(right, "%s", (*tz).second.c_str()); } fprintf(right, "%c", '\n'); } } for (size_t j = 0; j < simul.size(); j++) { if (!simul[j].identified) { add_to_report(notfound, simul[j].type); std::cout<<simul[j].type<<" "<<simul[j].start.chr<<" "<<simul[j].start.pos<<" END: "<<simul[j].stop.chr<<" "<<simul[j].stop.pos<<std::endl; } else { add_to_report(found, simul[j].type); } } std::cout << " Overall: " << simul.size() << " " << print_report(found) << " " << print_report(notfound) << " " << print_report(additional) << " " << get_TP(simul.size(), found) << " " << get_FP(found, additional) << std::endl; }
int test_main(void) { pj_status_t rc; pj_caching_pool caching_pool; const char *filename; unsigned tsx_test_cnt=0; struct tsx_test_param tsx_test[10]; pj_status_t status; #if INCLUDE_TSX_TEST unsigned i; pjsip_transport *tp; #if PJ_HAS_TCP pjsip_tpfactory *tpfactory; #endif /* PJ_HAS_TCP */ #endif /* INCLUDE_TSX_TEST */ int line; pj_log_set_level(log_level); pj_log_set_decor(param_log_decor); if ((rc=pj_init()) != PJ_SUCCESS) { app_perror("pj_init", rc); return rc; } if ((rc=pjlib_util_init()) != PJ_SUCCESS) { app_perror("pj_init", rc); return rc; } status = init_report(); if (status != PJ_SUCCESS) return status; pj_dump_config(); pj_caching_pool_init( &caching_pool, &pj_pool_factory_default_policy, PJSIP_TEST_MEM_SIZE ); rc = pjsip_endpt_create(&caching_pool.factory, "endpt", &endpt); if (rc != PJ_SUCCESS) { app_perror("pjsip_endpt_create", rc); pj_caching_pool_destroy(&caching_pool); return rc; } PJ_LOG(3,(THIS_FILE,"")); /* Init logger module. */ init_msg_logger(); msg_logger_set_enabled(1); /* Start transaction layer module. */ rc = pjsip_tsx_layer_init_module(endpt); if (rc != PJ_SUCCESS) { app_perror(" Error initializing transaction module", rc); goto on_return; } /* Create loop transport. */ rc = pjsip_loop_start(endpt, NULL); if (rc != PJ_SUCCESS) { app_perror(" error: unable to create datagram loop transport", rc); goto on_return; } tsx_test[tsx_test_cnt].port = 5060; tsx_test[tsx_test_cnt].tp_type = "loop-dgram"; tsx_test[tsx_test_cnt].type = PJSIP_TRANSPORT_LOOP_DGRAM; ++tsx_test_cnt; #if INCLUDE_URI_TEST DO_TEST(uri_test()); #endif #if INCLUDE_MSG_TEST DO_TEST(msg_test()); DO_TEST(msg_err_test()); #endif #if INCLUDE_MULTIPART_TEST DO_TEST(multipart_test()); #endif #if INCLUDE_TXDATA_TEST DO_TEST(txdata_test()); #endif #if INCLUDE_TSX_BENCH DO_TEST(tsx_bench()); #endif #if INCLUDE_UDP_TEST DO_TEST(transport_udp_test()); #endif #if INCLUDE_LOOP_TEST DO_TEST(transport_loop_test()); #endif #if INCLUDE_TCP_TEST DO_TEST(transport_tcp_test()); #endif #if INCLUDE_RESOLVE_TEST DO_TEST(resolve_test()); #endif #if INCLUDE_TSX_TEST status = pjsip_udp_transport_start(endpt, NULL, NULL, 1, &tp); if (status == PJ_SUCCESS) { tsx_test[tsx_test_cnt].port = tp->local_name.port; tsx_test[tsx_test_cnt].tp_type = "udp"; tsx_test[tsx_test_cnt].type = PJSIP_TRANSPORT_UDP; ++tsx_test_cnt; } #if PJ_HAS_TCP status = pjsip_tcp_transport_start(endpt, NULL, 1, &tpfactory); if (status == PJ_SUCCESS) { tsx_test[tsx_test_cnt].port = tpfactory->addr_name.port; tsx_test[tsx_test_cnt].tp_type = "tcp"; tsx_test[tsx_test_cnt].type = PJSIP_TRANSPORT_TCP; ++tsx_test_cnt; } else { app_perror("Unable to create TCP", status); rc = -4; goto on_return; } #endif for (i=0; i<tsx_test_cnt; ++i) { DO_TSX_TEST(tsx_basic_test, &tsx_test[i]); DO_TSX_TEST(tsx_uac_test, &tsx_test[i]); DO_TSX_TEST(tsx_uas_test, &tsx_test[i]); } #endif #if INCLUDE_INV_OA_TEST DO_TEST(inv_offer_answer_test()); #endif #if INCLUDE_REGC_TEST DO_TEST(regc_test()); #endif on_return: flush_events(500); /* Dumping memory pool usage */ PJ_LOG(3,(THIS_FILE, "Peak memory size=%u MB", caching_pool.peak_used_size / 1000000)); pjsip_endpt_destroy(endpt); pj_caching_pool_destroy(&caching_pool); PJ_LOG(3,(THIS_FILE, "")); pj_thread_get_stack_info(pj_thread_this(), &filename, &line); PJ_LOG(3,(THIS_FILE, "Stack max usage: %u, deepest: %s:%u", pj_thread_get_stack_max_usage(pj_thread_this()), filename, line)); if (rc == 0) PJ_LOG(3,(THIS_FILE, "Looks like everything is okay!..")); else PJ_LOG(3,(THIS_FILE, "Test completed with error(s)")); report_ival("test-status", rc, "", "Overall test status/result (0==success)"); close_report(); return rc; }