mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
tests: fix skipping of mtab simulation tests
Where rpl_fopen() is used rather than fopen(), wrapping fopen() is ineffective. Note rpl_fopen() is used as of glibc-2.39 at least (due to fflush and fclose being replaced). * tests/df/no-mtab-status.sh: Wrap open() rather than fopen(). * tests/df/skip-duplicates.sh: Likewise.
This commit is contained in:
1 parent
e71b24cedc
commit
6f1ec80f31
2 files changed
+41
-22
No files matched your search
+21
-11
@@ -31,39 +31,49 @@ grep '^#define HAVE_GETMNTENT 1' $CONFIG_HEADER > /dev/null \
|
||||
cat > k.c <<EOF || framework_failure_
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <mntent.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#define STREQ(a, b) (strcmp (a, b) == 0)
|
||||
|
||||
FILE* fopen(const char *path, const char *mode)
|
||||
int open(const char *path, int flags, ...)
|
||||
{
|
||||
static FILE* (*fopen_func)(char const *, char const *);
|
||||
static int (*open_func)(const char *, int, ...);
|
||||
|
||||
/* get reference to original (libc provided) fopen */
|
||||
if (!fopen_func)
|
||||
/* get reference to original (libc provided) open */
|
||||
if (!open_func)
|
||||
{
|
||||
fopen_func = (FILE*(*)(char const *, char const *))
|
||||
dlsym(RTLD_NEXT, "fopen");
|
||||
if (!fopen_func)
|
||||
open_func = (int(*)(const char *, int, ...))
|
||||
dlsym(RTLD_NEXT, "open");
|
||||
if (!open_func)
|
||||
{
|
||||
fprintf (stderr, "Failed to find fopen()\n");
|
||||
fprintf (stderr, "Failed to find open()\n");
|
||||
errno = ESRCH;
|
||||
return NULL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
va_list ap;
|
||||
va_start (ap, flags);
|
||||
mode_t mode = (sizeof (mode_t) < sizeof (int)
|
||||
? va_arg (ap, int)
|
||||
: va_arg (ap, mode_t));
|
||||
va_end (ap);
|
||||
|
||||
/* Returning ENOENT here will get read_file_system_list()
|
||||
to fall back to using getmntent() below. */
|
||||
if (STREQ (path, "/proc/self/mountinfo"))
|
||||
{
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
return fopen_func(path, mode);
|
||||
return open_func(path, flags, mode);
|
||||
}
|
||||
|
||||
struct mntent *getmntent (FILE *fp)
|
||||
|
||||
+20
-11
@@ -43,38 +43,47 @@ cat > k.c <<EOF || framework_failure_
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <mntent.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#define STREQ(a, b) (strcmp (a, b) == 0)
|
||||
|
||||
FILE* fopen(const char *path, const char *mode)
|
||||
int open(const char *path, int flags, ...)
|
||||
{
|
||||
static FILE* (*fopen_func)(char const *, char const *);
|
||||
static int (*open_func)(const char *, int, ...);
|
||||
|
||||
/* get reference to original (libc provided) fopen */
|
||||
if (!fopen_func)
|
||||
/* get reference to original (libc provided) open */
|
||||
if (!open_func)
|
||||
{
|
||||
fopen_func = (FILE*(*)(char const *, char const *))
|
||||
dlsym(RTLD_NEXT, "fopen");
|
||||
if (!fopen_func)
|
||||
open_func = (int(*)(const char *, int, ...))
|
||||
dlsym(RTLD_NEXT, "open");
|
||||
if (!open_func)
|
||||
{
|
||||
fprintf (stderr, "Failed to find fopen()\n");
|
||||
fprintf (stderr, "Failed to find open()\n");
|
||||
errno = ESRCH;
|
||||
return NULL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
va_list ap;
|
||||
va_start (ap, flags);
|
||||
mode_t mode = (sizeof (mode_t) < sizeof (int)
|
||||
? va_arg (ap, int)
|
||||
: va_arg (ap, mode_t));
|
||||
va_end (ap);
|
||||
|
||||
/* Returning ENOENT here will get read_file_system_list()
|
||||
to fall back to using getmntent() below. */
|
||||
if (STREQ (path, "/proc/self/mountinfo"))
|
||||
{
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
return fopen_func(path, mode);
|
||||
return open_func(path, flags, mode);
|
||||
}
|
||||
|
||||
#define STREQ(a, b) (strcmp (a, b) == 0)
|
||||
|
||||
Reference in new issue
Block a user