1 /* Test that lazy binding failures in constructors and destructors are fatal.
2 Copyright (C) 2019-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
21 #include <support/capture_subprocess.h>
22 #include <support/check.h>
23 #include <support/xdlfcn.h>
26 test_constructor (void *closure
)
28 void *handle
= dlopen ("tst-initlazyfailmod.so", RTLD_LAZY
);
30 FAIL_EXIT (2, "dlopen did not terminate the process: %s", dlerror ());
32 FAIL_EXIT (2, "dlopen did not terminate the process (%p)", handle
);
36 test_destructor (void *closure
)
38 void *handle
= xdlopen ("tst-finilazyfailmod.so", RTLD_LAZY
);
39 int ret
= dlclose (handle
);
40 const char *message
= dlerror ();
42 FAIL_EXIT (2, "dlclose did not terminate the process: %d, %s",
45 FAIL_EXIT (2, "dlopen did not terminate the process: %d", ret
);
52 struct support_capture_subprocess proc
53 = support_capture_subprocess (test_constructor
, NULL
);
54 support_capture_subprocess_check (&proc
, "constructor", 127,
56 printf ("info: constructor failure output: [[%s]]\n", proc
.err
.buffer
);
57 TEST_VERIFY (strstr (proc
.err
.buffer
,
58 "tst-initfinilazyfail: symbol lookup error: ")
60 TEST_VERIFY (strstr (proc
.err
.buffer
,
61 "tst-initlazyfailmod.so: undefined symbol:"
62 " undefined_function\n") != NULL
);
63 support_capture_subprocess_free (&proc
);
67 struct support_capture_subprocess proc
68 = support_capture_subprocess (test_destructor
, NULL
);
69 support_capture_subprocess_check (&proc
, "destructor", 127,
71 printf ("info: destructor failure output: [[%s]]\n", proc
.err
.buffer
);
72 TEST_VERIFY (strstr (proc
.err
.buffer
,
73 "tst-initfinilazyfail: symbol lookup error: ")
75 TEST_VERIFY (strstr (proc
.err
.buffer
,
76 "tst-finilazyfailmod.so: undefined symbol:"
77 " undefined_function\n") != NULL
);
78 support_capture_subprocess_free (&proc
);
84 #include <support/test-driver.c>