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