-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: Run IPC with use-filesystem-sockets active #455
Changes from 5 commits
f4fe0e3
15e3e1b
7682822
865e004
8812662
dde80a4
8ebd848
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh | ||
# | ||
# Run the IPC tests under the stat wrapper, | ||
# this simulates /etc/libqb/use-filesystem-sockets existing | ||
# so we can test both options without breaking other things | ||
# that might be running on this system | ||
# | ||
if [ "$(uname -s)" = "Linux" ] | ||
then | ||
if [ -f $(pwd)/.libs/libstat_wrapper.so ] | ||
then | ||
export LD_PRELOAD=$(pwd)/.libs/libstat_wrapper.so | ||
else | ||
export LD_PRELOAD=$(pwd)/libstat_wrapper.so | ||
fi | ||
./ipc.test | ||
else | ||
exit 0 | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* 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" | ||
#if defined(QB_LINUX) || defined(QB_CYGWIN) | ||
#include <gnu/lib-names.h> | ||
#endif | ||
|
||
// __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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. __xstat seems to return -1 with errno==EFAULT in case the filename points to invalid memory instead of segfaulting. |
||
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 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
best to have:
export LD_PRELOAD="$(pwd)/.libs/libstat_wrapper.so" in case pwd contains spaces... it doesn´t happen in CI or any sane systems.. but it can happen :)