1 /* Check that dlfcn errors are reported properly after dlmopen. Test module.
2 Copyright (C) 2021-2022 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 <http://www.gnu.org/licenses/>. */
23 #include <support/check.h>
25 /* Note: This object is not linked into the main program, so we cannot
26 use delayed test failure reporting via TEST_VERIFY etc., and have
27 to use FAIL_EXIT1 (or something else that calls exit). */
30 call_dlsym (const char *name
)
32 void *ptr
= dlsym (NULL
, name
);
34 FAIL_EXIT1 ("dlsym did not fail as expected for: %s", name
);
35 const char *message
= dlerror ();
36 if (strstr (message
, ": undefined symbol: does not exist X") == NULL
)
37 FAIL_EXIT1 ("invalid dlsym error message for [[%s]]: %s", name
, message
);
40 FAIL_EXIT1 ("second dlsym for [[%s]]: %s", name
, message
);
44 call_dlopen (const char *name
)
46 void *handle
= dlopen (name
, RTLD_NOW
);
48 FAIL_EXIT1 ("dlopen did not fail as expected for: %s", name
);
49 const char *message
= dlerror ();
50 if (strstr (message
, "X: cannot open shared object file:"
51 " No such file or directory") == NULL
52 && strstr (message
, "X: cannot open shared object file:"
53 " File name too long") == NULL
)
54 FAIL_EXIT1 ("invalid dlopen error message for [[%s]]: %s", name
, message
);
57 FAIL_EXIT1 ("second dlopen for [[%s]]: %s", name
, message
);