1*a0449d98SPierre Jolivet static char help[] = "Tests PetscLogView() called from different places.\n\n"; 2*a0449d98SPierre Jolivet 3*a0449d98SPierre Jolivet #include <petscsys.h> 4*a0449d98SPierre Jolivet #include <petscvec.h> 5*a0449d98SPierre Jolivet 6*a0449d98SPierre Jolivet int main(int argc, char **args) 7*a0449d98SPierre Jolivet { 8*a0449d98SPierre Jolivet Vec vec; 9*a0449d98SPierre Jolivet PetscViewer viewer[2]; 10*a0449d98SPierre Jolivet PetscBool flg = PETSC_FALSE; 11*a0449d98SPierre Jolivet 12*a0449d98SPierre Jolivet PetscFunctionBegin; 13*a0449d98SPierre Jolivet PetscCall(PetscInitialize(&argc, &args, NULL, help)); 14*a0449d98SPierre Jolivet PetscCall(PetscLogDefaultBegin()); 15*a0449d98SPierre Jolivet PetscCall(PetscViewerCreate(PETSC_COMM_SELF, viewer)); 16*a0449d98SPierre Jolivet PetscCall(PetscViewerCreate(PETSC_COMM_SELF, viewer + 1)); 17*a0449d98SPierre Jolivet PetscCall(PetscViewerDestroy(viewer + 1)); 18*a0449d98SPierre Jolivet PetscCall(PetscViewerSetType(viewer[0], PETSCVIEWERASCII)); 19*a0449d98SPierre Jolivet PetscCall(PetscOptionsGetBool(NULL, NULL, "-with_vec", &flg, NULL)); 20*a0449d98SPierre Jolivet if (flg) { 21*a0449d98SPierre Jolivet PetscCall(VecCreate(PETSC_COMM_SELF, &vec)); 22*a0449d98SPierre Jolivet PetscCall(VecDestroy(&vec)); 23*a0449d98SPierre Jolivet } 24*a0449d98SPierre Jolivet flg = PETSC_FALSE; 25*a0449d98SPierre Jolivet PetscCall(PetscOptionsGetBool(NULL, NULL, "-with_options", &flg, NULL)); 26*a0449d98SPierre Jolivet if (!flg) { 27*a0449d98SPierre Jolivet PetscCall(PetscLogView(viewer[0])); 28*a0449d98SPierre Jolivet PetscCall(PetscLogView(viewer[0])); 29*a0449d98SPierre Jolivet PetscCall(PetscLogView(viewer[0])); 30*a0449d98SPierre Jolivet } else { 31*a0449d98SPierre Jolivet PetscCall(PetscLogViewFromOptions()); 32*a0449d98SPierre Jolivet PetscCall(PetscLogViewFromOptions()); 33*a0449d98SPierre Jolivet PetscCall(PetscLogViewFromOptions()); 34*a0449d98SPierre Jolivet } 35*a0449d98SPierre Jolivet PetscCall(PetscViewerDestroy(viewer)); 36*a0449d98SPierre Jolivet PetscCall(PetscFinalize()); 37*a0449d98SPierre Jolivet return 0; 38*a0449d98SPierre Jolivet } 39*a0449d98SPierre Jolivet 40*a0449d98SPierre Jolivet /*TEST 41*a0449d98SPierre Jolivet 42*a0449d98SPierre Jolivet testset: 43*a0449d98SPierre Jolivet requires: defined(PETSC_USE_LOG) 44*a0449d98SPierre Jolivet nsize: 1 45*a0449d98SPierre Jolivet temporaries: default.log flamegraph.log 46*a0449d98SPierre Jolivet filter: grep Viewer | uniq 47*a0449d98SPierre Jolivet test: 48*a0449d98SPierre Jolivet args: -log_view ascii,:flamegraph.log:ascii_flamegraph,:default.log -with_vec {{false true}shared output} 49*a0449d98SPierre Jolivet # test: 50*a0449d98SPierre Jolivet # TODO: broken (wrong count when PetscLogViewFromOptions() is called by the user) 51*a0449d98SPierre Jolivet # args: -log_view ascii,:flamegraph.log:ascii_flamegraph,:default.log -with_vec {{false true}shared output} -with_options 52*a0449d98SPierre Jolivet 53*a0449d98SPierre Jolivet TEST*/ 54