LCOV - code coverage report
Current view: top level - sys/tests - test4.c (source / functions) Hit Total Coverage
Test: SLEPc Lines: 20 22 90.9 %
Date: 2024-12-18 00:51:33 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       3             :    SLEPc - Scalable Library for Eigenvalue Problem Computations
       4             :    Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain
       5             : 
       6             :    This file is part of SLEPc.
       7             :    SLEPc is distributed under a 2-clause BSD license (see LICENSE).
       8             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       9             : */
      10             : 
      11             : static char help[] = "Tests SlepcInitialize() after PetscInitialize().\n\n";
      12             : 
      13             : #include <slepcsys.h>
      14             : 
      15           2 : int main(int argc,char **argv)
      16             : {
      17           2 :   PetscBool pInitialized,sInitialized,pFinalized,sFinalized,skip_petsc_finalize;
      18             : 
      19           2 :   PetscCall(PetscInitialize(&argc,&argv,NULL,help));
      20           2 :   PetscCall(PetscInitialized(&pInitialized));
      21           2 :   PetscCall(SlepcInitialized(&sInitialized));
      22           2 :   PetscCall(PetscPrintf(PETSC_COMM_WORLD,"PetscInitialized=%d, SlepcInitialized=%d.\n",(int)pInitialized,(int)sInitialized));
      23           2 :   PetscFunctionBeginUser;
      24           2 :   PetscCall(SlepcInitialize(&argc,&argv,NULL,help));
      25           2 :   PetscCall(PetscInitialized(&pInitialized));
      26           2 :   PetscCall(SlepcInitialized(&sInitialized));
      27           2 :   PetscCall(PetscPrintf(PETSC_COMM_WORLD,"PetscInitialized=%d, SlepcInitialized=%d.\n",(int)pInitialized,(int)sInitialized));
      28           2 :   PetscCall(PetscOptionsHasName(NULL,NULL,"-skip_petsc_finalize",&skip_petsc_finalize));
      29           2 :   if (!skip_petsc_finalize) {
      30           1 :     PetscCall(PetscFinalize());
      31           0 :     PetscCall(PetscFinalized(&pFinalized));
      32           0 :     if (!pFinalized) printf("Unexpected value: PetscFinalized() returned False after PetscFinalize()\n");
      33             :   }
      34           1 :   PetscCall(SlepcFinalized(&sFinalized));
      35           1 :   if (sFinalized) printf("Unexpected value: SlepcFinalized() returned True before SlepcFinalize()\n");
      36           1 :   PetscCall(SlepcFinalize());
      37           1 :   PetscCall(SlepcFinalized(&sFinalized));
      38           1 :   if (!sFinalized) printf("Unexpected value: SlepcFinalized() returned False after SlepcFinalize()\n");
      39           1 :   if (skip_petsc_finalize) PetscCall(PetscFinalize());
      40             :   return 0;
      41             : }
      42             : 
      43             : /*TEST
      44             : 
      45             :    testset:
      46             :       output_file: output/test4_1.out
      47             :       test:
      48             :          suffix: 1
      49             :       test:
      50             :          suffix: 2
      51             :          args: -skip_petsc_finalize
      52             : 
      53             : TEST*/

Generated by: LCOV version 1.14