LCOV - code coverage report
Current view: top level - src/test/modules/test_checksums - test_checksums.c (source / functions) Coverage Total Hit
Test: PostgreSQL 19devel Lines: 16.0 % 25 4
Test Date: 2026-04-28 15:16:26 Functions: 50.0 % 8 4
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /*--------------------------------------------------------------------------
       2              :  *
       3              :  * test_checksums.c
       4              :  *      Test data checksums
       5              :  *
       6              :  * Copyright (c) 2026, PostgreSQL Global Development Group
       7              :  *
       8              :  * IDENTIFICATION
       9              :  *      src/test/modules/test_checksums/test_checksums.c
      10              :  *
      11              :  * -------------------------------------------------------------------------
      12              :  */
      13              : #include "postgres.h"
      14              : 
      15              : #include "funcapi.h"
      16              : #include "miscadmin.h"
      17              : #include "postmaster/datachecksum_state.h"
      18              : #include "storage/latch.h"
      19              : #include "utils/injection_point.h"
      20              : #include "utils/wait_event.h"
      21              : 
      22            2 : PG_MODULE_MAGIC;
      23              : 
      24              : extern PGDLLEXPORT void dc_delay_barrier(const char *name, const void *private_data, void *arg);
      25              : 
      26              : /*
      27              :  * Test for delaying emission of procsignalbarriers.
      28              :  */
      29              : void
      30            0 : dc_delay_barrier(const char *name, const void *private_data, void *arg)
      31              : {
      32              :     (void) name;
      33              :     (void) private_data;
      34              : 
      35            0 :     (void) WaitLatch(MyLatch,
      36              :                      WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH,
      37              :                      (3 * 1000),
      38              :                      WAIT_EVENT_PG_SLEEP);
      39            0 : }
      40              : 
      41            2 : PG_FUNCTION_INFO_V1(dcw_inject_delay_barrier);
      42              : Datum
      43            0 : dcw_inject_delay_barrier(PG_FUNCTION_ARGS)
      44              : {
      45              : #ifdef USE_INJECTION_POINTS
      46            0 :     bool        attach = PG_GETARG_BOOL(0);
      47              : 
      48            0 :     if (attach)
      49            0 :         InjectionPointAttach("datachecksums-enable-checksums-delay",
      50              :                              "test_checksums",
      51              :                              "dc_delay_barrier",
      52              :                              NULL,
      53              :                              0);
      54              :     else
      55            0 :         InjectionPointDetach("datachecksums-enable-checksums-delay");
      56              : #else
      57              :     elog(ERROR,
      58              :          "test is not working as intended when injection points are disabled");
      59              : #endif
      60            0 :     PG_RETURN_VOID();
      61              : }
      62              : 
      63            2 : PG_FUNCTION_INFO_V1(dcw_inject_launcher_delay);
      64              : Datum
      65            0 : dcw_inject_launcher_delay(PG_FUNCTION_ARGS)
      66              : {
      67              : #ifdef USE_INJECTION_POINTS
      68            0 :     bool        attach = PG_GETARG_BOOL(0);
      69              : 
      70            0 :     if (attach)
      71            0 :         InjectionPointAttach("datachecksumsworker-launcher-delay",
      72              :                              "test_checksums",
      73              :                              "dc_delay_barrier",
      74              :                              NULL,
      75              :                              0);
      76              :     else
      77            0 :         InjectionPointDetach("datachecksumsworker-launcher-delay");
      78              : #else
      79              :     elog(ERROR,
      80              :          "test is not working as intended when injection points are disabled");
      81              : #endif
      82            0 :     PG_RETURN_VOID();
      83              : }
      84              : 
      85            2 : PG_FUNCTION_INFO_V1(dcw_inject_startup_delay);
      86              : Datum
      87            0 : dcw_inject_startup_delay(PG_FUNCTION_ARGS)
      88              : {
      89              : #ifdef USE_INJECTION_POINTS
      90            0 :     bool        attach = PG_GETARG_BOOL(0);
      91              : 
      92            0 :     if (attach)
      93            0 :         InjectionPointAttach("datachecksumsworker-startup-delay",
      94              :                              "test_checksums",
      95              :                              "dc_delay_barrier",
      96              :                              NULL,
      97              :                              0);
      98              :     else
      99            0 :         InjectionPointDetach("datachecksumsworker-startup-delay");
     100              : #else
     101              :     elog(ERROR,
     102              :          "test is not working as intended when injection points are disabled");
     103              : #endif
     104            0 :     PG_RETURN_VOID();
     105              : }
        

Generated by: LCOV version 2.0-1