From ed62f0064be56a425c69f1754cf90893724c2ef2 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Thu, 18 Jun 2009 15:49:06 +0000 Subject: Ticket #895: Updated jbuf test to use defined search paths for locating test data file (when opening the file in working dir fails). git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2776 74dad513-b988-da41-8d7b-12977e46ad98 --- pjmedia/src/test/jbuf_test.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'pjmedia') diff --git a/pjmedia/src/test/jbuf_test.c b/pjmedia/src/test/jbuf_test.c index 1836227c..6eb5b458 100644 --- a/pjmedia/src/test/jbuf_test.c +++ b/pjmedia/src/test/jbuf_test.c @@ -158,10 +158,36 @@ static pj_bool_t process_test_data(char data, pjmedia_jbuf *jb, int jbuf_main(void) { - FILE *input = fopen("JBTEST.DAT", "rt"); + FILE *input; pj_bool_t data_eof = PJ_FALSE; int old_log_level; int rc = 0; + const char* input_filename = "Jbtest.dat"; + const char* input_search_path[] = { + "../build" + }; + + /* Try to open test data file in the working directory */ + input = fopen(input_filename, "rt"); + + /* If that fails, try to open test data file in specified search paths */ + if (input == NULL) { + char input_path[PJ_MAXPATH]; + int i; + + for (i = 0; !input && i < PJ_ARRAY_SIZE(input_search_path); ++i) { + pj_ansi_snprintf(input_path, PJ_MAXPATH, "%s/%s", + input_search_path[i], + input_filename); + input = fopen(input_path, "rt"); + } + } + + /* Failed to open test data file. */ + if (input == NULL) { + printf("Failed to open test data file, Jbtest.dat\n"); + return -1; + } old_log_level = pj_log_get_level(); pj_log_set_level(5); -- cgit v1.2.3