aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-08-21 18:26:43 +0000
committerChristian Grothoff <christian@grothoff.org>2012-08-21 18:26:43 +0000
commit072eeeccc8bc85170b90b36ec9a4fce9cb328f00 (patch)
tree5284e0fe4e2a97299fdfbdb61caa2c47258f90c6
parentf0277006357560844943516805c0c0e535000254 (diff)
downloadlibextractor-072eeeccc8bc85170b90b36ec9a4fce9cb328f00.tar.gz
libextractor-072eeeccc8bc85170b90b36ec9a4fce9cb328f00.zip
run in-process and out-of-process
-rw-r--r--src/plugins/test_exiv2.c56
-rw-r--r--src/plugins/test_lib.c55
2 files changed, 97 insertions, 14 deletions
diff --git a/src/plugins/test_exiv2.c b/src/plugins/test_exiv2.c
index c9850c7..87673a3 100644
--- a/src/plugins/test_exiv2.c
+++ b/src/plugins/test_exiv2.c
@@ -175,6 +175,14 @@ main (int argc, char *argv[])
175 0 175 0
176 }, 176 },
177 { 177 {
178 EXTRACTOR_METATYPE_LOCATION_CITY,
179 EXTRACTOR_METAFORMAT_UTF8,
180 "text/plain",
181 "Los Verdes",
182 strlen ("Los Verdes") + 1,
183 0
184 },
185 {
178 EXTRACTOR_METATYPE_LOCATION_SUBLOCATION, 186 EXTRACTOR_METATYPE_LOCATION_SUBLOCATION,
179 EXTRACTOR_METAFORMAT_UTF8, 187 EXTRACTOR_METAFORMAT_UTF8,
180 "text/plain", 188 "text/plain",
@@ -191,6 +199,14 @@ main (int argc, char *argv[])
191 0 199 0
192 }, 200 },
193 { 201 {
202 EXTRACTOR_METATYPE_LOCATION_COUNTRY,
203 EXTRACTOR_METAFORMAT_UTF8,
204 "text/plain",
205 "Spain",
206 strlen ("Spain") + 1,
207 0
208 },
209 {
194 EXTRACTOR_METATYPE_KEYWORDS, 210 EXTRACTOR_METATYPE_KEYWORDS,
195 EXTRACTOR_METAFORMAT_UTF8, 211 EXTRACTOR_METAFORMAT_UTF8,
196 "text/plain", 212 "text/plain",
@@ -270,6 +286,46 @@ main (int argc, char *argv[])
270 strlen ("Wo?") + 1, 286 strlen ("Wo?") + 1,
271 0 287 0
272 }, 288 },
289 {
290 EXTRACTOR_METATYPE_RATING,
291 EXTRACTOR_METAFORMAT_UTF8,
292 "text/plain",
293 "3",
294 strlen ("3") + 1,
295 0
296 },
297 {
298 EXTRACTOR_METATYPE_RATING,
299 EXTRACTOR_METAFORMAT_UTF8,
300 "text/plain",
301 "50",
302 strlen ("50") + 1,
303 0
304 },
305 {
306 EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE,
307 EXTRACTOR_METAFORMAT_UTF8,
308 "text/plain",
309 "ES",
310 strlen ("ES") + 1,
311 0
312 },
313 {
314 EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
315 EXTRACTOR_METAFORMAT_UTF8,
316 "text/plain",
317 "Optio W30 Ver 1.00",
318 strlen ("Optio W30 Ver 1.00") + 1,
319 0
320 },
321 {
322 EXTRACTOR_METATYPE_SUBJECT,
323 EXTRACTOR_METAFORMAT_UTF8,
324 "text/plain",
325 "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",
326 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,
327 0
328 },
273 { 0, 0, NULL, NULL, 0, -1 } 329 { 0, 0, NULL, NULL, 0, -1 }
274 }; 330 };
275 struct ProblemSet ps[] = 331 struct ProblemSet ps[] =
diff --git a/src/plugins/test_lib.c b/src/plugins/test_lib.c
index 8e5c3a8..6aa335c 100644
--- a/src/plugins/test_lib.c
+++ b/src/plugins/test_lib.c
@@ -86,32 +86,27 @@ process_replies (void *cls,
86 86
87 87
88/** 88/**
89 * Main function to be called to test a plugin. 89 * Run a test for the given plugin, problem set and options.
90 * 90 *
91 * @param plugin_name name of the plugin to load 91 * @param plugin_name name of the plugin to load
92 * @param ps array of problems the plugin should solve; 92 * @param ps array of problems the plugin should solve;
93 * NULL in filename terminates the array. 93 * NULL in filename terminates the array.
94 * @param opt options to use for loading the plugin
94 * @return 0 on success, 1 on failure 95 * @return 0 on success, 1 on failure
95 */ 96 */
96int 97static int
97ET_main (const char *plugin_name, 98run (const char *plugin_name,
98 struct ProblemSet *ps) 99 struct ProblemSet *ps,
100 enum EXTRACTOR_Options opt)
99{ 101{
100 struct EXTRACTOR_PluginList *pl; 102 struct EXTRACTOR_PluginList *pl;
101 unsigned int i; 103 unsigned int i;
102 unsigned int j; 104 unsigned int j;
103 int ret; 105 int ret;
104 106
105 /* change environment to find plugins which may not yet be
106 not installed but should be in the current directory (or .libs)
107 on 'make check' */
108 if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/"))
109 fprintf (stderr,
110 "Failed to update my environment, plugin loading may fail: %s\n",
111 strerror (errno));
112 pl = EXTRACTOR_plugin_add_config (NULL, 107 pl = EXTRACTOR_plugin_add_config (NULL,
113 plugin_name, 108 plugin_name,
114 EXTRACTOR_OPTION_IN_PROCESS); 109 opt);
115 for (i=0; NULL != ps[i].filename; i++) 110 for (i=0; NULL != ps[i].filename; i++)
116 EXTRACTOR_extract (pl, 111 EXTRACTOR_extract (pl,
117 ps[i].filename, 112 ps[i].filename,
@@ -122,7 +117,7 @@ ET_main (const char *plugin_name,
122 ret = 0; 117 ret = 0;
123 for (i=0; NULL != ps[i].filename; i++) 118 for (i=0; NULL != ps[i].filename; i++)
124 for (j=0; -1 != ps[i].solution[j].solved; j++) 119 for (j=0; -1 != ps[i].solution[j].solved; j++)
125 if (0 == ps[i].solution[j].solved) 120 if (0 == ps[i].solution[j].solved)
126 { 121 {
127 ret = 1; 122 ret = 1;
128 fprintf (stderr, 123 fprintf (stderr,
@@ -133,9 +128,41 @@ ET_main (const char *plugin_name,
133 ps[i].solution[j].data, 128 ps[i].solution[j].data,
134 plugin_name); 129 plugin_name);
135 } 130 }
131 else
132 ps[i].solution[j].solved = 0;
136 return ret; 133 return ret;
137} 134}
138 135
139 136
137/**
138 * Main function to be called to test a plugin.
139 *
140 * @param plugin_name name of the plugin to load
141 * @param ps array of problems the plugin should solve;
142 * NULL in filename terminates the array.
143 * @return 0 on success, 1 on failure
144 */
145int
146ET_main (const char *plugin_name,
147 struct ProblemSet *ps)
148{
149 int ret;
150
151 /* change environment to find plugins which may not yet be
152 not installed but should be in the current directory (or .libs)
153 on 'make check' */
154 if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/"))
155 fprintf (stderr,
156 "Failed to update my environment, plugin loading may fail: %s\n",
157 strerror (errno));
158 ret = run (plugin_name, ps, EXTRACTOR_OPTION_IN_PROCESS);
159 if (0 != ret)
160 return ret;
161 ret = run (plugin_name, ps, EXTRACTOR_OPTION_DEFAULT_POLICY);
162 if (0 != ret)
163 return ret;
164 return 0;
165}
166
140 167
141/* end of test_lib.c */ 168/* end of test_lib.c */