Actual source code: ex66.c
1: static const char help[] = "Tests error message when previous error was not fully handled\n";
3: #include <petscsys.h>
5: PetscErrorCode CreateError(int n)
6: {
7: PetscCheck(n, PETSC_COMM_SELF, PETSC_ERR_USER, "Error Created");
8: PetscCall(CreateError(n - 1));
9: return PETSC_SUCCESS;
10: }
12: int main(int argc, char **argv)
13: {
14: PetscErrorCode ierr;
16: PetscFunctionBeginUser;
17: PetscCall(PetscInitialize(&argc, &argv, NULL, help));
18: PetscCall(PetscFPrintf(PETSC_COMM_WORLD, stdout, "Demonstrates PETSc Error Handlers\n"));
19: PetscCall(PetscFPrintf(PETSC_COMM_WORLD, stdout, "The error is a contrived error to test error handling\n"));
20: PetscCall(PetscSynchronizedFlush(PETSC_COMM_WORLD, PETSC_STDOUT));
21: ierr = CreateError(5);
22: (void)ierr; /* this prevents the compiler from warning about unused error return code */
23: ierr = CreateError(5);
24: (void)ierr;
25: PetscCall(CreateError(5));
26: PetscCall(PetscFinalize());
27: return 0;
28: }
30: /*TEST
32: test:
33: requires: !defined(PETSCTEST_VALGRIND) !defined(PETSC_HAVE_SANITIZER)
34: args: -petsc_ci_portable_error_output -error_output_stdout
35: filter: grep -E -v "(memory block|leaked context|not freed before MPI_Finalize|Could be the program crashed|PETSc Option Table entries|source: environment)"
37: TEST*/