diff options
Diffstat (limited to 'src/plugins/test_lib.h')
-rw-r--r-- | src/plugins/test_lib.h | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/src/plugins/test_lib.h b/src/plugins/test_lib.h new file mode 100644 index 0000000..2416d57 --- /dev/null +++ b/src/plugins/test_lib.h | |||
@@ -0,0 +1,100 @@ | |||
1 | /* | ||
2 | This file is part of libextractor. | ||
3 | (C) 2012 Vidyut Samanta and Christian Grothoff | ||
4 | |||
5 | libextractor is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | libextractor is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with libextractor; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file plugins/test_lib.h | ||
22 | * @brief helper library for writing testcases | ||
23 | * @author Christian Grothoff | ||
24 | */ | ||
25 | #ifndef TEST_LIB_H | ||
26 | #define TEST_LIB_H | ||
27 | |||
28 | #include "extractor.h" | ||
29 | |||
30 | /** | ||
31 | * Expected outcome from the plugin. | ||
32 | */ | ||
33 | struct SolutionData | ||
34 | { | ||
35 | /** | ||
36 | * Expected type. | ||
37 | */ | ||
38 | enum EXTRACTOR_MetaType type; | ||
39 | |||
40 | /** | ||
41 | * Expected format. | ||
42 | */ | ||
43 | enum EXTRACTOR_MetaFormat format; | ||
44 | |||
45 | /** | ||
46 | * Expected data mime type. | ||
47 | */ | ||
48 | const char *data_mime_type; | ||
49 | |||
50 | /** | ||
51 | * Expected meta data. | ||
52 | */ | ||
53 | const char *data; | ||
54 | |||
55 | /** | ||
56 | * Expected number of bytes in meta data. | ||
57 | */ | ||
58 | size_t data_len; | ||
59 | |||
60 | /** | ||
61 | * Internally used flag to say if this solution was | ||
62 | * provided by the plugin; 0 for no, 1 for yes; -1 to | ||
63 | * terminate the list. | ||
64 | */ | ||
65 | int solved; | ||
66 | }; | ||
67 | |||
68 | |||
69 | /** | ||
70 | * Set of problems | ||
71 | */ | ||
72 | struct ProblemSet | ||
73 | { | ||
74 | /** | ||
75 | * File to run the extractor on, NULL | ||
76 | * to terminate the array. | ||
77 | */ | ||
78 | const char *filename; | ||
79 | |||
80 | /** | ||
81 | * Expected meta data. Terminate array with -1 in 'solved'. | ||
82 | */ | ||
83 | struct SolutionData *solution; | ||
84 | |||
85 | }; | ||
86 | |||
87 | |||
88 | /** | ||
89 | * Main function to be called to test a plugin. | ||
90 | * | ||
91 | * @param plugin_name name of the plugin to load | ||
92 | * @param ps array of problems the plugin should solve; | ||
93 | * NULL in filename terminates the array. | ||
94 | * @return 0 on success, 1 on failure | ||
95 | */ | ||
96 | int | ||
97 | ET_main (const char *plugin_name, | ||
98 | struct ProblemSet *ps); | ||
99 | |||
100 | #endif | ||