| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include "test.h" |
| 20 |
|
| 21 |
#define THIS_FILE "test.c" |
| 22 |
|
| 23 |
pj_pool_factory *mem; |
| 24 |
struct test_app_t test_app; |
| 25 |
|
| 26 |
|
| 27 |
void app_perror(pj_status_t status, const char *msg) |
| 28 |
{ |
| 29 |
char errbuf[PJ_ERR_MSG_SIZE]; |
| 30 |
|
| 31 |
pjmedia_strerror(status, errbuf, sizeof(errbuf)); |
| 32 |
|
| 33 |
PJ_LOG(3,(THIS_FILE, "%s: %s", msg, errbuf)); |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
#if PJMEDIA_HAS_G711_CODEC==0 |
| 40 |
void *dummy() |
| 41 |
{ |
| 42 |
|
| 43 |
return &pjmedia_plc_save; |
| 44 |
} |
| 45 |
#endif |
| 46 |
|
| 47 |
int test_main(int argc, char *argv[]) |
| 48 |
{ |
| 49 |
int rc = 0; |
| 50 |
pj_caching_pool caching_pool; |
| 51 |
pj_pool_t *pool = NULL; |
| 52 |
|
| 53 |
PJ_TEST_SUCCESS(pj_init(), NULL, return 1); |
| 54 |
|
| 55 |
if (test_app.ut_app.prm_config) |
| 56 |
pj_dump_config(); |
| 57 |
|
| 58 |
pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0); |
| 59 |
PJ_TEST_NOT_NULL(pool=pj_pool_create(&caching_pool.factory, "test", |
| 60 |
1000, 512, NULL), |
| 61 |
NULL, {rc=10; goto on_return;}); |
| 62 |
|
| 63 |
pj_log_set_decor(PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_TIME | |
| 64 |
PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_INDENT); |
| 65 |
pj_log_set_level(3); |
| 66 |
|
| 67 |
mem = &caching_pool.factory; |
| 68 |
|
| 69 |
PJ_TEST_SUCCESS(pjmedia_event_mgr_create(pool, 0, NULL), |
| 70 |
NULL, {rc=30; goto on_return;}); |
| 71 |
|
| 72 |
#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0) |
| 73 |
PJ_TEST_SUCCESS(pjmedia_video_format_mgr_create(pool, 64, 0, NULL), |
| 74 |
NULL, {rc=50; goto on_return;}); |
| 75 |
PJ_TEST_SUCCESS(pjmedia_converter_mgr_create(pool, NULL), |
| 76 |
NULL, {rc=60; goto on_return;}); |
| 77 |
PJ_TEST_SUCCESS(pjmedia_vid_codec_mgr_create(pool, NULL), |
| 78 |
NULL, {rc=70; goto on_return;}); |
| 79 |
#endif |
| 80 |
|
| 81 |
PJ_TEST_SUCCESS(ut_app_init1(&test_app.ut_app, mem), |
| 82 |
NULL, {rc=40; goto on_return;}); |
| 83 |
|
| 84 |
#if HAS_MIPS_TEST |
| 85 |
|
| 86 |
UT_ADD_TEST(&test_app.ut_app, mips_test, PJ_TEST_EXCLUSIVE); |
| 87 |
#endif |
| 88 |
|
| 89 |
#if HAS_VID_CODEC_TEST |
| 90 |
|
| 91 |
UT_ADD_TEST(&test_app.ut_app, vid_codec_test, PJ_TEST_EXCLUSIVE); |
| 92 |
#endif |
| 93 |
|
| 94 |
#if HAS_VID_PORT_TEST |
| 95 |
UT_ADD_TEST(&test_app.ut_app, vid_port_test, 0); |
| 96 |
#endif |
| 97 |
|
| 98 |
#if HAS_VID_DEV_TEST |
| 99 |
UT_ADD_TEST(&test_app.ut_app, vid_dev_test, 0); |
| 100 |
#endif |
| 101 |
|
| 102 |
#if HAS_SDP_NEG_TEST |
| 103 |
UT_ADD_TEST(&test_app.ut_app, sdp_neg_test, 0); |
| 104 |
#endif |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
#if HAS_JBUF_TEST |
| 109 |
UT_ADD_TEST(&test_app.ut_app, jbuf_test, 0); |
| 110 |
#endif |
| 111 |
#if HAS_CODEC_VECTOR_TEST |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
UT_ADD_TEST(&test_app.ut_app, codec_test_vectors, PJ_TEST_EXCLUSIVE); |
| 118 |
#endif |
| 119 |
|
| 120 |
if (ut_run_tests(&test_app.ut_app, "pjmedia tests", argc, argv)) { |
| 121 |
rc = 99; |
| 122 |
} else { |
| 123 |
rc = 0; |
| 124 |
} |
| 125 |
|
| 126 |
ut_app_destroy(&test_app.ut_app); |
| 127 |
|
| 128 |
on_return: |
| 129 |
if (rc != 0) { |
| 130 |
PJ_LOG(3,(THIS_FILE,"Test completed with error(s)!")); |
| 131 |
} else { |
| 132 |
PJ_LOG(3,(THIS_FILE,"Looks like everything is okay!")); |
| 133 |
} |
| 134 |
|
| 135 |
#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0) |
| 136 |
pjmedia_video_format_mgr_destroy(pjmedia_video_format_mgr_instance()); |
| 137 |
pjmedia_converter_mgr_destroy(pjmedia_converter_mgr_instance()); |
| 138 |
pjmedia_vid_codec_mgr_destroy(pjmedia_vid_codec_mgr_instance()); |
| 139 |
#endif |
| 140 |
|
| 141 |
pjmedia_event_mgr_destroy(pjmedia_event_mgr_instance()); |
| 142 |
if (pool) |
| 143 |
pj_pool_release(pool); |
| 144 |
pj_caching_pool_destroy(&caching_pool); |
| 145 |
|
| 146 |
return rc; |
| 147 |
} |