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