LCOV - code coverage report
Current view: top level - src/bindings/intercept/env/tests - test_fork.cpp (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 12 12 100.0 %
Date: 2019-09-12 12:28:41 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /**
       2             :  * @file
       3             :  *
       4             :  * @brief Tests for the getenv library
       5             :  *
       6             :  * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
       7             :  *
       8             :  */
       9             : 
      10             : #include <gtest/gtest.h>
      11             : #include <kdbconfig.h>
      12             : #include <kdbgetenv.h>
      13             : 
      14             : namespace ckdb
      15             : {
      16             : extern pthread_mutex_t elektraGetEnvMutex;
      17             : }
      18             : 
      19          80 : TEST (GetEnv, SimpleFork)
      20             : {
      21             :         using namespace ckdb;
      22           8 :         elektraOpen (nullptr, nullptr);
      23           8 :         setenv ("does-exist", "hello", 1);
      24          16 :         ASSERT_NE (getenv ("does-exist"), static_cast<char *> (nullptr));
      25          48 :         EXPECT_EQ (getenv ("does-exist"), std::string ("hello"));
      26             : #if VERBOSE
      27             :         pid_t f;
      28             :         f = fork ();
      29             :         std::cerr << "FORK " << f << std::endl;
      30             : #else
      31           8 :         fork ();
      32             : #endif
      33          16 :         ASSERT_NE (getenv ("does-exist"), static_cast<char *> (nullptr));
      34          48 :         EXPECT_EQ (getenv ("does-exist"), std::string ("hello"));
      35             : 
      36             : #if VERBOSE
      37             :         f = fork ();
      38             :         std::cerr << "FORK " << f << std::endl;
      39             : #else
      40           8 :         fork ();
      41             : #endif
      42          16 :         ASSERT_NE (getenv ("does-exist"), static_cast<char *> (nullptr));
      43          48 :         EXPECT_EQ (getenv ("does-exist"), std::string ("hello"));
      44           8 :         elektraClose ();
      45             : }
      46             : 
      47             : #include "main.cpp"

Generated by: LCOV version 1.13