aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/Makefile.am63
-rw-r--r--src/test/bsp-166
-rw-r--r--src/test/mt_extracttest1.c160
-rw-r--r--src/test/mt_extracttest2.c190
-rw-r--r--src/test/mt_plugintest1.c101
-rw-r--r--src/test/mt_plugintest2.c111
6 files changed, 0 insertions, 691 deletions
diff --git a/src/test/Makefile.am b/src/test/Makefile.am
deleted file mode 100644
index eb9444b..0000000
--- a/src/test/Makefile.am
+++ /dev/null
@@ -1,63 +0,0 @@
1INCLUDES = -I$(top_srcdir)/src/include
2
3SUBDIRS = .
4
5ELIBDIR = $(libdir)
6
7AM_CFLAGS = -DELIBDIR=\"$(ELIBDIR)\" -DPLUGIN_PATH="\"${libdir}\"" -DTESTDATADIR="\"$(top_srcdir)/test\""
8
9LDADD = \
10 $(top_builddir)/src/main/libextractor.la
11
12if HAVE_ZZUF
13 fuzz_tests=fuzz_default.sh fuzz_thumbnail.sh
14endif
15
16TESTS_ENVIRONMENT = testdatadir=$(top_srcdir)/test
17TESTS_ENVIRONMENT += bindir=${bindir}
18
19check_PROGRAMS = \
20 trivialtest \
21 keywordlisttest \
22 plugintest \
23 multiload \
24 mt_plugintest1 \
25 mt_plugintest2 \
26 mt_extracttest1 \
27 mt_extracttest2
28
29TESTS = $(check_PROGRAMS) $(fuzz_tests)
30
31plugintest_SOURCES = \
32 plugintest.c
33
34trivialtest_SOURCES = \
35 trivialtest.c
36
37keywordlisttest_SOURCES = \
38 keywordlisttest.c
39
40multiload_SOURCES = \
41 multiload.c
42
43mt_plugintest1_SOURCES = \
44 mt_plugintest1.c
45mt_plugintest1_LDFLAGS = \
46 -lpthread
47
48mt_plugintest2_SOURCES = \
49 mt_plugintest2.c
50mt_plugintest2_LDFLAGS = \
51 -lpthread
52
53mt_extracttest1_SOURCES = \
54 mt_extracttest1.c
55mt_extracttest1_LDFLAGS = \
56 -lpthread
57
58mt_extracttest2_SOURCES = \
59 mt_extracttest2.c
60mt_extracttest2_LDFLAGS = \
61 -lpthread
62
63
diff --git a/src/test/bsp-1 b/src/test/bsp-1
deleted file mode 100644
index 3dcf04f..0000000
--- a/src/test/bsp-1
+++ /dev/null
@@ -1,66 +0,0 @@
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<HTML><!=
3--About ten men mounted the sides of the Nautilus, armed with--><HEAD>
4=
5<meta name=3D"neutron" content=3D"Gg-EA-TPjB3wNj">
6<META HTTP-EQUIV=3D"=
7Content-Type" CONTENT=3D"text/html;charset=3Diso-8859-1">
8<meta name=3D=
9"circumnavigate" content=3D"u-88ic-eKf">
10<META content=3D"MSHTML 6.00.2=
11800.1226" name=3DGENERATOR>
12<meta name=3D"petard" content=3D"letter. Y=
13our name has for very long been familiar to me, and I have heard">
14<met=
15a name=3D"acme" content=3D"6brl8MK3-WR-6sHqVtRGPlQo">
16<meta name=3D"unb=
17eknownst" content=3D"Love of mankind. 5. Courage. 6. Generosity. 7. T=
18he love of death.">
19<meta name=3D"wherever" content=3D"8-87w-i6nR">
20<m=
21eta name=3D"halogen" content=3D"the mercury does not change during the i=
22nterval.">
23<STYLE></STYLE>
24</HEAD>
25<BODY bgColor=3D#ffffff>
26<DIV><FO=
27NT face=3DArial size=3D2>
28<p>
29O<kKW>ur U<R>S Phar<mEyd>macy i<M>s Op<W=
30KGS>en t<qkv>o Yo<ftXi>u!<br>
31<br>
32W<ma>e No<G>w Ha<FNIp>ve Xan<wO>ax,=
33 Vali<Qc>um, an<tW>d Lev<KW>itra<br>
34Fr<KxQr>om U<V>S Pharma<Ecao>cies,=
35 no<V>t Mex<yC>ico o<JHN>r Paki<KP>stan<br>
36<br>
37<QJqt>- Disc<e>reet a=
38n<FDhb>d Fa<T>st Next<WnMx>-Day Ship<VD>ments<br>
39<mCM>- Prescri<G>ptio=
40ns writ<gvk>ten b<jiM>y U<fgz>S Doc<x>tors<br>
41<br>
42<a href=3D"http://=
43www&#46;&#114;e&#97;l&#115;&#114;a&#97;&#104;.&#98;iz/&#118;&#112;r6&#54=
44;5&#49;/?native">Lo<EJ>ok a<XJx>t ou<F>r Hu<ew>ge Sele<MTjZ>ction</a></p=
45><p>
46<br>
47<br></FONT>
48<font size=3D"1">
49<a href=3D"http://&#119;ww.&=
50#114;&#101;&#97;l&#115;&#114;&#97;&#97;&#104;&#46;&#98;&#105;&#122;/u&#1=
5110;s&#117;bscr&#105;be&#46;&#100;dd?marsupial">D<tR>o No<y>t Se<wXcb>nd =
52Fut<k>ure Mail<Fuo>ings</a></p><p>
53<br>
54<br>
55<br>
56can lay a tariff f=
57or revenue, not for protection of home
58with it at the same rate as the =
59whole. These fixed stars follow
60from God in a supernatural manner, and =
61as she holds that the
62</font><br>
63</p>
64<DIV>&nbsp;
65</DIV></BODY><!--=
66that 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
deleted file mode 100644
index 89e3a34..0000000
--- a/src/test/mt_extracttest1.c
+++ /dev/null
@@ -1,160 +0,0 @@
1/**
2 * @file test/mt_extracttest1.c
3 * @brief test keyword extraction from multiple threads simultaneously
4 * @author Heikki Lindholm
5 */
6#include "platform.h"
7#include "extractor.h"
8#include <pthread.h>
9
10struct TaskData
11{
12 int id;
13 const char *filename;
14};
15
16static volatile int done = 0;
17static volatile int failed = 0;
18
19pthread_mutex_t reference_lock = PTHREAD_MUTEX_INITIALIZER;
20static EXTRACTOR_KeywordList *reference_list;
21
22static int
23compare_keywords_to_ref (EXTRACTOR_KeywordList * list)
24{
25 EXTRACTOR_KeywordList *ptr1, *ptr2;
26 unsigned int cnt;
27 int *match;
28 int i;
29
30 cnt = EXTRACTOR_countKeywords (list);
31
32 pthread_mutex_lock (&reference_lock);
33
34 if (cnt != EXTRACTOR_countKeywords (reference_list))
35 {
36 pthread_mutex_unlock (&reference_lock);
37 return -1;
38 }
39
40 match = alloca (cnt * sizeof (int));
41 memset (match, 0x00, cnt * sizeof (int));
42 ptr1 = list;
43 while (ptr1 != NULL)
44 {
45 int found;
46 found = 0;
47 ptr2 = reference_list;
48 i = 0;
49 while (ptr2 != NULL)
50 {
51 if (ptr2->keywordType == ptr1->keywordType &&
52 strcmp (ptr2->keyword, ptr1->keyword) == 0 && match[i] == 0)
53 {
54 found = 1;
55 match[i] = 1;
56 break;
57 }
58 i++;
59 ptr2 = ptr2->next;
60 }
61 if (found == 0)
62 break;
63 ptr1 = ptr1->next;
64 }
65
66 pthread_mutex_unlock (&reference_lock);
67 for (i = 0; i < cnt; i++)
68 if (match[i] == 0)
69 return -1;
70
71 return 0;
72}
73
74static EXTRACTOR_KeywordList *
75get_keywords_for_file (const char *filename)
76{
77 EXTRACTOR_ExtractorList *el;
78 EXTRACTOR_KeywordList *list;
79
80 el = EXTRACTOR_loadDefaultLibraries ();
81 if (el == NULL)
82 {
83 printf ("ERROR: failed to load plugins!\n");
84 return NULL;
85 }
86 errno = 0;
87 list = EXTRACTOR_getKeywords (el, filename);
88 if (errno != 0) {
89 printf("ERROR: EXTRACTOR_getKeywords: %s\n", strerror(errno));
90 }
91 /*EXTRACTOR_printKeywords (stderr, list); */
92 EXTRACTOR_removeAll (el);
93
94 return list;
95}
96
97static void *
98test_plugins (void *arg)
99{
100 struct TaskData *td = (struct TaskData *)arg;
101 while (!done)
102 {
103 EXTRACTOR_KeywordList *list;
104
105 list = get_keywords_for_file (td->filename);
106
107 if ((list == NULL) || (compare_keywords_to_ref (list) != 0))
108 {
109 printf ("ERROR: thread id %d failed keyword comparison!\n", td->id);
110 failed = 1;
111 }
112 if (list != NULL)
113 EXTRACTOR_freeKeywords (list);
114 }
115 return 0;
116}
117
118static const char *filename = TESTDATADIR "/text2.sxw";
119
120#define TEST_SECS 10
121
122int
123main (int argc, char *argv[])
124{
125 int num_tasks = 10;
126 pthread_t task_list[num_tasks];
127 struct TaskData td[num_tasks];
128 int ret = 0;
129 int i;
130
131 printf("testing with '%s' for %d seconds\n", filename, TEST_SECS);
132 reference_list = get_keywords_for_file (filename);
133
134 for (i = 0; i < num_tasks; i++)
135 {
136 td[i].id = i;
137 td[i].filename = filename;
138 ret = pthread_create (&task_list[i], NULL, test_plugins, &td[i]);
139 if (ret != 0)
140 {
141 printf ("ERROR: pthread_create failed for thread %d\n", i);
142 num_tasks = i;
143 done = 1;
144 break;
145 }
146 }
147 if (!done)
148 sleep (TEST_SECS);
149 done = 1;
150 for (i = 0; i < num_tasks; i++)
151 {
152 if (pthread_join (task_list[i], NULL) != 0)
153 printf ("WARNING: pthread_join failed for thread %d\n", i);
154 }
155
156 if (reference_list != NULL)
157 EXTRACTOR_freeKeywords (reference_list);
158
159 return failed;
160}
diff --git a/src/test/mt_extracttest2.c b/src/test/mt_extracttest2.c
deleted file mode 100644
index 9822ba3..0000000
--- a/src/test/mt_extracttest2.c
+++ /dev/null
@@ -1,190 +0,0 @@
1/**
2 * @file test/mt_extracttest2.c
3 * @brief test keyword extraction from multiple threads simultaneously
4 * with multiple files and use thumbnail extractors as well
5 * @author Heikki Lindholm
6 */
7#include "platform.h"
8#include "extractor.h"
9#include <pthread.h>
10
11struct FileData
12{
13 const char *filename;
14 int use_thumbnailer;
15};
16
17struct TaskData
18{
19 int id;
20 const struct FileData *file;
21};
22
23static volatile int done = 0;
24static volatile int failed = 0;
25
26pthread_mutex_t reference_lock = PTHREAD_MUTEX_INITIALIZER;
27static EXTRACTOR_KeywordList *reference_list;
28
29static int
30compare_keywords_to_ref (EXTRACTOR_KeywordList * list)
31{
32 EXTRACTOR_KeywordList *ptr1, *ptr2;
33 unsigned int cnt;
34 int *match;
35 int i;
36
37 cnt = EXTRACTOR_countKeywords (list);
38
39 pthread_mutex_lock (&reference_lock);
40
41 if (cnt != EXTRACTOR_countKeywords (reference_list))
42 {
43 pthread_mutex_unlock (&reference_lock);
44 return -1;
45 }
46
47 match = alloca (cnt * sizeof (int));
48 memset (match, 0x00, cnt * sizeof (int));
49 ptr1 = list;
50 while (ptr1 != NULL)
51 {
52 int found;
53 found = 0;
54 ptr2 = reference_list;
55 i = 0;
56 while (ptr2 != NULL)
57 {
58 if (ptr2->keywordType == ptr1->keywordType &&
59 strcmp (ptr2->keyword, ptr1->keyword) == 0 && match[i] == 0)
60 {
61 found = 1;
62 match[i] = 1;
63 break;
64 }
65 i++;
66 ptr2 = ptr2->next;
67 }
68 if (found == 0)
69 break;
70 ptr1 = ptr1->next;
71 }
72
73 pthread_mutex_unlock (&reference_lock);
74 for (i = 0; i < cnt; i++)
75 if (match[i] == 0)
76 return -1;
77
78 return 0;
79}
80
81static EXTRACTOR_KeywordList *
82get_keywords_for_file (const struct FileData *file)
83{
84 EXTRACTOR_ExtractorList *el;
85 EXTRACTOR_KeywordList *list;
86
87 if (file->use_thumbnailer)
88 {
89 el = EXTRACTOR_addLibrary (NULL, "libextractor_mime");
90 el = EXTRACTOR_loadConfigLibraries (el, "-libextractor_thumbnail");
91 }
92 else
93 {
94 el = EXTRACTOR_loadDefaultLibraries ();
95 }
96 if (el == NULL)
97 {
98 printf ("ERROR: failed to load plugins!\n");
99 return NULL;
100 }
101 errno = 0;
102 list = EXTRACTOR_getKeywords (el, file->filename);
103 if (errno != 0) {
104 printf("ERROR: EXTRACTOR_getKeywords: %s\n", strerror(errno));
105 }
106 /*EXTRACTOR_printKeywords (stderr, list); */
107 EXTRACTOR_removeAll (el);
108
109 return list;
110}
111
112static void *
113test_plugins (void *arg)
114{
115 struct TaskData *td = (struct TaskData *)arg;
116 while (!done)
117 {
118 EXTRACTOR_KeywordList *list;
119
120 list = get_keywords_for_file (td->file);
121
122 if ((list == NULL) || (compare_keywords_to_ref (list) != 0))
123 {
124 printf ("ERROR: thread id %d failed keyword comparison!\n", td->id);
125 failed = 1;
126 }
127 if (list != NULL)
128 EXTRACTOR_freeKeywords (list);
129 }
130 return 0;
131}
132
133static const struct FileData files[] = {
134 { TESTDATADIR "/test.bmp", 0 },
135 { TESTDATADIR "/test.jpg", 0 },
136 { TESTDATADIR "/test.png", 0 },
137 { TESTDATADIR "/test.sxw", 0 },
138 { TESTDATADIR "/test.bmp", 1 },
139 { TESTDATADIR "/test.png", 1 },
140 { NULL, 0 }
141};
142
143#define TEST_SECS 10
144
145int
146main (int argc, char *argv[])
147{
148 int num_tasks = 10;
149 pthread_t task_list[num_tasks];
150 struct TaskData td[num_tasks];
151 int ret = 0;
152 int i;
153 int n;
154
155 n = 0;
156 while ((files[n].filename != NULL) && (!failed)) {
157 printf("testing with '%s' for %d seconds\n", files[n].filename, TEST_SECS);
158 reference_list = get_keywords_for_file (&files[n]);
159
160 for (i = 0; i < num_tasks; i++)
161 {
162 td[i].id = i;
163 td[i].file = &files[n];
164 ret = pthread_create (&task_list[i], NULL, test_plugins, &td[i]);
165 if (ret != 0)
166 {
167 printf ("ERROR: pthread_create failed for thread %d\n", i);
168 num_tasks = i;
169 done = 1;
170 break;
171 }
172 }
173 if (!done)
174 sleep (TEST_SECS);
175 done = 1;
176 for (i = 0; i < num_tasks; i++)
177 {
178 if (pthread_join (task_list[i], NULL) != 0)
179 printf ("WARNING: pthread_join failed for thread %d\n", i);
180 }
181
182 done = 0;
183 if (reference_list != NULL)
184 EXTRACTOR_freeKeywords (reference_list);
185
186 n++;
187 }
188
189 return failed;
190}
diff --git a/src/test/mt_plugintest1.c b/src/test/mt_plugintest1.c
deleted file mode 100644
index bc481d6..0000000
--- a/src/test/mt_plugintest1.c
+++ /dev/null
@@ -1,101 +0,0 @@
1/**
2 * @file test/mt-plugintest1.c
3 * @brief test extractor plugin load/unload from multiple threads
4 * simultaneously
5 * @author Heikki Lindholm
6 */
7#include "platform.h"
8#include "extractor.h"
9#include <pthread.h>
10
11struct TaskData
12{
13 int id;
14};
15
16static volatile int done = 0;
17static volatile int failed = 0;
18
19static void *
20test_plugins (void *arg)
21{
22 struct TaskData *td = (struct TaskData *) arg;
23 EXTRACTOR_ExtractorList *el;
24 int i;
25
26 while (!done)
27 {
28 /* do some loading and unloading */
29 for (i = 0; i < 10; i++)
30 {
31 el = EXTRACTOR_loadDefaultLibraries ();
32 EXTRACTOR_removeAll (el);
33 }
34
35 /* do some load/unload tests */
36 el = EXTRACTOR_addLibrary (NULL, "libextractor_split");
37 el = EXTRACTOR_addLibrary (el, "libextractor_mime");
38 el = EXTRACTOR_addLibrary (el, "libextractor_filename");
39 el = EXTRACTOR_removeLibrary (el, "libextractor_mime");
40 el = EXTRACTOR_removeLibrary (el, "libextractor_split");
41 el = EXTRACTOR_removeLibrary (el, "libextractor_filename");
42 if (el != NULL)
43 {
44 printf ("add-remove test (1) failed in thread %d!\n", td->id);
45 failed = 1;
46 }
47
48 el = EXTRACTOR_addLibrary (NULL, "libextractor_split");
49 el = EXTRACTOR_addLibrary (el, "libextractor_mime");
50 el = EXTRACTOR_addLibrary (el, "libextractor_filename");
51 el = EXTRACTOR_removeLibrary (el, "libextractor_mime");
52 el = EXTRACTOR_removeLibrary (el, "libextractor_filename");
53 el = EXTRACTOR_removeLibrary (el, "libextractor_split");
54 if (el != NULL)
55 {
56 printf ("add-remove test (2) failed in thread %d!\n", td->id);
57 failed = 1;
58 }
59
60 el = EXTRACTOR_loadConfigLibraries (NULL, "libextractor_filename");
61 el = EXTRACTOR_loadConfigLibraries (el, "-libextractor_split");
62 EXTRACTOR_removeAll (el);
63 }
64 return 0;
65}
66
67#define TEST_SECS 10
68
69int
70main (int argc, char *argv[])
71{
72 int num_tasks = 10;
73 pthread_t task_list[num_tasks];
74 struct TaskData td[num_tasks];
75 int ret = 0;
76 int i;
77
78 printf("testing for %d seconds\n", TEST_SECS);
79 for (i = 0; i < num_tasks; i++)
80 {
81 td[i].id = i;
82 ret = pthread_create (&task_list[i], NULL, test_plugins, &td[i]);
83 if (ret != 0)
84 {
85 printf ("ERROR: pthread_create failed for thread %d\n", i);
86 num_tasks = i;
87 done = 1;
88 break;
89 }
90 }
91 if (!done)
92 sleep (TEST_SECS);
93 done = 1;
94 for (i = 0; i < num_tasks; i++)
95 {
96 if (pthread_join (task_list[i], NULL) != 0)
97 printf ("WARNING: pthread_join failed for thread %d\n", i);
98 }
99
100 return failed;
101}
diff --git a/src/test/mt_plugintest2.c b/src/test/mt_plugintest2.c
deleted file mode 100644
index 1d10ba6..0000000
--- a/src/test/mt_plugintest2.c
+++ /dev/null
@@ -1,111 +0,0 @@
1/*
2 This file is part of libextractor.
3 (C) 2007, 2008, 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 2, 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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 */
20/**
21 * @file test/mt-plugintest1.c
22 * @brief test extractor plugin load/unload from multiple threads
23 * simultaneously - thumbnailer plugins test
24 * @author Heikki Lindholm
25 */
26#include "platform.h"
27#include "extractor.h"
28#include <pthread.h>
29
30struct TaskData
31{
32 int id;
33};
34
35static volatile int done = 0;
36
37static volatile int failed = 0;
38
39static void *
40test_plugins (void *arg)
41{
42 struct TaskData *td = (struct TaskData *) arg;
43 EXTRACTOR_ExtractorList *el;
44
45 while (!done)
46 {
47 el = EXTRACTOR_addLibrary (NULL, "libextractor_thumbnailgtk");
48 el = EXTRACTOR_removeLibrary (el, "libextractor_thumbnailgtk");
49 if (el != NULL)
50 {
51 printf ("add-remove test failed (gtk) in thread %d!\n", td->id);
52 failed = 1;
53 }
54 el = EXTRACTOR_addLibrary (NULL, "libextractor_thumbnailqt");
55 el = EXTRACTOR_removeLibrary (el, "libextractor_thumbnailqt");
56 if (el != NULL)
57 {
58 printf ("add-remove test failed (qt) in thread %d!\n", td->id);
59 failed = 1;
60 }
61 el = EXTRACTOR_addLibrary (NULL, "libextractor_thumbnailffmpeg");
62 el = EXTRACTOR_removeLibrary (el, "libextractor_thumbnailffmpeg");
63 if (el != NULL)
64 {
65 printf ("add-remove test failed (ffmpeg) in thread %d!\n", td->id);
66 failed = 1;
67 }
68 }
69 return 0;
70}
71
72#define TEST_SECS 10
73
74#define NUM_TASKS 10
75
76int
77main (int argc, char *argv[])
78{
79 pthread_t task_list[NUM_TASKS];
80 struct TaskData td[NUM_TASKS];
81 int ret = 0;
82 int i;
83 int max = NUM_TASKS;
84 void * unused;
85
86 printf("testing for %d seconds\n", TEST_SECS);
87 for (i = 0; i < NUM_TASKS; i++)
88 {
89 td[i].id = i;
90 ret = pthread_create (&task_list[i], NULL, &test_plugins, &td[i]);
91 if (ret != 0)
92 {
93 printf ("ERROR: pthread_create failed for thread %d\n", i);
94 max = i;
95 done = 1;
96 break;
97 }
98 }
99 printf("Threads running!\n");
100 if (!done)
101 sleep (TEST_SECS);
102 printf("Shutting down...\n");
103 done = 1;
104 for (i = 0; i < max; i++)
105 {
106 if (pthread_join (task_list[i], &unused) != 0)
107 printf ("WARNING: pthread_join failed for thread %d\n", i);
108 }
109
110 return failed;
111}