root/lib/common/mock_private.h

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

INCLUDED FROM


   1 /*
   2  * Copyright 2021-2023 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 MOCK_PRIVATE__H
  11 #  define MOCK_PRIVATE__H
  12 
  13 #include <pwd.h>
  14 #include <stdbool.h>
  15 #include <stdio.h>
  16 #include <stdlib.h>
  17 #include <string.h>
  18 #include <sys/types.h>
  19 #include <sys/utsname.h>
  20 #include <unistd.h>
  21 #include <grp.h>
  22 
  23 /* This header is for the sole use of libcrmcommon_test and unit tests */
  24 
  25 extern bool pcmk__mock_calloc;
  26 void *__real_calloc(size_t nmemb, size_t size);
  27 void *__wrap_calloc(size_t nmemb, size_t size);
  28 
  29 extern bool pcmk__mock_fopen;
  30 FILE *__real_fopen(const char *pathname, const char *mode);
  31 FILE *__wrap_fopen(const char *pathname, const char *mode);
  32 #ifdef HAVE_FOPEN64
  33 FILE *__real_fopen64(const char *pathname, const char *mode);
  34 FILE *__wrap_fopen64(const char *pathname, const char *mode);
  35 #endif
  36 
  37 extern bool pcmk__mock_getenv;
  38 char *__real_getenv(const char *name);
  39 char *__wrap_getenv(const char *name);
  40 
  41 extern bool pcmk__mock_setenv;
  42 int __real_setenv(const char *name, const char *value, int overwrite);
  43 int __wrap_setenv(const char *name, const char *value, int overwrite);
  44 
  45 extern bool pcmk__mock_unsetenv;
  46 int __real_unsetenv(const char *name);
  47 int __wrap_unsetenv(const char *name);
  48 
  49 extern bool pcmk__mock_getpid;
  50 pid_t __real_getpid(void);
  51 pid_t __wrap_getpid(void);
  52 
  53 extern bool pcmk__mock_grent;
  54 void __real_setgrent(void);
  55 void __wrap_setgrent(void);
  56 struct group * __wrap_getgrent(void);
  57 struct group * __real_getgrent(void);
  58 void __wrap_endgrent(void);
  59 void __real_endgrent(void);
  60 
  61 extern bool pcmk__mock_getpwnam_r;
  62 int __real_getpwnam_r(const char *name, struct passwd *pwd,
  63                       char *buf, size_t buflen, struct passwd **result);
  64 int __wrap_getpwnam_r(const char *name, struct passwd *pwd,
  65                       char *buf, size_t buflen, struct passwd **result);
  66 
  67 extern bool pcmk__mock_readlink;
  68 ssize_t __real_readlink(const char *restrict path, char *restrict buf,
  69                         size_t bufsize);
  70 ssize_t __wrap_readlink(const char *restrict path, char *restrict buf,
  71                         size_t bufsize);
  72 
  73 extern bool pcmk__mock_strdup;
  74 char *__real_strdup(const char *s);
  75 char *__wrap_strdup(const char *s);
  76 
  77 extern bool pcmk__mock_uname;
  78 int __real_uname(struct utsname *buf);
  79 int __wrap_uname(struct utsname *buf);
  80 
  81 #endif  // MOCK_PRIVATE__H

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