mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
tests: Replace various function calls with their x variant
With fortification enabled, few function calls return result need to be checked, has they get the __wur macro enabled. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
This commit is contained in:
parent
8c4f69d711
commit
f6a532fbd0
@ -5,11 +5,13 @@
|
|||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <libc-diag.h>
|
#include <libc-diag.h>
|
||||||
|
|
||||||
|
#include <support/xstdio.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_test (int argc, char *argv[])
|
do_test (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
mtrace ();
|
mtrace ();
|
||||||
(void) freopen (argc == 1 ? "/dev/stdout" : argv[1], "a", stderr);
|
xfreopen (argc == 1 ? "/dev/stdout" : argv[1], "a", stderr);
|
||||||
/* Orient the stream. */
|
/* Orient the stream. */
|
||||||
fwprintf (stderr, L"hello world\n");
|
fwprintf (stderr, L"hello world\n");
|
||||||
char buf[20000];
|
char buf[20000];
|
||||||
|
@ -121,7 +121,7 @@ do_test (void)
|
|||||||
/* Change the root dir. */
|
/* Change the root dir. */
|
||||||
|
|
||||||
TEST_VERIFY (chroot ("/subdir") == 0);
|
TEST_VERIFY (chroot ("/subdir") == 0);
|
||||||
chdir ("/");
|
xchdir ("/");
|
||||||
|
|
||||||
/* Check we're NOT using the "inner" nsswitch.conf. */
|
/* Check we're NOT using the "inner" nsswitch.conf. */
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <support/xunistd.h>
|
||||||
|
|
||||||
|
|
||||||
#define OUT_OF_MEMORY \
|
#define OUT_OF_MEMORY \
|
||||||
do { \
|
do { \
|
||||||
@ -229,7 +231,8 @@ do_test (int argc, char *argv[])
|
|||||||
close (fd);
|
close (fd);
|
||||||
|
|
||||||
snprintf (buf, buflen, "%s/..", testdir);
|
snprintf (buf, buflen, "%s/..", testdir);
|
||||||
chdir (buf);
|
xchdir (buf);
|
||||||
|
|
||||||
/* We are now in the directory above the one we create the test
|
/* We are now in the directory above the one we create the test
|
||||||
directory in. */
|
directory in. */
|
||||||
|
|
||||||
@ -349,7 +352,7 @@ do_test (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
chdir (startdir);
|
xchdir (startdir);
|
||||||
|
|
||||||
/* Remove all the files. */
|
/* Remove all the files. */
|
||||||
chmod (testdir, 0700);
|
chmod (testdir, 0700);
|
||||||
|
@ -336,7 +336,7 @@ do_test (int argc, char *argv[])
|
|||||||
if (cwd == NULL)
|
if (cwd == NULL)
|
||||||
cwd = "..";
|
cwd = "..";
|
||||||
|
|
||||||
chdir (cwd);
|
xchdir (cwd);
|
||||||
rmdir (tmpdir);
|
rmdir (tmpdir);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <support/xunistd.h>
|
||||||
|
|
||||||
/* Prototype for our test function. */
|
/* Prototype for our test function. */
|
||||||
extern int do_test (int argc, char *argv[]);
|
extern int do_test (int argc, char *argv[]);
|
||||||
#include <test-skeleton.c>
|
#include <test-skeleton.c>
|
||||||
@ -159,7 +161,7 @@ do_test (int argc, char ** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < (int) (sizeof (symlinks) / sizeof (symlinks[0])); ++i)
|
for (i = 0; i < (int) (sizeof (symlinks) / sizeof (symlinks[0])); ++i)
|
||||||
symlink (symlinks[i].value, symlinks[i].name);
|
xsymlink (symlinks[i].value, symlinks[i].name);
|
||||||
|
|
||||||
int has_dir = mkdir ("doesExist", 0777) == 0;
|
int has_dir = mkdir ("doesExist", 0777) == 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user