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