libqb/tests/_libstat_wrapper.c
Chrissie Caulfield a3aedbc419
tests: allow -j to work (#485)
build: fix several issues with building tests

- MAINTAINERCLEANFILES should not rely on conditionals
  that could or could not clean files.

- EXTRA_DIST should not rely on conditonals that could
  or could not add files to the final tarball.
  sources should always ship.

- CLEANFILES should not rely on conditionals as
  ./configure can be done in between builds leaving
  stray files around.

- (cosmetic) move distclean-local: target with clean-local.

- drop old ipc_sock.test, start.test and resources.test
  shell files.

- fix make distcheck -j:
  - stop shipping or not shipping libstat_wrapper.so.
    libtool will only generate the .so when installing
    a shared library (--enable-install-tests).
  - make libstat_wrapper a module in a similar fashion
    of _failure_injection.
  - build ipc_sock.test in a similar fashion as ipc.test
    and link as module _libstat_wrapper.la.
    this solves multiple issues of having the binary
    in the final test builddir, no need to detect if
    libstat_wrapper.so is installed or not and workaround
    libtool different linking methods for inst vs noinst
    libraries.

- fix ipc.test linking with GLIB that should not be
  dependent on HAVE_FAILURE_INJECTION.

Run tests in parallel with dependancies
Make sure the two IPC tests use different socket names
Shortedn some names so they fit with the new ipc-names
remove ipc-test-name-sock
Fix resources.test now that ipc_sock is being run properly

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
2023-05-26 20:21:43 +02:00

56 lines
1.3 KiB
C

/*
* Simulate FORCESOCKETSFILE existing for the IPC tests
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <dlfcn.h>
#include <string.h>
#include <sys/stat.h>
#include "../include/config.h"
// __xstat for earlier libc
int __xstat(int __ver, const char *__filename, struct stat *__stat_buf)
{
#if defined(QB_LINUX) || defined(QB_CYGWIN)
static int opened = 0;
static int (*real_xstat)(int __ver, const char *__filename, void *__stat_buf);
if (!opened) {
real_xstat = dlsym(RTLD_NEXT, "__xstat");
opened = 1;
}
if (strcmp(__filename, FORCESOCKETSFILE) == 0) {
fprintf(stderr, "__xstat called for %s\n", __filename);
return 0; /* it exists! */
}
return real_xstat(__ver, __filename, __stat_buf);
#else
return -1; /* Error in the unlikely event we get called on *BSD* */
#endif
}
// stat for F35 and later
int stat(const char *__filename, struct stat *__stat_buf)
{
#if defined(QB_LINUX) || defined(QB_CYGWIN)
static int opened = 0;
static int (*real_stat)(const char *__filename, void *__stat_buf);
if (!opened) {
real_stat = dlsym(RTLD_NEXT, "stat");
opened = 1;
}
if (strcmp(__filename, FORCESOCKETSFILE) == 0) {
fprintf(stderr, "stat called for %s\n", __filename);
return 0; /* it exists! */
}
return real_stat(__filename, __stat_buf);
#else
return -1; /* Error in the unlikely event we get called on *BSD* */
#endif
}