libextractor

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

commit 072eeeccc8bc85170b90b36ec9a4fce9cb328f00
parent f0277006357560844943516805c0c0e535000254
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 21 Aug 2012 18:26:43 +0000

run in-process and out-of-process

Diffstat:
Msrc/plugins/test_exiv2.c | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/plugins/test_lib.c | 55+++++++++++++++++++++++++++++++++++++++++--------------
2 files changed, 97 insertions(+), 14 deletions(-)

diff --git a/src/plugins/test_exiv2.c b/src/plugins/test_exiv2.c @@ -175,6 +175,14 @@ main (int argc, char *argv[]) 0 }, { + EXTRACTOR_METATYPE_LOCATION_CITY, + EXTRACTOR_METAFORMAT_UTF8, + "text/plain", + "Los Verdes", + strlen ("Los Verdes") + 1, + 0 + }, + { EXTRACTOR_METATYPE_LOCATION_SUBLOCATION, EXTRACTOR_METAFORMAT_UTF8, "text/plain", @@ -191,6 +199,14 @@ main (int argc, char *argv[]) 0 }, { + EXTRACTOR_METATYPE_LOCATION_COUNTRY, + EXTRACTOR_METAFORMAT_UTF8, + "text/plain", + "Spain", + strlen ("Spain") + 1, + 0 + }, + { EXTRACTOR_METATYPE_KEYWORDS, EXTRACTOR_METAFORMAT_UTF8, "text/plain", @@ -270,6 +286,46 @@ main (int argc, char *argv[]) strlen ("Wo?") + 1, 0 }, + { + EXTRACTOR_METATYPE_RATING, + EXTRACTOR_METAFORMAT_UTF8, + "text/plain", + "3", + strlen ("3") + 1, + 0 + }, + { + EXTRACTOR_METATYPE_RATING, + EXTRACTOR_METAFORMAT_UTF8, + "text/plain", + "50", + strlen ("50") + 1, + 0 + }, + { + EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE, + EXTRACTOR_METAFORMAT_UTF8, + "text/plain", + "ES", + strlen ("ES") + 1, + 0 + }, + { + EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE, + EXTRACTOR_METAFORMAT_UTF8, + "text/plain", + "Optio W30 Ver 1.00", + strlen ("Optio W30 Ver 1.00") + 1, + 0 + }, + { + EXTRACTOR_METATYPE_SUBJECT, + EXTRACTOR_METAFORMAT_UTF8, + "text/plain", + "Wo?, Wo?|Fuerteventura, Was?, Was?|Anlass]|Urlaub, Was?|Aufnahme]|Landschaftsbild, Was?|Natur]|Wind, Was?|Natur]|Sand, Wo?|Fuerteventura|ProCenter Rene Egli, Was?|Sport, Was?|Sport|Windsurfen", + strlen ("Wo?, Wo?|Fuerteventura, Was?, Was?|Anlass]|Urlaub, Was?|Aufnahme]|Landschaftsbild, Was?|Natur]|Wind, Was?|Natur]|Sand, Wo?|Fuerteventura|ProCenter Rene Egli, Was?|Sport, Was?|Sport|Windsurfen") + 1, + 0 + }, { 0, 0, NULL, NULL, 0, -1 } }; struct ProblemSet ps[] = diff --git a/src/plugins/test_lib.c b/src/plugins/test_lib.c @@ -86,32 +86,27 @@ process_replies (void *cls, /** - * Main function to be called to test a plugin. + * Run a test for the given plugin, problem set and options. * * @param plugin_name name of the plugin to load * @param ps array of problems the plugin should solve; * NULL in filename terminates the array. + * @param opt options to use for loading the plugin * @return 0 on success, 1 on failure */ -int -ET_main (const char *plugin_name, - struct ProblemSet *ps) +static int +run (const char *plugin_name, + struct ProblemSet *ps, + enum EXTRACTOR_Options opt) { struct EXTRACTOR_PluginList *pl; unsigned int i; unsigned int j; int ret; - - /* change environment to find plugins which may not yet be - 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)); + pl = EXTRACTOR_plugin_add_config (NULL, plugin_name, - EXTRACTOR_OPTION_IN_PROCESS); + opt); for (i=0; NULL != ps[i].filename; i++) EXTRACTOR_extract (pl, ps[i].filename, @@ -122,7 +117,7 @@ ET_main (const char *plugin_name, ret = 0; for (i=0; NULL != ps[i].filename; i++) for (j=0; -1 != ps[i].solution[j].solved; j++) - if (0 == ps[i].solution[j].solved) + if (0 == ps[i].solution[j].solved) { ret = 1; fprintf (stderr, @@ -133,9 +128,41 @@ ET_main (const char *plugin_name, ps[i].solution[j].data, plugin_name); } + else + ps[i].solution[j].solved = 0; return ret; } +/** + * Main function to be called to test a plugin. + * + * @param plugin_name name of the plugin to load + * @param ps array of problems the plugin should solve; + * NULL in filename terminates the array. + * @return 0 on success, 1 on failure + */ +int +ET_main (const char *plugin_name, + struct ProblemSet *ps) +{ + int ret; + + /* change environment to find plugins which may not yet be + 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 = run (plugin_name, ps, EXTRACTOR_OPTION_IN_PROCESS); + if (0 != ret) + return ret; + ret = run (plugin_name, ps, EXTRACTOR_OPTION_DEFAULT_POLICY); + if (0 != ret) + return ret; + return 0; +} + /* end of test_lib.c */