gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r9831 - in Extractor: . src/main src/test


From: gnunet
Subject: [GNUnet-SVN] r9831 - in Extractor: . src/main src/test
Date: Sun, 20 Dec 2009 21:51:54 +0100

Author: grothoff
Date: 2009-12-20 21:51:54 +0100 (Sun, 20 Dec 2009)
New Revision: 9831

Added:
   Extractor/src/main/fuzz_default.sh
   Extractor/src/main/fuzz_thumbnail.sh
   Extractor/src/main/test_plugin_load_multi.c
   Extractor/src/main/test_plugin_loading.c
   Extractor/src/main/test_trivial.c
Removed:
   Extractor/src/test/fuzz_default.sh
   Extractor/src/test/fuzz_thumbnail.sh
   Extractor/src/test/multiload.c
   Extractor/src/test/plugintest.c
   Extractor/src/test/trivialtest.c
Modified:
   Extractor/TODO
   Extractor/src/main/Makefile.am
   Extractor/src/main/extractor.c
   Extractor/src/test/Makefile.am
Log:
starting work on testcases

Modified: Extractor/TODO
===================================================================
--- Extractor/TODO      2009-12-20 20:16:02 UTC (rev 9830)
+++ Extractor/TODO      2009-12-20 20:51:54 UTC (rev 9831)
@@ -1,15 +1,13 @@
 * ffmpeg needs make 3.81: add configure check for it
 
 Core:
-* check for symbolic links, do not load same plugin twice! 
-  (happens right now for installations with multiple
-   available thumbnailers)
+* port test cases
 * support "hash" plugins as *optional* plugins
   (need a way to indicate that they should not be used
    "by default")
-* use "-" in config not to append plugin, but to remove one!
-* document
-* port test cases
+* support "footer" plugins that need the end of the file,
+  and not the beginning
+* document the new APIs
 * document special options; we have:
   - force-kill: plugin process committs suicide after each file
   - oop-only: plugin is never run in-process 

Modified: Extractor/src/main/Makefile.am
===================================================================
--- Extractor/src/main/Makefile.am      2009-12-20 20:16:02 UTC (rev 9830)
+++ Extractor/src/main/Makefile.am      2009-12-20 20:51:54 UTC (rev 9831)
@@ -38,7 +38,7 @@
 EXTRA_DIST = \
   iconv.c
 
-libextractor_la_CPPFLAGS = -DPLUGINDIR=\"@address@hidden" $(AM_CPPFLAGS)
+libextractor_la_CPPFLAGS = -DPLUGINDIR=\"@address@hidden" 
-DPLUGININSTDIR=\"${plugindir}\" $(AM_CPPFLAGS)
 
 libextractor_la_SOURCES = \
   extractor.c \
@@ -52,3 +52,60 @@
   getopt1.c 
 
 
+
+
+ELIBDIR = $(libdir)
+
+LDADD = \
+ $(top_builddir)/src/main/libextractor.la  
+
+if HAVE_ZZUF
+  fuzz_tests=fuzz_default.sh fuzz_thumbnail.sh
+endif
+
+TESTS_ENVIRONMENT = testdatadir=$(top_srcdir)/test
+TESTS_ENVIRONMENT += bindir=${bindir}
+
+check_PROGRAMS = \
+ test_trivial \
+ test_plugin_loading \
+ test_plugin_load_multi
+
+nocheck = \
+ mt_plugintest1 \
+ mt_plugintest2 \
+ mt_extracttest1 \
+ mt_extracttest2
+
+TESTS = $(check_PROGRAMS) $(fuzz_tests)
+
+test_trivial_SOURCES = \
+ test_trivial.c 
+
+test_plugin_loading_SOURCES = \
+ test_plugin_loading.c 
+
+test_plugin_load_multi_SOURCES = \
+ test_plugin_load_multi.c 
+
+mt_plugintest1_SOURCES = \
+ mt_plugintest1.c 
+mt_plugintest1_LDFLAGS = \
+ -lpthread
+
+mt_plugintest2_SOURCES = \
+ mt_plugintest2.c 
+mt_plugintest2_LDFLAGS = \
+ -lpthread
+
+mt_extracttest1_SOURCES = \
+ mt_extracttest1.c 
+mt_extracttest1_LDFLAGS = \
+ -lpthread
+
+mt_extracttest2_SOURCES = \
+ mt_extracttest2.c 
+mt_extracttest2_LDFLAGS = \
+ -lpthread
+
+

Modified: Extractor/src/main/extractor.c
===================================================================
--- Extractor/src/main/extractor.c      2009-12-20 20:16:02 UTC (rev 9830)
+++ Extractor/src/main/extractor.c      2009-12-20 20:51:54 UTC (rev 9831)
@@ -349,15 +349,38 @@
 {
   char *ret;
 
+#ifdef MINGW
+  if (fname[0] == '\\')
+    fname++;
+#else
+  if (fname[0] == '/')
+    fname++;
+#endif
   ret = malloc (strlen (path) + strlen(fname) + 2);
-  sprintf (ret,
+
 #ifdef MINGW
-          "%s\%s",
+  if (path[strlen(path)-1] == '\\')
+    sprintf (ret,
+            "%s%s",
+            path, 
+            fname);
+  else
+    sprintf (ret,
+            "%s\%s",
+            path, 
+            fname);
 #else
+  if (path[strlen(path)-1] == '/')
+    sprintf (ret,
+          "%s%s",
+          path, 
+          fname);
+  else
+    sprintf (ret,
           "%s/%s",
-#endif
           path, 
           fname);
+#endif
   return ret;
 }
 
@@ -406,12 +429,15 @@
 #endif
   if (prefix == NULL)
     prefix = get_path_from_PATH();
+  pp (pp_cls, PLUGININSTDIR);
   if (prefix == NULL)
     return;
   if (prefix != NULL)
     {
       path = append_to_dir (prefix, PLUGINDIR);
-      pp (pp_cls, path);
+      if (0 != strcmp (path,
+                      PLUGININSTDIR))
+       pp (pp_cls, path);
       free (path);
       free (prefix);
       return;
@@ -458,7 +484,7 @@
        continue; /* only load '.so' and '.dll' */
       sym_name = strstr (ent->d_name, "_");
       if (sym_name == NULL)
-       continue;
+       continue;       
       sym_name++;
       sym = strdup (sym_name);
       dot = strstr (sym, ".");
@@ -751,7 +777,12 @@
 
   libname = find_plugin (library);
   if (libname == NULL)
-    return prev;
+    {
+      fprintf (stderr,
+              "Could not load `%s'\n",
+              library);
+      return prev;
+    }
   result = calloc (1, sizeof (struct EXTRACTOR_PluginList));
   result->next = prev;
   result->short_libname = strdup (library);

Copied: Extractor/src/main/fuzz_default.sh (from rev 9824, 
Extractor/src/test/fuzz_default.sh)
===================================================================
--- Extractor/src/main/fuzz_default.sh                          (rev 0)
+++ Extractor/src/main/fuzz_default.sh  2009-12-20 20:51:54 UTC (rev 9831)
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+ZZSTARTSEED=0
+ZZSTOPSEED=100
+
+# fallbacks for direct, non-"make check" usage
+if test x"$testdatadir" = x""
+then
+  testdatadir=../../test
+fi
+if test x"$bindir" = x""
+then
+  bindir=`grep "^prefix = " ./Makefile | cut -d ' ' -f 3`
+  bindir="$bindir/bin"
+fi
+
+
+for file in $testdatadir/test*
+do
+  if test -f "$file"
+  then
+    tmpfile=`mktemp extractortmp.XXXXXX` || exit 1
+    seed=$ZZSTARTSEED
+    trap "echo $tmpfile caused SIGSEGV ; exit 1" SEGV
+    while [ $seed -lt $ZZSTOPSEED ]
+    do
+#      echo "file $file seed $seed"
+      zzuf -c -s $seed cat "$file" > "$tmpfile"
+      if ! "$bindir/extract" "$tmpfile" > /dev/null
+      then
+        echo "$tmpfile caused error exit"
+        exit 1
+      fi
+      seed=`expr $seed + 1`
+    done
+    rm -f "$tmpfile"
+  fi
+done
+

Copied: Extractor/src/main/fuzz_thumbnail.sh (from rev 9824, 
Extractor/src/test/fuzz_thumbnail.sh)
===================================================================
--- Extractor/src/main/fuzz_thumbnail.sh                                (rev 0)
+++ Extractor/src/main/fuzz_thumbnail.sh        2009-12-20 20:51:54 UTC (rev 
9831)
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+ZZSTARTSEED=0
+ZZSTOPSEED=100
+
+# fallbacks for direct, non-"make check" usage
+if test x"$testdatadir" = x""
+then
+  testdatadir=../../test
+fi
+if test x"$bindir" = x""
+then
+  bindir=`grep "^prefix = " ./Makefile | cut -d ' ' -f 3`
+  bindir="$bindir/bin"
+fi
+
+
+for file in $testdatadir/*.bmp $testdatadir/*.gif $testdatadir/*.png 
$testdatadir/*.ppm
+do
+  if test -f "$file"
+  then
+    tmpfile=`mktemp extractortmp.XXXXXX` || exit 1
+    seed=$ZZSTARTSEED
+    trap "echo $tmpfile caused SIGSEGV ; exit 1" SEGV
+    while [ $seed -lt $ZZSTOPSEED ]
+    do
+#      echo "file $file seed $seed"
+      zzuf -c -s $seed cat "$file" > "$tmpfile"
+      if ! "$bindir/extract" -n -l thumbnailffmpeg:thumbnailqt:thumbnailgtk 
"$tmpfile" > /dev/null
+      then
+        echo "$tmpfile caused error exit"
+        exit 1
+      fi
+      seed=`expr $seed + 1`
+    done
+    rm -f "$tmpfile"
+  fi
+done
+

Copied: Extractor/src/main/test_plugin_load_multi.c (from rev 9824, 
Extractor/src/test/multiload.c)
===================================================================
--- Extractor/src/main/test_plugin_load_multi.c                         (rev 0)
+++ Extractor/src/main/test_plugin_load_multi.c 2009-12-20 20:51:54 UTC (rev 
9831)
@@ -0,0 +1,38 @@
+/**
+ * @file main/test_plugin_load_multi.c
+ * @brief testcase for libextractor plugin loading that loads the same
+ *    plugins multiple times!
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "extractor.h"
+
+static int
+testLoadPlugins ()
+{
+  struct EXTRACTOR_PluginList *el1;
+  struct EXTRACTOR_PluginList *el2;
+
+  el1 = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY);
+  el2 = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY);
+  if ((el1 == NULL) || (el2 == NULL))
+    {
+      fprintf (stderr,
+              "Failed to load default plugins!\n");
+      return 1;
+    }
+  EXTRACTOR_plugin_remove_all (el1);
+  EXTRACTOR_plugin_remove_all (el2);
+  return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+  int ret = 0;
+
+  ret += testLoadPlugins ();
+  ret += testLoadPlugins ();
+  return ret;
+}

Copied: Extractor/src/main/test_plugin_loading.c (from rev 9824, 
Extractor/src/test/plugintest.c)
===================================================================
--- Extractor/src/main/test_plugin_loading.c                            (rev 0)
+++ Extractor/src/main/test_plugin_loading.c    2009-12-20 20:51:54 UTC (rev 
9831)
@@ -0,0 +1,40 @@
+/**
+ * @file main/test_plugin_loading.c
+ * @brief testcase for dynamic loading and unloading of plugins
+ */
+#include "platform.h"
+#include "extractor.h"
+
+int
+main (int argc, char *argv[])
+{
+  struct EXTRACTOR_PluginList *arg;
+
+  /* do some load/unload tests */
+  arg = EXTRACTOR_plugin_add (NULL, "mime", NULL, 
EXTRACTOR_OPTION_DEFAULT_POLICY);
+  arg = EXTRACTOR_plugin_add (arg, "png", NULL, 
EXTRACTOR_OPTION_DEFAULT_POLICY);
+  arg = EXTRACTOR_plugin_add (arg, "zip", NULL, 
EXTRACTOR_OPTION_DEFAULT_POLICY);
+  arg = EXTRACTOR_plugin_remove (arg, "mime");
+  arg = EXTRACTOR_plugin_remove (arg, "zip");
+  arg = EXTRACTOR_plugin_remove (arg, "png");
+  if (arg != NULL)
+    {
+      fprintf (stderr,
+              "add-remove test failed!\n");
+      return -1;
+    }
+
+  arg = EXTRACTOR_plugin_add (NULL, "mime", NULL, 
EXTRACTOR_OPTION_DEFAULT_POLICY);
+  arg = EXTRACTOR_plugin_add (arg, "png", NULL, 
EXTRACTOR_OPTION_DEFAULT_POLICY);
+  arg = EXTRACTOR_plugin_add (arg, "zip", NULL, 
EXTRACTOR_OPTION_DEFAULT_POLICY);
+  arg = EXTRACTOR_plugin_remove (arg, "zip");
+  arg = EXTRACTOR_plugin_remove (arg, "mime");
+  arg = EXTRACTOR_plugin_remove (arg, "png");
+  if (arg != NULL)
+    {
+      fprintf (stderr,
+              "add-remove test failed!\n");
+      return -1;
+    }
+  return 0;
+}

Copied: Extractor/src/main/test_trivial.c (from rev 9824, 
Extractor/src/test/trivialtest.c)
===================================================================
--- Extractor/src/main/test_trivial.c                           (rev 0)
+++ Extractor/src/main/test_trivial.c   2009-12-20 20:51:54 UTC (rev 9831)
@@ -0,0 +1,35 @@
+/**
+ * @file main/test_trivial.c
+ * @brief trivial testcase for libextractor plugin loading
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "extractor.h"
+
+static int
+testLoadPlugins (enum EXTRACTOR_Options policy)
+{
+  struct EXTRACTOR_PluginList *pl;
+  
+  pl = EXTRACTOR_plugin_add_defaults (policy);
+  if (pl == NULL)
+    {
+      fprintf (stderr,
+              "Failed to load default plugins!\n");
+      return 1;
+    }
+  EXTRACTOR_plugin_remove_all (pl);
+  return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+  int ret = 0;
+
+  ret += testLoadPlugins (EXTRACTOR_OPTION_DEFAULT_POLICY);
+  ret += testLoadPlugins (EXTRACTOR_OPTION_DEFAULT_POLICY);
+  ret += testLoadPlugins (EXTRACTOR_OPTION_DEFAULT_POLICY);
+  ret += testLoadPlugins (EXTRACTOR_OPTION_OUT_OF_PROCESS_NO_RESTART);
+  return ret;
+}

Modified: Extractor/src/test/Makefile.am
===================================================================
--- Extractor/src/test/Makefile.am      2009-12-20 20:16:02 UTC (rev 9830)
+++ Extractor/src/test/Makefile.am      2009-12-20 20:51:54 UTC (rev 9831)
@@ -10,7 +10,7 @@
  $(top_builddir)/src/main/libextractor.la  
 
 if HAVE_ZZUF
-fuzz_tests=fuzz_default.sh fuzz_thumbnail.sh
+  fuzz_tests=fuzz_default.sh fuzz_thumbnail.sh
 endif
 
 TESTS_ENVIRONMENT = testdatadir=$(top_srcdir)/test

Deleted: Extractor/src/test/fuzz_default.sh
===================================================================
--- Extractor/src/test/fuzz_default.sh  2009-12-20 20:16:02 UTC (rev 9830)
+++ Extractor/src/test/fuzz_default.sh  2009-12-20 20:51:54 UTC (rev 9831)
@@ -1,39 +0,0 @@
-#!/bin/sh
-
-ZZSTARTSEED=0
-ZZSTOPSEED=100
-
-# fallbacks for direct, non-"make check" usage
-if test x"$testdatadir" = x""
-then
-  testdatadir=../../test
-fi
-if test x"$bindir" = x""
-then
-  bindir=`grep "^prefix = " ./Makefile | cut -d ' ' -f 3`
-  bindir="$bindir/bin"
-fi
-
-
-for file in $testdatadir/test*
-do
-  if test -f "$file"
-  then
-    tmpfile=`mktemp extractortmp.XXXXXX` || exit 1
-    seed=$ZZSTARTSEED
-    trap "echo $tmpfile caused SIGSEGV ; exit 1" SEGV
-    while [ $seed -lt $ZZSTOPSEED ]
-    do
-#      echo "file $file seed $seed"
-      zzuf -c -s $seed cat "$file" > "$tmpfile"
-      if ! "$bindir/extract" "$tmpfile" > /dev/null
-      then
-        echo "$tmpfile caused error exit"
-        exit 1
-      fi
-      seed=`expr $seed + 1`
-    done
-    rm -f "$tmpfile"
-  fi
-done
-

Deleted: Extractor/src/test/fuzz_thumbnail.sh
===================================================================
--- Extractor/src/test/fuzz_thumbnail.sh        2009-12-20 20:16:02 UTC (rev 
9830)
+++ Extractor/src/test/fuzz_thumbnail.sh        2009-12-20 20:51:54 UTC (rev 
9831)
@@ -1,39 +0,0 @@
-#!/bin/sh
-
-ZZSTARTSEED=0
-ZZSTOPSEED=100
-
-# fallbacks for direct, non-"make check" usage
-if test x"$testdatadir" = x""
-then
-  testdatadir=../../test
-fi
-if test x"$bindir" = x""
-then
-  bindir=`grep "^prefix = " ./Makefile | cut -d ' ' -f 3`
-  bindir="$bindir/bin"
-fi
-
-
-for file in $testdatadir/*.bmp $testdatadir/*.gif $testdatadir/*.png 
$testdatadir/*.ppm
-do
-  if test -f "$file"
-  then
-    tmpfile=`mktemp extractortmp.XXXXXX` || exit 1
-    seed=$ZZSTARTSEED
-    trap "echo $tmpfile caused SIGSEGV ; exit 1" SEGV
-    while [ $seed -lt $ZZSTOPSEED ]
-    do
-#      echo "file $file seed $seed"
-      zzuf -c -s $seed cat "$file" > "$tmpfile"
-      if ! "$bindir/extract" -n -l libextractor_thumbnail:libextractor_mime 
"$tmpfile" > /dev/null
-      then
-        echo "$tmpfile caused error exit"
-        exit 1
-      fi
-      seed=`expr $seed + 1`
-    done
-    rm -f "$tmpfile"
-  fi
-done
-

Deleted: Extractor/src/test/multiload.c
===================================================================
--- Extractor/src/test/multiload.c      2009-12-20 20:16:02 UTC (rev 9830)
+++ Extractor/src/test/multiload.c      2009-12-20 20:51:54 UTC (rev 9831)
@@ -1,37 +0,0 @@
-/**
- * @file test/multiload.c
- * @brief testcase for libextractor plugin loading that loads the same
- *    plugins multiple times!
- * @author Christian Grothoff
- */
-
-#include "platform.h"
-#include "extractor.h"
-
-static int
-testLoadPlugins ()
-{
-  EXTRACTOR_ExtractorList *el1;
-  EXTRACTOR_ExtractorList *el2;
-
-  el1 = EXTRACTOR_loadDefaultLibraries ();
-  el2 = EXTRACTOR_loadDefaultLibraries ();
-  if ((el1 == NULL) || (el2 == NULL))
-    {
-      printf ("Failed to load default plugins!\n");
-      return 1;
-    }
-  EXTRACTOR_removeAll (el1);
-  EXTRACTOR_removeAll (el2);
-  return 0;
-}
-
-int
-main (int argc, char *argv[])
-{
-  int ret = 0;
-
-  ret += testLoadPlugins ();
-  ret += testLoadPlugins ();
-  return ret;
-}

Deleted: Extractor/src/test/plugintest.c
===================================================================
--- Extractor/src/test/plugintest.c     2009-12-20 20:16:02 UTC (rev 9830)
+++ Extractor/src/test/plugintest.c     2009-12-20 20:51:54 UTC (rev 9831)
@@ -1,78 +0,0 @@
-/**
- * @file test/plugintest.c
- * @brief testcase for dynamic loading and unloading of plugins
- */
-#include "platform.h"
-#include "extractor.h"
-
-int
-main (int argc, char *argv[])
-{
-  int i;
-  EXTRACTOR_ExtractorList *arg;
-  EXTRACTOR_KeywordList *list;
-  EXTRACTOR_KeywordList *list1;
-
-  /* do some loading and unloading */
-  for (i = 0; i < 10; i++)
-    {
-      arg = EXTRACTOR_loadDefaultLibraries ();
-      EXTRACTOR_removeAll (arg);
-    }
-
-  /* do some load/unload tests */
-  arg = EXTRACTOR_addLibrary (NULL, "libextractor_split");
-  arg = EXTRACTOR_addLibrary (arg, "libextractor_mime");
-  arg = EXTRACTOR_addLibrary (arg, "libextractor_filename");
-  arg = EXTRACTOR_removeLibrary (arg, "libextractor_mime");
-  arg = EXTRACTOR_removeLibrary (arg, "libextractor_split");
-  arg = EXTRACTOR_removeLibrary (arg, "libextractor_filename");
-  if (arg != NULL)
-    {
-      printf ("add-remove test failed!\n");
-      return -1;
-    }
-
-  arg = EXTRACTOR_addLibrary (NULL, "libextractor_split");
-  arg = EXTRACTOR_addLibrary (arg, "libextractor_mime");
-  arg = EXTRACTOR_addLibrary (arg, "libextractor_filename");
-  arg = EXTRACTOR_removeLibrary (arg, "libextractor_mime");
-  arg = EXTRACTOR_removeLibrary (arg, "libextractor_filename");
-  arg = EXTRACTOR_removeLibrary (arg, "libextractor_split");
-  if (arg != NULL)
-    {
-      printf ("add-remove test failed!\n");
-      return -1;
-    }
-
-  arg = EXTRACTOR_loadConfigLibraries (NULL, "libextractor_filename");
-  arg = EXTRACTOR_loadConfigLibraries (arg, "-libextractor_split");
-  list = EXTRACTOR_getKeywords (arg, "/etc/resolv.conf");
-  if (4 != EXTRACTOR_countKeywords (list))
-    {
-      printf ("Invalid number of keywords (4 != %d)\n",
-              EXTRACTOR_countKeywords (list));
-      return -1;
-    }
-  i = 0;
-  list1 = list;
-  while (list1 != NULL)
-    {
-      if ((strcmp (list1->keyword, "resolv") == 0) ||
-          (strcmp (list1->keyword, "conf") == 0) ||
-          (strcmp (list1->keyword, "resolv.conf") == 0))
-        i++;
-      list1 = list1->next;
-    }
-  if (i != 3)
-    {
-      printf ("Wrong keyword extracted.\n");
-      EXTRACTOR_printKeywords (stderr, list);
-      return -1;
-    }
-
-  EXTRACTOR_removeAll (arg);
-  EXTRACTOR_freeKeywords (list);
-
-  return 0;
-}

Deleted: Extractor/src/test/trivialtest.c
===================================================================
--- Extractor/src/test/trivialtest.c    2009-12-20 20:16:02 UTC (rev 9830)
+++ Extractor/src/test/trivialtest.c    2009-12-20 20:51:54 UTC (rev 9831)
@@ -1,32 +0,0 @@
-/**
- * @file test/trivialtest.c
- * @brief trivial testcase for libextractor plugin loading
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "extractor.h"
-
-static int
-testLoadPlugins ()
-{
-  EXTRACTOR_ExtractorList *el;
-
-  el = EXTRACTOR_loadDefaultLibraries ();
-  if (el == NULL)
-    {
-      printf ("Failed to load default plugins!\n");
-      return 1;
-    }
-  EXTRACTOR_removeAll (el);
-  return 0;
-}
-
-int
-main (int argc, char *argv[])
-{
-  int ret = 0;
-
-  ret += testLoadPlugins ();
-  ret += testLoadPlugins ();
-  return ret;
-}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]