|
Packit Service |
ac4cd2 |
/* Check _dl_exception_create_format.
|
|
Packit Service |
ac4cd2 |
Copyright (C) 2018 Free Software Foundation, Inc.
|
|
Packit Service |
ac4cd2 |
This file is part of the GNU C Library.
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
ac4cd2 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
ac4cd2 |
License as published by the Free Software Foundation; either
|
|
Packit Service |
ac4cd2 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
ac4cd2 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
ac4cd2 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
ac4cd2 |
Lesser General Public License for more details.
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
ac4cd2 |
License along with the GNU C Library; if not, see
|
|
Packit Service |
ac4cd2 |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
#include <ldsodefs.h>
|
|
Packit Service |
ac4cd2 |
#include <array_length.h>
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
#include <support/check.h>
|
|
Packit Service |
ac4cd2 |
#include <support/xunistd.h>
|
|
Packit Service |
ac4cd2 |
#include <support/capture_subprocess.h>
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
#define TEST(es, objn, fmt, ...) \
|
|
Packit Service |
ac4cd2 |
({ \
|
|
Packit Service |
ac4cd2 |
struct dl_exception exception; \
|
|
Packit Service |
ac4cd2 |
_dl_exception_create_format (&exception, objn, fmt, __VA_ARGS__); \
|
|
Packit Service |
ac4cd2 |
TEST_COMPARE_STRING (exception.objname, objn == NULL ? "" : objn); \
|
|
Packit Service |
ac4cd2 |
TEST_COMPARE_STRING (exception.errstring, es); \
|
|
Packit Service |
ac4cd2 |
_dl_exception_free (&exception); \
|
|
Packit Service |
ac4cd2 |
})
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
static void
|
|
Packit Service |
ac4cd2 |
do_test_invalid_conversion (void *closure)
|
|
Packit Service |
ac4cd2 |
{
|
|
Packit Service |
ac4cd2 |
TEST ("(null)", NULL, "%p", NULL);
|
|
Packit Service |
ac4cd2 |
}
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
/* Exit status after abnormal termination. */
|
|
Packit Service |
ac4cd2 |
static int invalid_status;
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
static void
|
|
Packit Service |
ac4cd2 |
init_invalid_status (void)
|
|
Packit Service |
ac4cd2 |
{
|
|
Packit Service |
ac4cd2 |
pid_t pid = xfork ();
|
|
Packit Service |
ac4cd2 |
if (pid == 0)
|
|
Packit Service |
ac4cd2 |
_exit (127);
|
|
Packit Service |
ac4cd2 |
xwaitpid (pid, &invalid_status, 0);
|
|
Packit Service |
ac4cd2 |
if (WIFEXITED (invalid_status))
|
|
Packit Service |
ac4cd2 |
invalid_status = WEXITSTATUS (invalid_status);
|
|
Packit Service |
ac4cd2 |
}
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
static int
|
|
Packit Service |
ac4cd2 |
do_test (void)
|
|
Packit Service |
ac4cd2 |
{
|
|
Packit Service |
ac4cd2 |
init_invalid_status ();
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
TEST ("test", NULL, "%s", "test");
|
|
Packit Service |
ac4cd2 |
TEST ("test-test", NULL, "%s-test", "test");
|
|
Packit Service |
ac4cd2 |
TEST ("test", "test", "%s", "test");
|
|
Packit Service |
ac4cd2 |
TEST ("test-test", "test", "%s-test", "test");
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
TEST ("test%", NULL, "%s%%", "test");
|
|
Packit Service |
ac4cd2 |
TEST ("test%-test", NULL, "%s%%-test", "test");
|
|
Packit Service |
ac4cd2 |
TEST ("test%", "test", "%s%%", "test");
|
|
Packit Service |
ac4cd2 |
TEST ("test%-test", "test", "%s%%-test", "test");
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
TEST ("0000007b", NULL, "%x", 123);
|
|
Packit Service |
ac4cd2 |
TEST ("0000007b-test", NULL, "%x-test", 123);
|
|
Packit Service |
ac4cd2 |
TEST ("0000007b", "test", "%x", 123);
|
|
Packit Service |
ac4cd2 |
TEST ("0000007b-test", "test", "%x-test", 123);
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
#define TEST_LONG(es, objn, fmt, ...) \
|
|
Packit Service |
ac4cd2 |
({ \
|
|
Packit Service |
ac4cd2 |
if (sizeof (int) == sizeof (long int)) \
|
|
Packit Service |
ac4cd2 |
TEST (es, objn, fmt, __VA_ARGS__); \
|
|
Packit Service |
ac4cd2 |
else \
|
|
Packit Service |
ac4cd2 |
TEST ("ffffffff" es, objn, fmt, __VA_ARGS__); \
|
|
Packit Service |
ac4cd2 |
})
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
TEST_LONG ("fffffffd", NULL, "%lx", (long int)~2ul);
|
|
Packit Service |
ac4cd2 |
TEST_LONG ("fffffffd-test", NULL, "%lx-test", (long int)~2ul);
|
|
Packit Service |
ac4cd2 |
TEST_LONG ("fffffffd", "test", "%lx", (long int)~2ul);
|
|
Packit Service |
ac4cd2 |
TEST_LONG ("fffffffd-test", "test", "%lx-test", (long int)~2ul);
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
TEST_LONG ("fffffffe", NULL, "%zx", (size_t)~1ul);
|
|
Packit Service |
ac4cd2 |
TEST_LONG ("fffffffe-test", NULL, "%zx-test", (size_t)~1ul);
|
|
Packit Service |
ac4cd2 |
TEST_LONG ("fffffffe", "test", "%zx", (size_t)~1ul);
|
|
Packit Service |
ac4cd2 |
TEST_LONG ("fffffffe-test", "test", "%zx-test", (size_t)~1ul);
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
struct support_capture_subprocess result;
|
|
Packit Service |
ac4cd2 |
result = support_capture_subprocess (do_test_invalid_conversion, NULL);
|
|
Packit Service |
ac4cd2 |
support_capture_subprocess_check (&result, "dl-exception",
|
|
Packit Service |
ac4cd2 |
invalid_status, sc_allow_stderr);
|
|
Packit Service |
ac4cd2 |
TEST_COMPARE_STRING (result.err.buffer,
|
|
Packit Service |
ac4cd2 |
"Fatal error: invalid format in exception string\n");
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
return 0;
|
|
Packit Service |
ac4cd2 |
}
|
|
Packit Service |
ac4cd2 |
|
|
Packit Service |
ac4cd2 |
#include <support/test-driver.c>
|