1 static char help[] = "Tests PetscGetFullPath().\n\n"; 2 3 #include <petscsys.h> 4 5 /* for windows - fix up path - so that we can do diff test */ 6 PetscErrorCode path_to_unix(char filein[]) 7 { 8 size_t i, n; 9 10 PetscFunctionBegin; 11 PetscCall(PetscStrlen(filein, &n)); 12 for (i = 0; i < n; i++) { 13 if (filein[i] == '\\') filein[i] = '/'; 14 } 15 PetscFunctionReturn(PETSC_SUCCESS); 16 } 17 18 int main(int argc, char **argv) 19 { 20 char fpath[PETSC_MAX_PATH_LEN]; 21 22 PetscFunctionBeginUser; 23 PetscCall(PetscInitialize(&argc, &argv, NULL, help)); 24 PetscCall(PetscGetFullPath("~/somefile", fpath, sizeof(fpath))); 25 PetscCall(path_to_unix(fpath)); 26 PetscCall(PetscPrintf(PETSC_COMM_WORLD, "%s\n", fpath)); 27 PetscCall(PetscGetFullPath("someotherfile", fpath, sizeof(fpath))); 28 PetscCall(path_to_unix(fpath)); 29 PetscCall(PetscPrintf(PETSC_COMM_WORLD, "%s\n", fpath)); 30 PetscCall(PetscFinalize()); 31 return 0; 32 } 33 34 /*TEST 35 36 test: 37 requires: !windows_compilers 38 filter: sed "s?$(pwd -P)??g" | sed "s?${HOME}??g" 39 40 test: 41 suffix: 2 42 requires: windows_compilers 43 output_file: output/ex31_1.out 44 filter: sed "s?`cygpath -m ${PWD}`??g" | sed "s?`cygpath -m ${HOME}`??g" 45 46 TEST*/ 47