int main(int argc, char **argv) { Message msg_in("in"), msg_out("out"), msg_empty, msg_test(msg_out); Folder fld_in, fld_out; msg_in.save(fld_in); msg_out.save(fld_out); }
static void plugin_vlog(openvpn_plugin_log_flags_t flags, const char *name, const char *format, va_list arglist) { unsigned int msg_flags = 0; if (!format) { return; } if (!name || name[0] == '\0') { msg(D_PLUGIN_DEBUG, "PLUGIN: suppressed log message from plugin with unknown name"); return; } if (flags & PLOG_ERR) { msg_flags = M_INFO | M_NONFATAL; } else if (flags & PLOG_WARN) { msg_flags = M_INFO | M_WARN; } else if (flags & PLOG_NOTE) { msg_flags = M_INFO; } else if (flags & PLOG_DEBUG) { msg_flags = D_PLUGIN_DEBUG; } if (flags & PLOG_ERRNO) { msg_flags |= M_ERRNO; } if (flags & PLOG_NOMUTE) { msg_flags |= M_NOMUTE; } if (msg_test(msg_flags)) { struct gc_arena gc; char *msg_fmt; /* Never add instance prefix; not thread safe */ msg_flags |= M_NOIPREFIX; gc_init(&gc); msg_fmt = gc_malloc(ERR_BUF_SIZE, false, &gc); openvpn_snprintf(msg_fmt, ERR_BUF_SIZE, "PLUGIN %s: %s", name, format); x_msg_va(msg_flags, msg_fmt, arglist); gc_free(&gc); } }
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; }