libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

commit b014ab4deffd627b55f654a07408c13c9e7a5b96
parent 15d3cc42d0780fb0178c2d0073d38e500890a836
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu,  2 Aug 2012 19:59:13 +0000

-make tests less verbose if they pass, also remove dependency on src/plugins/

Diffstat:
Msrc/main/extractor_ipc_gnu.c | 5-----
Msrc/main/extractor_plugpath.c | 21++++-----------------
Msrc/main/test_ipc.c | 4++++
Msrc/main/test_plugin_load_multi.c | 7+++++++
Msrc/main/test_plugin_loading.c | 27++++++++++++---------------
Msrc/main/test_trivial.c | 8++++++++
6 files changed, 35 insertions(+), 37 deletions(-)

diff --git a/src/main/extractor_ipc_gnu.c b/src/main/extractor_ipc_gnu.c @@ -154,9 +154,6 @@ EXTRACTOR_IPC_shared_memory_create_ (size_t size) "%slibextractor-shm-%u-%u", tpath, getpid (), (unsigned int) RANDOM()); - LOG ("Creating shared memory `%s' with %u bytes capacity\n", - shm->shm_name, - (unsigned int) size); if (-1 == (shm->shm_id = shm_open (shm->shm_name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR))) { @@ -207,8 +204,6 @@ EXTRACTOR_IPC_shared_memory_change_rc_ (struct EXTRACTOR_SharedMemory *shm, void EXTRACTOR_IPC_shared_memory_destroy_ (struct EXTRACTOR_SharedMemory *shm) { - LOG ("Destroying shared memory `%s'\n", - shm->shm_name); munmap (shm->shm_ptr, shm->shm_size); (void) close (shm->shm_id); (void) shm_unlink (shm->shm_name); diff --git a/src/main/extractor_plugpath.c b/src/main/extractor_plugpath.c @@ -501,7 +501,6 @@ find_plugin_in_path (void *cls, struct SearchContext *sc = cls; DIR *dir; struct dirent *ent; - const char *la; const char *sym_name; char *sym; char *dot; @@ -514,12 +513,8 @@ find_plugin_in_path (void *cls, { if ('.' == ent->d_name[0]) continue; - if ( ( (NULL != (la = strstr (ent->d_name, ".la"))) && - ('\0' == la[3]) ) || - ( (NULL != (la = strstr (ent->d_name, ".ver"))) && - (la[4] == '\0') ) || - ( (NULL != (la = strstr (ent->d_name, ".a"))) && - (la[2] == '\0') ) ) + if ( (NULL == strstr (ent->d_name, ".so")) && + (NULL == strstr (ent->d_name, ".dll")) ) continue; /* only load '.so' and '.dll' */ if (NULL == (sym_name = strrchr (ent->d_name, '_'))) continue; @@ -592,7 +587,6 @@ load_plugins_from_dir (void *cls, struct DefaultLoaderContext *dlc = cls; DIR *dir; struct dirent *ent; - const char *la; const char *sym_name; char *sym; char *dot; @@ -603,14 +597,9 @@ load_plugins_from_dir (void *cls, { if (ent->d_name[0] == '.') continue; - if ( ( (NULL != (la = strstr (ent->d_name, ".la"))) && - (la[3] == '\0') ) || - ( (NULL != (la = strstr (ent->d_name, ".ver"))) && - (la[4] == '\0') ) || - ( (NULL != (la = strstr (ent->d_name, ".a"))) && - (la[2] == '\0')) ) + if ( (NULL == strstr (ent->d_name, ".so")) && + (NULL == strstr (ent->d_name, ".dll")) ) continue; /* only load '.so' and '.dll' */ - if (NULL == (sym_name = strrchr (ent->d_name, '_'))) continue; sym_name++; @@ -622,8 +611,6 @@ load_plugins_from_dir (void *cls, } if (NULL != (dot = strchr (sym, '.'))) *dot = '\0'; - LOG ("Adding default plugin `%s'\n", - sym); dlc->res = EXTRACTOR_plugin_add (dlc->res, sym, NULL, diff --git a/src/main/test_ipc.c b/src/main/test_ipc.c @@ -96,7 +96,9 @@ process_replies (void *cls, HLO, strlen (HLO))) ) { +#if 0 fprintf (stderr, "Received '%s'\n", HLO); +#endif ret = 1; return 0; } @@ -106,7 +108,9 @@ process_replies (void *cls, GOB, strlen (GOB))) ) { +#if 0 fprintf (stderr, "Received '%s'\n", GOB); +#endif ret = 0; return 1; } diff --git a/src/main/test_plugin_load_multi.c b/src/main/test_plugin_load_multi.c @@ -57,6 +57,13 @@ main (int argc, char *argv[]) { int ret = 0; + /* change environment to find 'extractor_test' plugin which is + not installed but should be in the current directory (or .libs) + on 'make check' */ + if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/")) + fprintf (stderr, + "Failed to update my environment, plugin loading may fail: %s\n", + strerror (errno)); ret += testLoadPlugins (); ret += testLoadPlugins (); return ret; diff --git a/src/main/test_plugin_loading.c b/src/main/test_plugin_loading.c @@ -30,25 +30,22 @@ main (int argc, char *argv[]) { struct EXTRACTOR_PluginList *arg; + /* change environment to find 'extractor_test' plugin which is + not installed but should be in the current directory (or .libs) + on 'make check' */ + if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/")) + fprintf (stderr, + "Failed to update my environment, plugin loading may fail: %s\n", + strerror (errno)); + /* do some load/unload tests */ - arg = EXTRACTOR_plugin_add (NULL, "mime", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - arg = EXTRACTOR_plugin_add (arg, "png", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - arg = EXTRACTOR_plugin_add (arg, "zip", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - arg = EXTRACTOR_plugin_remove (arg, "mime"); - arg = EXTRACTOR_plugin_remove (arg, "zip"); - arg = EXTRACTOR_plugin_remove (arg, "png"); - if (NULL != arg) + arg = EXTRACTOR_plugin_add (NULL, "test", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); + if (arg != EXTRACTOR_plugin_add (arg, "test", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY)) { fprintf (stderr, - "add-remove test failed!\n"); - return -1; + "Could load plugin twice, that should not be allowed\n"); } - arg = EXTRACTOR_plugin_add (NULL, "mime", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - arg = EXTRACTOR_plugin_add (arg, "png", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - arg = EXTRACTOR_plugin_add (arg, "zip", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY); - arg = EXTRACTOR_plugin_remove (arg, "zip"); - arg = EXTRACTOR_plugin_remove (arg, "mime"); - arg = EXTRACTOR_plugin_remove (arg, "png"); + arg = EXTRACTOR_plugin_remove (arg, "test"); if (NULL != arg) { fprintf (stderr, diff --git a/src/main/test_trivial.c b/src/main/test_trivial.c @@ -46,6 +46,14 @@ main (int argc, char *argv[]) { int ret = 0; + + /* change environment to find 'extractor_test' plugin which is + not installed but should be in the current directory (or .libs) + on 'make check' */ + if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/")) + fprintf (stderr, + "Failed to update my environment, plugin loading may fail: %s\n", + strerror (errno)); ret += testLoadPlugins (EXTRACTOR_OPTION_DEFAULT_POLICY); ret += testLoadPlugins (EXTRACTOR_OPTION_DEFAULT_POLICY); ret += testLoadPlugins (EXTRACTOR_OPTION_DEFAULT_POLICY);