Changeset 2776


Ignore:
Timestamp:
Jun 18, 2009 3:49:06 PM (11 years ago)
Author:
nanang
Message:

Ticket #895: Updated jbuf test to use defined search paths for locating test data file (when opening the file in working dir fails).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/test/jbuf_test.c

    r2660 r2776  
    159159int jbuf_main(void) 
    160160{ 
    161     FILE *input = fopen("JBTEST.DAT", "rt"); 
     161    FILE *input; 
    162162    pj_bool_t data_eof = PJ_FALSE; 
    163163    int old_log_level; 
    164164    int rc = 0; 
     165    const char* input_filename = "Jbtest.dat"; 
     166    const char* input_search_path[] = {  
     167        "../build" 
     168    }; 
     169 
     170    /* Try to open test data file in the working directory */ 
     171    input = fopen(input_filename, "rt"); 
     172 
     173    /* If that fails, try to open test data file in specified search paths */ 
     174    if (input == NULL) { 
     175        char input_path[PJ_MAXPATH]; 
     176        int i; 
     177 
     178        for (i = 0; !input && i < PJ_ARRAY_SIZE(input_search_path); ++i) { 
     179            pj_ansi_snprintf(input_path, PJ_MAXPATH, "%s/%s", 
     180                             input_search_path[i], 
     181                             input_filename); 
     182            input = fopen(input_path, "rt"); 
     183        } 
     184    } 
     185     
     186    /* Failed to open test data file. */ 
     187    if (input == NULL) { 
     188        printf("Failed to open test data file, Jbtest.dat\n"); 
     189        return -1; 
     190    } 
    165191 
    166192    old_log_level = pj_log_get_level(); 
Note: See TracChangeset for help on using the changeset viewer.