xref: /petsc/src/sys/tests/ex31.c (revision 40badf4fbc550ac1f60bd080eaff6de6d55b946d)
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 {
9   size_t         i,n;
10 
11   PetscFunctionBegin;
12   CHKERRQ(PetscStrlen(filein,&n));
13   for (i=0; i<n; i++) {
14     if (filein[i] == '\\') filein[i] = '/';
15   }
16   PetscFunctionReturn(0);
17 }
18 
19 int main(int argc,char **argv)
20 {
21   char           fpath[PETSC_MAX_PATH_LEN];
22   PetscErrorCode ierr;
23 
24   ierr = PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;
25   CHKERRQ(PetscGetFullPath("~/somefile",fpath,sizeof(fpath)));
26   CHKERRQ(path_to_unix(fpath));
27   CHKERRQ(PetscPrintf(PETSC_COMM_WORLD,"%s\n",fpath));
28   CHKERRQ(PetscGetFullPath("someotherfile",fpath,sizeof(fpath)));
29   CHKERRQ(path_to_unix(fpath));
30   CHKERRQ(PetscPrintf(PETSC_COMM_WORLD,"%s\n",fpath));
31   ierr = PetscFinalize();
32   return ierr;
33 }
34 
35 /*TEST
36 
37    test:
38       requires: !windows_compilers
39       filter: sed "s?$(pwd -P)??g" |  sed "s?${HOME}??g"
40 
41    test:
42       suffix: 2
43       requires: windows_compilers
44       output_file: output/ex31_1.out
45       filter: sed "s?`cygpath -m ${PWD}`??g" |  sed "s?`cygpath -m ${HOME}`??g"
46 
47 TEST*/
48