test_plugin_load_multi.c (2219B)
1 /* 2 This file is part of libextractor. 3 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2009 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 main/test_plugin_load_multi.c 22 * @brief testcase for libextractor plugin loading that loads the same 23 * plugins multiple times! 24 * @author Christian Grothoff 25 */ 26 27 #include "platform.h" 28 #include "extractor.h" 29 30 31 static int 32 testLoadPlugins () 33 { 34 struct EXTRACTOR_PluginList *el1; 35 struct EXTRACTOR_PluginList *el2; 36 37 el1 = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY); 38 el2 = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY); 39 if ((NULL == el1) || (NULL == el2)) 40 { 41 fprintf (stderr, 42 "Failed to load default plugins!\n"); 43 if (NULL != el1) 44 EXTRACTOR_plugin_remove_all (el1); 45 if (NULL != el2) 46 EXTRACTOR_plugin_remove_all (el2); 47 return 1; 48 } 49 EXTRACTOR_plugin_remove_all (el1); 50 EXTRACTOR_plugin_remove_all (el2); 51 return 0; 52 } 53 54 55 int 56 main (int argc, char *argv[]) 57 { 58 int ret = 0; 59 60 /* change environment to find 'extractor_test' plugin which is 61 not installed but should be in the current directory (or .libs) 62 on 'make check' */ 63 if (0 != putenv ("LIBEXTRACTOR_PREFIX=.:.libs/")) 64 fprintf (stderr, 65 "Failed to update my environment, plugin loading may fail: %s\n", 66 strerror (errno)); 67 ret += testLoadPlugins (); 68 ret += testLoadPlugins (); 69 return ret; 70 } 71 72 73 /* end of test_plugin_load_multi.c */