libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

test_plugin_loading.c (2034B)


      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_plugin_loading.c
     23  * @brief testcase for dynamic loading and unloading of plugins
     24  */
     25 #include "platform.h"
     26 #include "extractor.h"
     27 
     28 int
     29 main (int argc, char *argv[])
     30 {
     31   struct EXTRACTOR_PluginList *arg;
     32 
     33   /* change environment to find 'extractor_test' plugin which is
     34      not installed but should be in the current directory (or .libs)
     35      on 'make check' */
     36   if (0 != putenv ("LIBEXTRACTOR_PREFIX=.:.libs/"))
     37     fprintf (stderr,
     38              "Failed to update my environment, plugin loading may fail: %s\n",
     39              strerror (errno));
     40 
     41   /* do some load/unload tests */
     42   arg = EXTRACTOR_plugin_add (NULL, "test", NULL,
     43                               EXTRACTOR_OPTION_DEFAULT_POLICY);
     44   if (arg != EXTRACTOR_plugin_add (arg, "test", NULL,
     45                                    EXTRACTOR_OPTION_DEFAULT_POLICY))
     46   {
     47     fprintf (stderr,
     48              "Could load plugin twice, that should not be allowed\n");
     49   }
     50   arg = EXTRACTOR_plugin_remove (arg, "test");
     51   if (NULL != arg)
     52   {
     53     fprintf (stderr,
     54              "add-remove test failed!\n");
     55     return -1;
     56   }
     57   return 0;
     58 }
     59 
     60 
     61 /* end of test_plugin_loading.c */