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