root/lib/common/tests/utils/pcmk__getpid_s_test.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. pcmk__getpid_s_test

   1 /*
   2  * Copyright 2022 the Pacemaker project contributors
   3  *
   4  * The version control history for this file may have further details.
   5  *
   6  * This source code is licensed under the GNU General Public License version 2
   7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #include <crm_internal.h>
  11 
  12 #include <crm/common/unittest_internal.h>
  13 
  14 #include "mock_private.h"
  15 
  16 #include <sys/types.h>
  17 #include <unistd.h>
  18 
  19 static void
  20 pcmk__getpid_s_test(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  21 {
  22     char *retval;
  23 
  24     // Set getpid() return value
  25     pcmk__mock_getpid = true;
  26     will_return(__wrap_getpid, 1234);
  27 
  28     retval = pcmk__getpid_s();
  29     assert_non_null(retval);
  30     assert_string_equal("1234", retval);
  31 
  32     free(retval);
  33 
  34     pcmk__mock_getpid = false;
  35 }
  36 
  37 PCMK__UNIT_TEST(NULL, NULL,
  38                 cmocka_unit_test(pcmk__getpid_s_test))

/* [previous][next][first][last][top][bottom][index][help] */