aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/test_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/test_lib.c')
-rw-r--r--src/plugins/test_lib.c55
1 files changed, 41 insertions, 14 deletions
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 */