commit a2a49db6a27662716da9af7965ddf8baee9c3616
parent b1ec7718df666b43324d7828e4c2ee8e885aed8b
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 6 Apr 2010 10:53:25 +0000
dce
Diffstat:
6 files changed, 0 insertions(+), 692 deletions(-)
diff --git a/src/test/Makefile.am b/src/test/Makefile.am
@@ -1,63 +0,0 @@
-INCLUDES = -I$(top_srcdir)/src/include
-
-SUBDIRS = .
-
-ELIBDIR = $(libdir)
-
-AM_CFLAGS = -DELIBDIR=\"$(ELIBDIR)\" -DPLUGIN_PATH="\"${libdir}\"" -DTESTDATADIR="\"$(top_srcdir)/test\""
-
-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 = \
- trivialtest \
- keywordlisttest \
- plugintest \
- multiload \
- mt_plugintest1 \
- mt_plugintest2 \
- mt_extracttest1 \
- mt_extracttest2
-
-TESTS = $(check_PROGRAMS) $(fuzz_tests)
-
-plugintest_SOURCES = \
- plugintest.c
-
-trivialtest_SOURCES = \
- trivialtest.c
-
-keywordlisttest_SOURCES = \
- keywordlisttest.c
-
-multiload_SOURCES = \
- multiload.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
-
-
diff --git a/src/test/bsp-1 b/src/test/bsp-1
@@ -1,66 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<HTML><!=
---About ten men mounted the sides of the Nautilus, armed with--><HEAD>
-=
-<meta name=3D"neutron" content=3D"Gg-EA-TPjB3wNj">
-<META HTTP-EQUIV=3D"=
-Content-Type" CONTENT=3D"text/html;charset=3Diso-8859-1">
-<meta name=3D=
-"circumnavigate" content=3D"u-88ic-eKf">
-<META content=3D"MSHTML 6.00.2=
-800.1226" name=3DGENERATOR>
-<meta name=3D"petard" content=3D"letter. Y=
-our name has for very long been familiar to me, and I have heard">
-<met=
-a name=3D"acme" content=3D"6brl8MK3-WR-6sHqVtRGPlQo">
-<meta name=3D"unb=
-eknownst" content=3D"Love of mankind. 5. Courage. 6. Generosity. 7. T=
-he love of death.">
-<meta name=3D"wherever" content=3D"8-87w-i6nR">
-<m=
-eta name=3D"halogen" content=3D"the mercury does not change during the i=
-nterval.">
-<STYLE></STYLE>
-</HEAD>
-<BODY bgColor=3D#ffffff>
-<DIV><FO=
-NT face=3DArial size=3D2>
-<p>
-O<kKW>ur U<R>S Phar<mEyd>macy i<M>s Op<W=
-KGS>en t<qkv>o Yo<ftXi>u!<br>
-<br>
-W<ma>e No<G>w Ha<FNIp>ve Xan<wO>ax,=
- Vali<Qc>um, an<tW>d Lev<KW>itra<br>
-Fr<KxQr>om U<V>S Pharma<Ecao>cies,=
- no<V>t Mex<yC>ico o<JHN>r Paki<KP>stan<br>
-<br>
-<QJqt>- Disc<e>reet a=
-n<FDhb>d Fa<T>st Next<WnMx>-Day Ship<VD>ments<br>
-<mCM>- Prescri<G>ptio=
-ns writ<gvk>ten b<jiM>y U<fgz>S Doc<x>tors<br>
-<br>
-<a href=3D"http://=
-www.realsraah.biz/vpr66=
-;51/?native">Lo<EJ>ok a<XJx>t ou<F>r Hu<ew>ge Sele<MTjZ>ction</a></p=
-><p>
-<br>
-<br></FONT>
-<font size=3D"1">
-<a href=3D"http://www.&=
-#114;ealsraah.biz/u=
-10;subscribe.ddd?marsupial">D<tR>o No<y>t Se<wXcb>nd =
-Fut<k>ure Mail<Fuo>ings</a></p><p>
-<br>
-<br>
-<br>
-can lay a tariff f=
-or revenue, not for protection of home
-with it at the same rate as the =
-whole. These fixed stars follow
-from God in a supernatural manner, and =
-as she holds that the
-</font><br>
-</p>
-<DIV>
-</DIV></BODY><!--=
-that is the Law, Moreau held up his lank white hand.--></HTML>
-\ No newline at end of file
diff --git a/src/test/mt_extracttest1.c b/src/test/mt_extracttest1.c
@@ -1,160 +0,0 @@
-/**
- * @file test/mt_extracttest1.c
- * @brief test keyword extraction from multiple threads simultaneously
- * @author Heikki Lindholm
- */
-#include "platform.h"
-#include "extractor.h"
-#include <pthread.h>
-
-struct TaskData
-{
- int id;
- const char *filename;
-};
-
-static volatile int done = 0;
-static volatile int failed = 0;
-
-pthread_mutex_t reference_lock = PTHREAD_MUTEX_INITIALIZER;
-static EXTRACTOR_KeywordList *reference_list;
-
-static int
-compare_keywords_to_ref (EXTRACTOR_KeywordList * list)
-{
- EXTRACTOR_KeywordList *ptr1, *ptr2;
- unsigned int cnt;
- int *match;
- int i;
-
- cnt = EXTRACTOR_countKeywords (list);
-
- pthread_mutex_lock (&reference_lock);
-
- if (cnt != EXTRACTOR_countKeywords (reference_list))
- {
- pthread_mutex_unlock (&reference_lock);
- return -1;
- }
-
- match = alloca (cnt * sizeof (int));
- memset (match, 0x00, cnt * sizeof (int));
- ptr1 = list;
- while (ptr1 != NULL)
- {
- int found;
- found = 0;
- ptr2 = reference_list;
- i = 0;
- while (ptr2 != NULL)
- {
- if (ptr2->keywordType == ptr1->keywordType &&
- strcmp (ptr2->keyword, ptr1->keyword) == 0 && match[i] == 0)
- {
- found = 1;
- match[i] = 1;
- break;
- }
- i++;
- ptr2 = ptr2->next;
- }
- if (found == 0)
- break;
- ptr1 = ptr1->next;
- }
-
- pthread_mutex_unlock (&reference_lock);
- for (i = 0; i < cnt; i++)
- if (match[i] == 0)
- return -1;
-
- return 0;
-}
-
-static EXTRACTOR_KeywordList *
-get_keywords_for_file (const char *filename)
-{
- EXTRACTOR_ExtractorList *el;
- EXTRACTOR_KeywordList *list;
-
- el = EXTRACTOR_loadDefaultLibraries ();
- if (el == NULL)
- {
- printf ("ERROR: failed to load plugins!\n");
- return NULL;
- }
- errno = 0;
- list = EXTRACTOR_getKeywords (el, filename);
- if (errno != 0) {
- printf("ERROR: EXTRACTOR_getKeywords: %s\n", strerror(errno));
- }
- /*EXTRACTOR_printKeywords (stderr, list); */
- EXTRACTOR_removeAll (el);
-
- return list;
-}
-
-static void *
-test_plugins (void *arg)
-{
- struct TaskData *td = (struct TaskData *)arg;
- while (!done)
- {
- EXTRACTOR_KeywordList *list;
-
- list = get_keywords_for_file (td->filename);
-
- if ((list == NULL) || (compare_keywords_to_ref (list) != 0))
- {
- printf ("ERROR: thread id %d failed keyword comparison!\n", td->id);
- failed = 1;
- }
- if (list != NULL)
- EXTRACTOR_freeKeywords (list);
- }
- return 0;
-}
-
-static const char *filename = TESTDATADIR "/text2.sxw";
-
-#define TEST_SECS 10
-
-int
-main (int argc, char *argv[])
-{
- int num_tasks = 10;
- pthread_t task_list[num_tasks];
- struct TaskData td[num_tasks];
- int ret = 0;
- int i;
-
- printf("testing with '%s' for %d seconds\n", filename, TEST_SECS);
- reference_list = get_keywords_for_file (filename);
-
- for (i = 0; i < num_tasks; i++)
- {
- td[i].id = i;
- td[i].filename = filename;
- ret = pthread_create (&task_list[i], NULL, test_plugins, &td[i]);
- if (ret != 0)
- {
- printf ("ERROR: pthread_create failed for thread %d\n", i);
- num_tasks = i;
- done = 1;
- break;
- }
- }
- if (!done)
- sleep (TEST_SECS);
- done = 1;
- for (i = 0; i < num_tasks; i++)
- {
- if (pthread_join (task_list[i], NULL) != 0)
- printf ("WARNING: pthread_join failed for thread %d\n", i);
- }
-
- if (reference_list != NULL)
- EXTRACTOR_freeKeywords (reference_list);
-
- return failed;
-}
diff --git a/src/test/mt_extracttest2.c b/src/test/mt_extracttest2.c
@@ -1,190 +0,0 @@
-/**
- * @file test/mt_extracttest2.c
- * @brief test keyword extraction from multiple threads simultaneously
- * with multiple files and use thumbnail extractors as well
- * @author Heikki Lindholm
- */
-#include "platform.h"
-#include "extractor.h"
-#include <pthread.h>
-
-struct FileData
-{
- const char *filename;
- int use_thumbnailer;
-};
-
-struct TaskData
-{
- int id;
- const struct FileData *file;
-};
-
-static volatile int done = 0;
-static volatile int failed = 0;
-
-pthread_mutex_t reference_lock = PTHREAD_MUTEX_INITIALIZER;
-static EXTRACTOR_KeywordList *reference_list;
-
-static int
-compare_keywords_to_ref (EXTRACTOR_KeywordList * list)
-{
- EXTRACTOR_KeywordList *ptr1, *ptr2;
- unsigned int cnt;
- int *match;
- int i;
-
- cnt = EXTRACTOR_countKeywords (list);
-
- pthread_mutex_lock (&reference_lock);
-
- if (cnt != EXTRACTOR_countKeywords (reference_list))
- {
- pthread_mutex_unlock (&reference_lock);
- return -1;
- }
-
- match = alloca (cnt * sizeof (int));
- memset (match, 0x00, cnt * sizeof (int));
- ptr1 = list;
- while (ptr1 != NULL)
- {
- int found;
- found = 0;
- ptr2 = reference_list;
- i = 0;
- while (ptr2 != NULL)
- {
- if (ptr2->keywordType == ptr1->keywordType &&
- strcmp (ptr2->keyword, ptr1->keyword) == 0 && match[i] == 0)
- {
- found = 1;
- match[i] = 1;
- break;
- }
- i++;
- ptr2 = ptr2->next;
- }
- if (found == 0)
- break;
- ptr1 = ptr1->next;
- }
-
- pthread_mutex_unlock (&reference_lock);
- for (i = 0; i < cnt; i++)
- if (match[i] == 0)
- return -1;
-
- return 0;
-}
-
-static EXTRACTOR_KeywordList *
-get_keywords_for_file (const struct FileData *file)
-{
- EXTRACTOR_ExtractorList *el;
- EXTRACTOR_KeywordList *list;
-
- if (file->use_thumbnailer)
- {
- el = EXTRACTOR_addLibrary (NULL, "libextractor_mime");
- el = EXTRACTOR_loadConfigLibraries (el, "-libextractor_thumbnail");
- }
- else
- {
- el = EXTRACTOR_loadDefaultLibraries ();
- }
- if (el == NULL)
- {
- printf ("ERROR: failed to load plugins!\n");
- return NULL;
- }
- errno = 0;
- list = EXTRACTOR_getKeywords (el, file->filename);
- if (errno != 0) {
- printf("ERROR: EXTRACTOR_getKeywords: %s\n", strerror(errno));
- }
- /*EXTRACTOR_printKeywords (stderr, list); */
- EXTRACTOR_removeAll (el);
-
- return list;
-}
-
-static void *
-test_plugins (void *arg)
-{
- struct TaskData *td = (struct TaskData *)arg;
- while (!done)
- {
- EXTRACTOR_KeywordList *list;
-
- list = get_keywords_for_file (td->file);
-
- if ((list == NULL) || (compare_keywords_to_ref (list) != 0))
- {
- printf ("ERROR: thread id %d failed keyword comparison!\n", td->id);
- failed = 1;
- }
- if (list != NULL)
- EXTRACTOR_freeKeywords (list);
- }
- return 0;
-}
-
-static const struct FileData files[] = {
- { TESTDATADIR "/test.bmp", 0 },
- { TESTDATADIR "/test.jpg", 0 },
- { TESTDATADIR "/test.png", 0 },
- { TESTDATADIR "/test.sxw", 0 },
- { TESTDATADIR "/test.bmp", 1 },
- { TESTDATADIR "/test.png", 1 },
- { NULL, 0 }
-};
-
-#define TEST_SECS 10
-
-int
-main (int argc, char *argv[])
-{
- int num_tasks = 10;
- pthread_t task_list[num_tasks];
- struct TaskData td[num_tasks];
- int ret = 0;
- int i;
- int n;
-
- n = 0;
- while ((files[n].filename != NULL) && (!failed)) {
- printf("testing with '%s' for %d seconds\n", files[n].filename, TEST_SECS);
- reference_list = get_keywords_for_file (&files[n]);
-
- for (i = 0; i < num_tasks; i++)
- {
- td[i].id = i;
- td[i].file = &files[n];
- ret = pthread_create (&task_list[i], NULL, test_plugins, &td[i]);
- if (ret != 0)
- {
- printf ("ERROR: pthread_create failed for thread %d\n", i);
- num_tasks = i;
- done = 1;
- break;
- }
- }
- if (!done)
- sleep (TEST_SECS);
- done = 1;
- for (i = 0; i < num_tasks; i++)
- {
- if (pthread_join (task_list[i], NULL) != 0)
- printf ("WARNING: pthread_join failed for thread %d\n", i);
- }
-
- done = 0;
- if (reference_list != NULL)
- EXTRACTOR_freeKeywords (reference_list);
-
- n++;
- }
-
- return failed;
-}
diff --git a/src/test/mt_plugintest1.c b/src/test/mt_plugintest1.c
@@ -1,101 +0,0 @@
-/**
- * @file test/mt-plugintest1.c
- * @brief test extractor plugin load/unload from multiple threads
- * simultaneously
- * @author Heikki Lindholm
- */
-#include "platform.h"
-#include "extractor.h"
-#include <pthread.h>
-
-struct TaskData
-{
- int id;
-};
-
-static volatile int done = 0;
-static volatile int failed = 0;
-
-static void *
-test_plugins (void *arg)
-{
- struct TaskData *td = (struct TaskData *) arg;
- EXTRACTOR_ExtractorList *el;
- int i;
-
- while (!done)
- {
- /* do some loading and unloading */
- for (i = 0; i < 10; i++)
- {
- el = EXTRACTOR_loadDefaultLibraries ();
- EXTRACTOR_removeAll (el);
- }
-
- /* do some load/unload tests */
- el = EXTRACTOR_addLibrary (NULL, "libextractor_split");
- el = EXTRACTOR_addLibrary (el, "libextractor_mime");
- el = EXTRACTOR_addLibrary (el, "libextractor_filename");
- el = EXTRACTOR_removeLibrary (el, "libextractor_mime");
- el = EXTRACTOR_removeLibrary (el, "libextractor_split");
- el = EXTRACTOR_removeLibrary (el, "libextractor_filename");
- if (el != NULL)
- {
- printf ("add-remove test (1) failed in thread %d!\n", td->id);
- failed = 1;
- }
-
- el = EXTRACTOR_addLibrary (NULL, "libextractor_split");
- el = EXTRACTOR_addLibrary (el, "libextractor_mime");
- el = EXTRACTOR_addLibrary (el, "libextractor_filename");
- el = EXTRACTOR_removeLibrary (el, "libextractor_mime");
- el = EXTRACTOR_removeLibrary (el, "libextractor_filename");
- el = EXTRACTOR_removeLibrary (el, "libextractor_split");
- if (el != NULL)
- {
- printf ("add-remove test (2) failed in thread %d!\n", td->id);
- failed = 1;
- }
-
- el = EXTRACTOR_loadConfigLibraries (NULL, "libextractor_filename");
- el = EXTRACTOR_loadConfigLibraries (el, "-libextractor_split");
- EXTRACTOR_removeAll (el);
- }
- return 0;
-}
-
-#define TEST_SECS 10
-
-int
-main (int argc, char *argv[])
-{
- int num_tasks = 10;
- pthread_t task_list[num_tasks];
- struct TaskData td[num_tasks];
- int ret = 0;
- int i;
-
- printf("testing for %d seconds\n", TEST_SECS);
- for (i = 0; i < num_tasks; i++)
- {
- td[i].id = i;
- ret = pthread_create (&task_list[i], NULL, test_plugins, &td[i]);
- if (ret != 0)
- {
- printf ("ERROR: pthread_create failed for thread %d\n", i);
- num_tasks = i;
- done = 1;
- break;
- }
- }
- if (!done)
- sleep (TEST_SECS);
- done = 1;
- for (i = 0; i < num_tasks; i++)
- {
- if (pthread_join (task_list[i], NULL) != 0)
- printf ("WARNING: pthread_join failed for thread %d\n", i);
- }
-
- return failed;
-}
diff --git a/src/test/mt_plugintest2.c b/src/test/mt_plugintest2.c
@@ -1,111 +0,0 @@
-/*
- This file is part of libextractor.
- (C) 2007, 2008, 2009 Vidyut Samanta and Christian Grothoff
-
- libextractor is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
- option) any later version.
-
- libextractor is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with libextractor; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
-/**
- * @file test/mt-plugintest1.c
- * @brief test extractor plugin load/unload from multiple threads
- * simultaneously - thumbnailer plugins test
- * @author Heikki Lindholm
- */
-#include "platform.h"
-#include "extractor.h"
-#include <pthread.h>
-
-struct TaskData
-{
- int id;
-};
-
-static volatile int done = 0;
-
-static volatile int failed = 0;
-
-static void *
-test_plugins (void *arg)
-{
- struct TaskData *td = (struct TaskData *) arg;
- EXTRACTOR_ExtractorList *el;
-
- while (!done)
- {
- el = EXTRACTOR_addLibrary (NULL, "libextractor_thumbnailgtk");
- el = EXTRACTOR_removeLibrary (el, "libextractor_thumbnailgtk");
- if (el != NULL)
- {
- printf ("add-remove test failed (gtk) in thread %d!\n", td->id);
- failed = 1;
- }
- el = EXTRACTOR_addLibrary (NULL, "libextractor_thumbnailqt");
- el = EXTRACTOR_removeLibrary (el, "libextractor_thumbnailqt");
- if (el != NULL)
- {
- printf ("add-remove test failed (qt) in thread %d!\n", td->id);
- failed = 1;
- }
- el = EXTRACTOR_addLibrary (NULL, "libextractor_thumbnailffmpeg");
- el = EXTRACTOR_removeLibrary (el, "libextractor_thumbnailffmpeg");
- if (el != NULL)
- {
- printf ("add-remove test failed (ffmpeg) in thread %d!\n", td->id);
- failed = 1;
- }
- }
- return 0;
-}
-
-#define TEST_SECS 10
-
-#define NUM_TASKS 10
-
-int
-main (int argc, char *argv[])
-{
- pthread_t task_list[NUM_TASKS];
- struct TaskData td[NUM_TASKS];
- int ret = 0;
- int i;
- int max = NUM_TASKS;
- void * unused;
-
- printf("testing for %d seconds\n", TEST_SECS);
- for (i = 0; i < NUM_TASKS; i++)
- {
- td[i].id = i;
- ret = pthread_create (&task_list[i], NULL, &test_plugins, &td[i]);
- if (ret != 0)
- {
- printf ("ERROR: pthread_create failed for thread %d\n", i);
- max = i;
- done = 1;
- break;
- }
- }
- printf("Threads running!\n");
- if (!done)
- sleep (TEST_SECS);
- printf("Shutting down...\n");
- done = 1;
- for (i = 0; i < max; i++)
- {
- if (pthread_join (task_list[i], &unused) != 0)
- printf ("WARNING: pthread_join failed for thread %d\n", i);
- }
-
- return failed;
-}