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