-
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
Merged
chrissie-c
merged 7 commits into
ClusterLabs:main
from
chrissie-c:test-filesystem-sockets
Mar 21, 2022
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f4fe0e3
tests: Run IPC with use-filesystem-sockets active
chrissie-c 15e3e1b
Check for the right number of leftovers
chrissie-c 7682822
Catch stat() as well as __xstat()
chrissie-c 865e004
Use RTLD_NEXT
chrissie-c 8812662
use $() rather than ``
chrissie-c dde80a4
Cope with spaces in directory names
chrissie-c 8ebd848
Docs: quote DOXYGEN2MAN in Makefile.am rather than configure.ac
chrissie-c File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
__xstat seems to return -1 with errno==EFAULT in case the filename points to invalid memory instead of segfaulting.
Don't know if we need it that generic here but we might get called by unexpected callers and get confusing results.
Simple approach might be doing the original in any case and just compare and possibly fake result if return -1 and errno!=EFAULT.