root/lib/common/mock_private.h

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

INCLUDED FROM


   1 /*
   2  * Copyright 2021-2024 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 Lesser General Public License
   7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #ifndef PCMK__COMMON_MOCK_PRIVATE__H
  11 #define PCMK__COMMON_MOCK_PRIVATE__H
  12 
  13 #include <pwd.h>                    // struct passwd
  14 #include <stdbool.h>                // bool
  15 #include <stdio.h>                  // FILE
  16 #include <stdlib.h>
  17 #include <string.h>
  18 #include <sys/types.h>              // pid_t, size_t
  19 #include <sys/utsname.h>
  20 #include <unistd.h>
  21 #include <grp.h>                    // struct group
  22 
  23 #include <crm/common/results.h>     // _Noreturn
  24 
  25 #ifdef __cplusplus
  26 extern "C" {
  27 
  28 // C++ doesn't support the restrict keyword
  29 #define restrict
  30 #endif
  31 
  32 /* This header is for the sole use of libcrmcommon_test and unit tests */
  33 
  34 _Noreturn void __real_abort(void);
  35 _Noreturn void __wrap_abort(void);
  36 
  37 extern bool pcmk__mock_calloc;
  38 void *__real_calloc(size_t nmemb, size_t size);
  39 void *__wrap_calloc(size_t nmemb, size_t size);
  40 
  41 extern bool pcmk__mock_fopen;
  42 FILE *__real_fopen(const char *pathname, const char *mode);
  43 FILE *__wrap_fopen(const char *pathname, const char *mode);
  44 #ifdef HAVE_FOPEN64
  45 FILE *__real_fopen64(const char *pathname, const char *mode);
  46 FILE *__wrap_fopen64(const char *pathname, const char *mode);
  47 #endif
  48 
  49 extern bool pcmk__mock_getenv;
  50 char *__real_getenv(const char *name);
  51 char *__wrap_getenv(const char *name);
  52 
  53 extern bool pcmk__mock_realloc;
  54 void *__real_realloc(void *ptr, size_t size);
  55 void *__wrap_realloc(void *ptr, size_t size);
  56 
  57 extern bool pcmk__mock_setenv;
  58 int __real_setenv(const char *name, const char *value, int overwrite);
  59 int __wrap_setenv(const char *name, const char *value, int overwrite);
  60 
  61 extern bool pcmk__mock_unsetenv;
  62 int __real_unsetenv(const char *name);
  63 int __wrap_unsetenv(const char *name);
  64 
  65 extern bool pcmk__mock_getpid;
  66 pid_t __real_getpid(void);
  67 pid_t __wrap_getpid(void);
  68 
  69 extern bool pcmk__mock_grent;
  70 void __real_setgrent(void);
  71 void __wrap_setgrent(void);
  72 struct group * __wrap_getgrent(void);
  73 struct group * __real_getgrent(void);
  74 void __wrap_endgrent(void);
  75 void __real_endgrent(void);
  76 
  77 extern bool pcmk__mock_getpwnam_r;
  78 int __real_getpwnam_r(const char *name, struct passwd *pwd,
  79                       char *buf, size_t buflen, struct passwd **result);
  80 int __wrap_getpwnam_r(const char *name, struct passwd *pwd,
  81                       char *buf, size_t buflen, struct passwd **result);
  82 
  83 extern bool pcmk__mock_readlink;
  84 ssize_t __real_readlink(const char *restrict path, char *restrict buf,
  85                         size_t bufsize);
  86 ssize_t __wrap_readlink(const char *restrict path, char *restrict buf,
  87                         size_t bufsize);
  88 
  89 extern bool pcmk__mock_strdup;
  90 char *__real_strdup(const char *s);
  91 char *__wrap_strdup(const char *s);
  92 
  93 #ifdef __cplusplus
  94 }
  95 #endif
  96 
  97 #endif  // PCMK__COMMON_MOCK_PRIVATE__H

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