|
Packit Service |
2ee6d2 |
/* Test that lazy binding failures in constructors and destructors are fatal.
|
|
Packit Service |
2ee6d2 |
Copyright (C) 2019 Free Software Foundation, Inc.
|
|
Packit Service |
2ee6d2 |
This file is part of the GNU C Library.
|
|
Packit Service |
2ee6d2 |
|
|
Packit Service |
2ee6d2 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
2ee6d2 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
2ee6d2 |
License as published by the Free Software Foundation; either
|
|
Packit Service |
2ee6d2 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
2ee6d2 |
|
|
Packit Service |
2ee6d2 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
2ee6d2 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
2ee6d2 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
2ee6d2 |
Lesser General Public License for more details.
|
|
Packit Service |
2ee6d2 |
|
|
Packit Service |
2ee6d2 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
2ee6d2 |
License along with the GNU C Library; if not, see
|
|
Packit Service |
2ee6d2 |
<https://www.gnu.org/licenses/>. */
|
|
Packit Service |
2ee6d2 |
|
|
Packit Service |
2ee6d2 |
#include <dlfcn.h>
|
|
Packit Service |
2ee6d2 |
#include <string.h>
|
|
Packit Service |
2ee6d2 |
#include <support/capture_subprocess.h>
|
|
Packit Service |
2ee6d2 |
#include <support/check.h>
|
|
Packit Service |
2ee6d2 |
#include <support/xdlfcn.h>
|
|
Packit Service |
2ee6d2 |
|
|
Packit Service |
2ee6d2 |
static void
|
|
Packit Service |
2ee6d2 |
test_constructor (void *closure)
|
|
Packit Service |
2ee6d2 |
{
|
|
Packit Service |
2ee6d2 |
void *handle = dlopen ("tst-initlazyfailmod.so", RTLD_LAZY);
|
|
Packit Service |
2ee6d2 |
if (handle == NULL)
|
|
Packit Service |
2ee6d2 |
FAIL_EXIT (2, "dlopen did not terminate the process: %s", dlerror ());
|
|
Packit Service |
2ee6d2 |
else
|
|
Packit Service |
2ee6d2 |
FAIL_EXIT (2, "dlopen did not terminate the process (%p)", handle);
|
|
Packit Service |
2ee6d2 |
}
|
|
Packit Service |
2ee6d2 |
|
|
Packit Service |
2ee6d2 |
static void
|
|
Packit Service |
2ee6d2 |
test_destructor (void *closure)
|
|
Packit Service |
2ee6d2 |
{
|
|
Packit Service |
2ee6d2 |
void *handle = xdlopen ("tst-finilazyfailmod.so", RTLD_LAZY);
|
|
Packit Service |
2ee6d2 |
int ret = dlclose (handle);
|
|
Packit Service |
2ee6d2 |
const char *message = dlerror ();
|
|
Packit Service |
2ee6d2 |
if (message != NULL)
|
|
Packit Service |
2ee6d2 |
FAIL_EXIT (2, "dlclose did not terminate the process: %d, %s",
|
|
Packit Service |
2ee6d2 |
ret, message);
|
|
Packit Service |
2ee6d2 |
else
|
|
Packit Service |
2ee6d2 |
FAIL_EXIT (2, "dlopen did not terminate the process: %d", ret);
|
|
Packit Service |
2ee6d2 |
}
|
|
Packit Service |
2ee6d2 |
|
|
Packit Service |
2ee6d2 |
static int
|
|
Packit Service |
2ee6d2 |
do_test (void)
|
|
Packit Service |
2ee6d2 |
{
|
|
Packit Service |
2ee6d2 |
{
|
|
Packit Service |
2ee6d2 |
struct support_capture_subprocess proc
|
|
Packit Service |
2ee6d2 |
= support_capture_subprocess (test_constructor, NULL);
|
|
Packit Service |
2ee6d2 |
support_capture_subprocess_check (&proc, "constructor", 127,
|
|
Packit Service |
2ee6d2 |
sc_allow_stderr);
|
|
Packit Service |
2ee6d2 |
printf ("info: constructor failure output: [[%s]]\n", proc.err.buffer);
|
|
Packit Service |
2ee6d2 |
TEST_VERIFY (strstr (proc.err.buffer,
|
|
Packit Service |
2ee6d2 |
"tst-initfinilazyfail: symbol lookup error: ")
|
|
Packit Service |
2ee6d2 |
!= NULL);
|
|
Packit Service |
2ee6d2 |
TEST_VERIFY (strstr (proc.err.buffer,
|
|
Packit Service |
2ee6d2 |
"tst-initlazyfailmod.so: undefined symbol:"
|
|
Packit Service |
2ee6d2 |
" undefined_function\n") != NULL);
|
|
Packit Service |
2ee6d2 |
support_capture_subprocess_free (&proc;;
|
|
Packit Service |
2ee6d2 |
}
|
|
Packit Service |
2ee6d2 |
|
|
Packit Service |
2ee6d2 |
{
|
|
Packit Service |
2ee6d2 |
struct support_capture_subprocess proc
|
|
Packit Service |
2ee6d2 |
= support_capture_subprocess (test_destructor, NULL);
|
|
Packit Service |
2ee6d2 |
support_capture_subprocess_check (&proc, "destructor", 127,
|
|
Packit Service |
2ee6d2 |
sc_allow_stderr);
|
|
Packit Service |
2ee6d2 |
printf ("info: destructor failure output: [[%s]]\n", proc.err.buffer);
|
|
Packit Service |
2ee6d2 |
TEST_VERIFY (strstr (proc.err.buffer,
|
|
Packit Service |
2ee6d2 |
"tst-initfinilazyfail: symbol lookup error: ")
|
|
Packit Service |
2ee6d2 |
!= NULL);
|
|
Packit Service |
2ee6d2 |
TEST_VERIFY (strstr (proc.err.buffer,
|
|
Packit Service |
2ee6d2 |
"tst-finilazyfailmod.so: undefined symbol:"
|
|
Packit Service |
2ee6d2 |
" undefined_function\n") != NULL);
|
|
Packit Service |
2ee6d2 |
support_capture_subprocess_free (&proc;;
|
|
Packit Service |
2ee6d2 |
}
|
|
Packit Service |
2ee6d2 |
|
|
Packit Service |
2ee6d2 |
return 0;
|
|
Packit Service |
2ee6d2 |
}
|
|
Packit Service |
2ee6d2 |
|
|
Packit Service |
2ee6d2 |
#include <support/test-driver.c>
|