mirror of git://sourceware.org/git/glibc.git
testsuite: Update tests for 'xfmemopen' use
Convert tests to use 'xfmemopen' rather than open-coding error checks with 'fmemopen' or plain missing them, where 'fmemopen' itself is not the scope of testing. Leave 'fmemopen' tests alone. Reviewed-by: Florian Weimer <fweimer@redhat.com>
This commit is contained in:
parent
fe709cc245
commit
2d47b01de0
|
|
@ -103,8 +103,7 @@ do_test (int argc, char *argv[])
|
|||
|
||||
/* Some hooks are called more than once but the test only check if any
|
||||
is called at least once. */
|
||||
FILE *out = fmemopen (result.err.buffer, result.err.length, "r");
|
||||
TEST_VERIFY (out != NULL);
|
||||
FILE *out = xfmemopen (result.err.buffer, result.err.length, "r");
|
||||
char *buffer = NULL;
|
||||
size_t buffer_length = 0;
|
||||
while (xgetline (&buffer, &buffer_length, out))
|
||||
|
|
|
|||
|
|
@ -74,8 +74,7 @@ do_test (int argc, char *argv[])
|
|||
|
||||
bool find_symbind = false;
|
||||
|
||||
FILE *out = fmemopen (result.err.buffer, result.err.length, "r");
|
||||
TEST_VERIFY (out != NULL);
|
||||
FILE *out = xfmemopen (result.err.buffer, result.err.length, "r");
|
||||
char *buffer = NULL;
|
||||
size_t buffer_length = 0;
|
||||
while (xgetline (&buffer, &buffer_length, out))
|
||||
|
|
|
|||
|
|
@ -95,8 +95,7 @@ do_test (int argc, char *argv[])
|
|||
bool vdso_audit_found = false;
|
||||
uintptr_t vdso_audit = 0;
|
||||
|
||||
FILE *out = fmemopen (result.err.buffer, result.err.length, "r");
|
||||
TEST_VERIFY (out != NULL);
|
||||
FILE *out = xfmemopen (result.err.buffer, result.err.length, "r");
|
||||
char *buffer = NULL;
|
||||
size_t buffer_length = 0;
|
||||
while (xgetline (&buffer, &buffer_length, out))
|
||||
|
|
|
|||
|
|
@ -91,8 +91,7 @@ do_one_test (int argc, char *argv[], bool pass_dlclose_flag)
|
|||
support_capture_subprocess_check (&result, "tst-audit22", 0, sc_allow_stderr);
|
||||
|
||||
{
|
||||
FILE *fp = fmemopen (result.err.buffer, result.err.length, "r");
|
||||
TEST_VERIFY (fp != NULL);
|
||||
FILE *fp = xfmemopen (result.err.buffer, result.err.length, "r");
|
||||
unsigned int line = 0;
|
||||
char *buffer = NULL;
|
||||
size_t buffer_length = 0;
|
||||
|
|
@ -132,8 +131,7 @@ do_one_test (int argc, char *argv[], bool pass_dlclose_flag)
|
|||
uintptr_t last_act_cookie = -1;
|
||||
bool seen_first_objclose = false;
|
||||
|
||||
FILE *out = fmemopen (result.err.buffer, result.err.length, "r");
|
||||
TEST_VERIFY (out != NULL);
|
||||
FILE *out = xfmemopen (result.err.buffer, result.err.length, "r");
|
||||
char *buffer = NULL;
|
||||
size_t buffer_length = 0;
|
||||
unsigned int line = 0;
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@
|
|||
static void
|
||||
compare_output (void *buffer, size_t length, const char *ref[], size_t reflen)
|
||||
{
|
||||
FILE *in = fmemopen (buffer, length, "r");
|
||||
TEST_VERIFY_EXIT (in != NULL);
|
||||
FILE *in = xfmemopen (buffer, length, "r");
|
||||
char *line = NULL;
|
||||
size_t linelen = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include <support/check.h>
|
||||
#include <support/support.h>
|
||||
#include <support/xptrace.h>
|
||||
#include <support/xstdio.h>
|
||||
#include <support/xunistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <errno.h>
|
||||
|
|
@ -113,8 +114,7 @@ do_test (void)
|
|||
#define STRINPUT(size) XSTRINPUT(size)
|
||||
#define XSTRINPUT(size) "%" # size "s"
|
||||
|
||||
FILE *out = fmemopen (pldd.out.buffer, pldd.out.length, "r");
|
||||
TEST_VERIFY (out != NULL);
|
||||
FILE *out = xfmemopen (pldd.out.buffer, pldd.out.length, "r");
|
||||
|
||||
/* First line is in the form of <pid>: <full path of executable> */
|
||||
TEST_COMPARE (fscanf (out, "%u: " STRINPUT (BUFFERLEN), &pid, buffer), 2);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include <support/check.h>
|
||||
#include <support/support.h>
|
||||
#include <support/test-driver.h>
|
||||
#include <support/xstdio.h>
|
||||
|
||||
static int
|
||||
do_test (void)
|
||||
|
|
@ -41,8 +42,7 @@ do_test (void)
|
|||
char *lineptr = NULL;
|
||||
size_t linelen = 0;
|
||||
char membuf[] = "abc\0d\nef\0";
|
||||
FILE *memstream = fmemopen (membuf, sizeof (membuf), "r");
|
||||
TEST_VERIFY_EXIT (memstream != NULL);
|
||||
FILE *memstream = xfmemopen (membuf, sizeof (membuf), "r");
|
||||
TEST_VERIFY (getdelim (&lineptr, &linelen, '\0', memstream) != -1);
|
||||
TEST_COMPARE_BLOB (lineptr, 4, "abc\0", 4);
|
||||
TEST_VERIFY (getdelim (&lineptr, &linelen, '\0', memstream) != -1);
|
||||
|
|
|
|||
|
|
@ -84,9 +84,7 @@ do_test (void)
|
|||
memcpy (ntfi.buffer, s, sizeof (s));
|
||||
|
||||
ic = i = 0;
|
||||
f = fmemopen (b, sizeof (s), "r");
|
||||
if (f == NULL)
|
||||
FAIL_EXIT1 ("fmemopen: %m");
|
||||
f = xfmemopen (b, sizeof (s), "r");
|
||||
|
||||
c = e - 1;
|
||||
TEST_VERIFY_EXIT (ftell (f) == i);
|
||||
|
|
@ -168,9 +166,7 @@ do_test (void)
|
|||
xfclose (f);
|
||||
|
||||
ic = i = 0;
|
||||
f = fmemopen (b, 3, "r");
|
||||
if (f == NULL)
|
||||
FAIL_EXIT1 ("fmemopen: %m");
|
||||
f = xfmemopen (b, 3, "r");
|
||||
|
||||
c = e - 2;
|
||||
TEST_VERIFY_EXIT (ftell (f) == i);
|
||||
|
|
@ -192,9 +188,7 @@ do_test (void)
|
|||
xfclose (f);
|
||||
|
||||
ic = i = 0;
|
||||
f = fmemopen (b, 3, "r");
|
||||
if (f == NULL)
|
||||
FAIL_EXIT1 ("fmemopen: %m");
|
||||
f = xfmemopen (b, 3, "r");
|
||||
|
||||
c = e - 1;
|
||||
TEST_VERIFY_EXIT (ftell (f) == i);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <libc-diag.h>
|
||||
#include <support/check.h>
|
||||
#include <support/xstdio.h>
|
||||
|
||||
#define PD "\xd9\xab"
|
||||
|
||||
|
|
@ -32,7 +33,7 @@ do_test (void)
|
|||
FAIL_EXIT1 ("setlocale (LC_ALL, \"fa_IR.UTF-8\")");
|
||||
|
||||
char s[] = "+" PD "e";
|
||||
FILE *f = fmemopen (s, strlen (s), "r");
|
||||
FILE *f = xfmemopen (s, strlen (s), "r");
|
||||
|
||||
/* Avoid: "warning: 'I' flag used with '%f' gnu_scanf format [-Wformat=]";
|
||||
cf. GCC PR c/119514. */
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <libc-diag.h>
|
||||
#include <support/check.h>
|
||||
#include <support/xstdio.h>
|
||||
|
||||
#define P1 "\xdb\xb1"
|
||||
#define P2 "\xdb\xb2"
|
||||
|
|
@ -33,9 +34,7 @@ do_test (void)
|
|||
FAIL_EXIT1 ("setlocale (LC_ALL, \"fa_IR.UTF-8\")");
|
||||
|
||||
char s[] = P1 P2;
|
||||
FILE *f = fmemopen (s, strlen (s), "r");
|
||||
if (f == NULL)
|
||||
FAIL_EXIT1 ("fmemopen: %m");
|
||||
FILE *f = xfmemopen (s, strlen (s), "r");
|
||||
|
||||
/* Avoid: "warning: 'I' flag used with '%f' gnu_scanf format [-Wformat=]";
|
||||
cf. GCC PR c/119514. */
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <libc-diag.h>
|
||||
#include <support/check.h>
|
||||
#include <support/xstdio.h>
|
||||
|
||||
#define PD "\xd9\xab"
|
||||
|
||||
|
|
@ -32,9 +33,7 @@ do_test (void)
|
|||
FAIL_EXIT1 ("setlocale (LC_ALL, \"ps_AF.UTF-8\")");
|
||||
|
||||
char s[] = "1" PD;
|
||||
FILE *f = fmemopen (s, strlen (s), "r");
|
||||
if (f == NULL)
|
||||
FAIL_EXIT1 ("fmemopen: %m");
|
||||
FILE *f = xfmemopen (s, strlen (s), "r");
|
||||
|
||||
/* This should succeed parsing a floating-point number, and leave '\xd9',
|
||||
'\xab' in the input. */
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <support/check.h>
|
||||
#include <support/xstdio.h>
|
||||
|
||||
struct const_mntent
|
||||
{
|
||||
|
|
@ -54,13 +55,7 @@ do_test (void)
|
|||
{
|
||||
char buf[128];
|
||||
struct mntent *ret, curtest;
|
||||
FILE *fp = fmemopen (buf, sizeof (buf), "w+");
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
printf ("Failed to open file\n");
|
||||
return 1;
|
||||
}
|
||||
FILE *fp = xfmemopen (buf, sizeof (buf), "w+");
|
||||
|
||||
curtest.mnt_fsname = strdupa (tests[i].mnt_fsname);
|
||||
curtest.mnt_dir = strdupa (tests[i].mnt_dir);
|
||||
|
|
|
|||
|
|
@ -520,9 +520,7 @@ check_syslog_perror (bool large)
|
|||
: send_openlog_callback,
|
||||
&(int){LOG_PERROR});
|
||||
|
||||
FILE *mfp = fmemopen (result.err.buffer, result.err.length, "r");
|
||||
if (mfp == NULL)
|
||||
FAIL_EXIT1 ("fmemopen: %m");
|
||||
FILE *mfp = xfmemopen (result.err.buffer, result.err.length, "r");
|
||||
if (large)
|
||||
check_syslog_console_read_large (mfp);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <support/xstdio.h>
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
|
|
@ -27,7 +29,7 @@ main (void)
|
|||
double d;
|
||||
char s[] = "+.e";
|
||||
|
||||
f = fmemopen (s, strlen (s), "r");
|
||||
f = xfmemopen (s, strlen (s), "r");
|
||||
/* This should fail to parse a floating-point number, and leave 'e' in the
|
||||
input. */
|
||||
lost |= (fscanf (f, "%lf", &d) != 0);
|
||||
|
|
|
|||
|
|
@ -45,9 +45,7 @@ do_test (void)
|
|||
memcpy (ntfi.buffer, s, sizeof (s));
|
||||
|
||||
i = 0;
|
||||
f = fmemopen (b, sizeof (s), "r");
|
||||
if (f == NULL)
|
||||
FAIL_EXIT1 ("fmemopen: %m");
|
||||
f = xfmemopen (b, sizeof (s), "r");
|
||||
|
||||
c = e - 1;
|
||||
TEST_VERIFY_EXIT (ftell (f) == i);
|
||||
|
|
@ -114,9 +112,7 @@ do_test (void)
|
|||
xfclose (f);
|
||||
|
||||
i = 0;
|
||||
f = fmemopen (b, 3, "r");
|
||||
if (f == NULL)
|
||||
FAIL_EXIT1 ("fmemopen: %m");
|
||||
f = xfmemopen (b, 3, "r");
|
||||
|
||||
c = e - 1;
|
||||
TEST_VERIFY_EXIT (ftell (f) == i);
|
||||
|
|
@ -144,9 +140,7 @@ do_test (void)
|
|||
xfclose (f);
|
||||
|
||||
i = 0;
|
||||
f = fmemopen (b, 3, "r");
|
||||
if (f == NULL)
|
||||
FAIL_EXIT1 ("fmemopen: %m");
|
||||
f = xfmemopen (b, 3, "r");
|
||||
|
||||
c = e - 2;
|
||||
TEST_VERIFY_EXIT (ftell (f) == i);
|
||||
|
|
|
|||
|
|
@ -2,10 +2,12 @@
|
|||
https://sourceware.org/bugzilla/show_bug.cgi?id=713. */
|
||||
#include <stdio.h>
|
||||
|
||||
#include <support/xstdio.h>
|
||||
|
||||
static int
|
||||
do_test (void)
|
||||
{
|
||||
FILE *fp = fmemopen ((char *) "hello", 5, "r");
|
||||
FILE *fp = xfmemopen ((char *) "hello", 5, "r");
|
||||
char buf[2];
|
||||
char *bp = fgets (buf, sizeof (buf), fp);
|
||||
printf ("fgets: %s\n", bp == buf ? "OK" : "ERROR");
|
||||
|
|
|
|||
Loading…
Reference in New Issue