1 /* Test that loading libpthread does not break ld.so exceptions (bug 16628).
2 Copyright (C) 2016-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/>. */
29 void *handle
= dlopen ("tst-latepthreadmod.so", RTLD_LOCAL
| RTLD_LAZY
);
32 printf ("error: dlopen failed: %s\n", dlerror ());
35 void *ptr
= dlsym (handle
, "trigger_dynlink_failure");
38 printf ("error: dlsym failed: %s\n", dlerror ());
41 int (*func
) (void) = ptr
;
43 /* Run the actual test in a subprocess, to capture the error. */
47 printf ("error: pipe: %m\n");
53 printf ("error: fork: %m\n");
58 if (dup2 (fds
[1], STDERR_FILENO
) < 0)
60 /* Trigger an abort. */
64 /* NB: This assumes that the abort message is so short that the pipe
67 if (waitpid (pid
, &status
, 0) < 0)
69 printf ("error: waitpid: %m\n");
73 /* Check the printed error message. */
74 if (close (fds
[1]) < 0)
76 printf ("error: close: %m\n");
80 /* Leave room for the NUL terminator. */
81 ssize_t ret
= read (fds
[0], buf
, sizeof (buf
) - 1);
84 printf ("error: read: %m\n");
87 if (ret
> 0 && buf
[ret
- 1] == '\n')
90 printf ("info: exit status: %d, message: %s\n", status
, buf
);
91 if (strstr (buf
, "undefined symbol: this_function_is_not_defined") == NULL
)
93 printf ("error: message does not contain expected string\n");
96 if (!WIFEXITED (status
) || WEXITSTATUS (status
) != 127)
98 printf ("error: unexpected process exit status\n");
104 #include <support/test-driver.c>