test_lib.h (2281B)
1 /* 2 This file is part of libextractor. 3 Copyright (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., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301, 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 * Treat solution as a regex that must match. 69 */ 70 int regex; 71 }; 72 73 74 /** 75 * Set of problems 76 */ 77 struct ProblemSet 78 { 79 /** 80 * File to run the extractor on, NULL 81 * to terminate the array. 82 */ 83 const char *filename; 84 85 /** 86 * Expected meta data. Terminate array with -1 in 'solved'. 87 */ 88 struct SolutionData *solution; 89 90 }; 91 92 93 /** 94 * Main function to be called to test a plugin. 95 * 96 * @param plugin_name name of the plugin to load 97 * @param ps array of problems the plugin should solve; 98 * NULL in filename terminates the array. 99 * @return 0 on success, 1 on failure 100 */ 101 int 102 ET_main (const char *plugin_name, 103 struct ProblemSet *ps); 104 105 #endif