1 From 916065cfed5ceccfd2ee4127a460b47161c2efd7 Mon Sep 17 00:00:00 2001
2 From: Lukas Slebodnik <lslebodn@redhat.com>
3 Date: Mon, 17 Oct 2016 21:44:18 +0200
4 Subject: [PATCH 10/39] dlopen-test: Add check for untested libraries
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Reviewed-by: Petr Čech <pcech@redhat.com>
10 (cherry picked from commit c7b3c43cf669e39f7ce5f4ef1a2e939b31a8b7b9)
11 (cherry picked from commit 7251859d8cdb2fc57c969f67ac76904fea331cd0)
13 src/tests/dlopen-tests.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++
14 1 file changed, 69 insertions(+)
16 diff --git a/src/tests/dlopen-tests.c b/src/tests/dlopen-tests.c
17 index c857dff73..520c91f63 100644
18 --- a/src/tests/dlopen-tests.c
19 +++ b/src/tests/dlopen-tests.c
25 #include "tests/common.h"
27 #define LIBPFX ABS_BUILD_DIR "/" LT_OBJDIR
28 @@ -154,16 +155,84 @@ static bool recursive_dlopen(const char **name, int round, char **errmsg)
32 +static int file_so_filter(const struct dirent *ent)
36 + suffix = rindex(ent->d_name, '.');
38 + && strcmp(suffix, ".so") == 0
39 + && suffix[3] == '\0') {
46 +static char **get_so_files(size_t *_list_size)
49 + struct dirent **namelist;
52 + n = scandir(LIBPFX, &namelist, file_so_filter, alphasort);
55 + libraries = calloc(n + 1, sizeof(char *));
57 + for (int i = 0; i < n; ++i) {
58 + libraries[i] = strdup(namelist[i]->d_name);
59 + fail_if(libraries[i] == NULL);
65 + *_list_size = (size_t)n;
69 +static void remove_library_from_list(const char *library, char **list,
72 + for (size_t i = 0; i < list_size; ++i) {
73 + if (list[i] != NULL && strcmp(library, list[i]) == 0) {
74 + /* found library need to be removed from list */
81 + ck_abort_msg("Cannot find expected library: %s", library);
84 START_TEST(test_dlopen_base)
89 + size_t found_libraries_size;
90 + char **found_libraries = get_so_files(&found_libraries_size);
91 + bool unchecked_library = false;
93 for (i = 0; so[i].name != NULL; i++) {
94 ok = recursive_dlopen(so[i].libs, 0, &errmsg);
95 fail_unless(ok, "Error opening %s: [%s]", so[i].name, errmsg);
97 + remove_library_from_list(so[i].name, found_libraries,
98 + found_libraries_size);
101 + for (i = 0; i < found_libraries_size; ++i) {
102 + if (found_libraries[i] != NULL) {
103 + printf("Unchecked library found: %s\n", found_libraries[i]);
104 + unchecked_library = true;
107 + free(found_libraries);
109 + fail_if(unchecked_library);