LCOV - code coverage report
Current view: top level - autotest/cpp - proj_with_fork.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 13 18 72.2 %
Date: 2024-11-21 22:18:42 Functions: 4 4 100.0 %

          Line data    Source code
       1             : #include <unistd.h>
       2             : #include <sys/types.h>
       3             : #include <sys/wait.h>
       4             : 
       5             : #include "ogr_srs_api.h"
       6             : #include "gtest_include.h"
       7             : 
       8             : namespace
       9             : {
      10             : 
      11             : // ---------------------------------------------------------------------------
      12             : 
      13           4 : TEST(proj_with_fork, test)
      14             : {
      15           1 :     OGRSpatialReferenceH hSRS = OSRNewSpatialReference(nullptr);
      16             :     // To open the DB in the parent
      17           1 :     OSRImportFromEPSG(hSRS, 32631);
      18             : 
      19             :     pid_t children[4];
      20           5 :     for (int i = 0; i < 4; i++)
      21             :     {
      22           4 :         children[i] = fork();
      23           4 :         if (children[i] < 0)
      24           0 :             exit(1);
      25           4 :         if (children[i] == 0)
      26             :         {
      27           0 :             for (int epsg = 32601; epsg <= 32661; epsg++)
      28             :             {
      29           0 :                 EXPECT_EQ(OSRImportFromEPSG(hSRS, epsg), OGRERR_NONE);
      30           0 :                 EXPECT_EQ(OSRImportFromEPSG(hSRS, epsg + 100), OGRERR_NONE);
      31             :             }
      32           0 :             _exit(0);
      33             :         }
      34             :     }
      35             : 
      36           5 :     for (int i = 0; i < 4; i++)
      37             :     {
      38           4 :         int status = 0;
      39           4 :         waitpid(children[i], &status, 0);
      40           4 :         EXPECT_EQ(status, 0);
      41             :     }
      42             : 
      43           1 :     OSRDestroySpatialReference(hSRS);
      44           1 : }
      45             : 
      46             : }  // namespace

Generated by: LCOV version 1.14