aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-08-14 22:32:03 +0000
committerChristian Grothoff <christian@grothoff.org>2012-08-14 22:32:03 +0000
commitb7382eee137f67f959da59912d5d9b9e5587e834 (patch)
tree529c76bb6a9baa4c027ea134c9f2ea18388f80e3
parentdc0861ada7e0bdd8754b86bcb0dc533ca1df02d2 (diff)
downloadlibextractor-b7382eee137f67f959da59912d5d9b9e5587e834.tar.gz
libextractor-b7382eee137f67f959da59912d5d9b9e5587e834.zip
nsfe testcase and nsfe fixes
-rw-r--r--src/plugins/Makefile.am9
-rw-r--r--src/plugins/nsfe_extractor.c4
-rw-r--r--src/plugins/test_nsfe.c133
-rw-r--r--src/plugins/testdata/nsfe_classics.nsfebin0 -> 8406 bytes
4 files changed, 143 insertions, 3 deletions
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 4669a11..281035c 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -33,7 +33,8 @@ EXTRA_DIST = template_extractor.c \
33 testdata/png_image.png \ 33 testdata/png_image.png \
34 testdata/odf_cg.odt \ 34 testdata/odf_cg.odt \
35 testdata/deb_bzip2.deb \ 35 testdata/deb_bzip2.deb \
36 testdata/nsf_arkanoid.nsf 36 testdata/nsf_arkanoid.nsf \
37 testdata/nsfe_classics.nsfe
37 38
38if HAVE_VORBISFILE 39if HAVE_VORBISFILE
39PLUGIN_OGG=libextractor_ogg.la 40PLUGIN_OGG=libextractor_ogg.la
@@ -119,6 +120,7 @@ check_PROGRAMS = \
119 test_odf \ 120 test_odf \
120 test_zip \ 121 test_zip \
121 test_nsf \ 122 test_nsf \
123 test_nsfe \
122 $(TEST_ZLIB) \ 124 $(TEST_ZLIB) \
123 $(TEST_OGG) \ 125 $(TEST_OGG) \
124 $(TEST_MIME) \ 126 $(TEST_MIME) \
@@ -177,6 +179,11 @@ libextractor_nsfe_la_SOURCES = \
177libextractor_nsfe_la_LDFLAGS = \ 179libextractor_nsfe_la_LDFLAGS = \
178 $(PLUGINFLAGS) 180 $(PLUGINFLAGS)
179 181
182test_nsfe_SOURCES = \
183 test_nsfe.c
184test_nsfe_LDADD = \
185 $(top_builddir)/src/plugins/libtest.la
186
180 187
181libextractor_odf_la_SOURCES = \ 188libextractor_odf_la_SOURCES = \
182 odf_extractor.c 189 odf_extractor.c
diff --git a/src/plugins/nsfe_extractor.c b/src/plugins/nsfe_extractor.c
index 16c4980..aa6fb0a 100644
--- a/src/plugins/nsfe_extractor.c
+++ b/src/plugins/nsfe_extractor.c
@@ -371,10 +371,10 @@ EXTRACTOR_nsfe_extract_method (struct EXTRACTOR_ExtractContext *ec)
371 if (8 > 371 if (8 >
372 ec->read (ec->cls, 372 ec->read (ec->cls,
373 &data, 373 &data,
374 sizeof (struct header))) 374 8))
375 break; 375 break;
376 chunksize = nsfeuint (data); 376 chunksize = nsfeuint (data);
377 off += 4 + chunksize; 377 off += 8 + chunksize;
378 if (0 == memcmp (data + 4, "INFO", 4)) 378 if (0 == memcmp (data + 4, "INFO", 4))
379 ret = info_extract (ec, chunksize); 379 ret = info_extract (ec, chunksize);
380 else if (0 == memcmp (data + 4, "auth", 4)) 380 else if (0 == memcmp (data + 4, "auth", 4))
diff --git a/src/plugins/test_nsfe.c b/src/plugins/test_nsfe.c
new file mode 100644
index 0000000..7e4e5cd
--- /dev/null
+++ b/src/plugins/test_nsfe.c
@@ -0,0 +1,133 @@
1/*
2 This file is part of libextractor.
3 (C) 2012 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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20/**
21 * @file plugins/test_nsfe.c
22 * @brief testcase for nsfe plugin
23 * @author Christian Grothoff
24 */
25#include "platform.h"
26#include "test_lib.h"
27
28
29
30/**
31 * Main function for the NSFE testcase.
32 *
33 * @param argc number of arguments (ignored)
34 * @param argv arguments (ignored)
35 * @return 0 on success
36 */
37int
38main (int argc, char *argv[])
39{
40 struct SolutionData nsfe_classics_sol[] =
41 {
42 {
43 EXTRACTOR_METATYPE_MIMETYPE,
44 EXTRACTOR_METAFORMAT_UTF8,
45 "text/plain",
46 "audio/x-nsfe",
47 strlen ("audio/x-nsfe") + 1,
48 0
49 },
50 {
51 EXTRACTOR_METATYPE_SONG_COUNT,
52 EXTRACTOR_METAFORMAT_UTF8,
53 "text/plain",
54 "2",
55 strlen ("2") + 1,
56 0
57 },
58 {
59 EXTRACTOR_METATYPE_STARTING_SONG,
60 EXTRACTOR_METAFORMAT_UTF8,
61 "text/plain",
62 "0",
63 strlen ("0") + 1,
64 0
65 },
66 {
67 EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM,
68 EXTRACTOR_METAFORMAT_UTF8,
69 "text/plain",
70 "PAL",
71 strlen ("PAL") + 1,
72 0
73 },
74 {
75 EXTRACTOR_METATYPE_ALBUM,
76 EXTRACTOR_METAFORMAT_UTF8,
77 "text/plain",
78 "Adventures of Dr. Franken,The",
79 strlen ("Adventures of Dr. Franken,The") + 1,
80 0
81 },
82 {
83 EXTRACTOR_METATYPE_ARTIST,
84 EXTRACTOR_METAFORMAT_UTF8,
85 "text/plain",
86 "Mark Cooksey",
87 strlen ("Mark Cooksey") + 1,
88 0
89 },
90 {
91 EXTRACTOR_METATYPE_COPYRIGHT,
92 EXTRACTOR_METAFORMAT_UTF8,
93 "text/plain",
94 "1993 Motivetime LTD.",
95 strlen ("1993 Motivetime LTD.") + 1,
96 0
97 },
98 {
99 EXTRACTOR_METATYPE_RIPPER,
100 EXTRACTOR_METAFORMAT_UTF8,
101 "text/plain",
102 "Gil_Galad",
103 strlen ("Gil_Galad") + 1,
104 0
105 },
106 {
107 EXTRACTOR_METATYPE_TITLE,
108 EXTRACTOR_METAFORMAT_UTF8,
109 "text/plain",
110 "Bach: Prelude & Fugue In C Minor",
111 strlen ("Bach: Prelude & Fugue In C Minor") + 1,
112 0
113 },
114 {
115 EXTRACTOR_METATYPE_TITLE,
116 EXTRACTOR_METAFORMAT_UTF8,
117 "text/plain",
118 "Beethoven: Moonlight Sonata",
119 strlen ("Beethoven: Moonlight Sonata") + 1,
120 0
121 },
122 { 0, 0, NULL, NULL, 0, -1 }
123 };
124 struct ProblemSet ps[] =
125 {
126 { "testdata/nsfe_classics.nsfe",
127 nsfe_classics_sol },
128 { NULL, NULL }
129 };
130 return ET_main ("nsfe", ps);
131}
132
133/* end of test_nsfe.c */
diff --git a/src/plugins/testdata/nsfe_classics.nsfe b/src/plugins/testdata/nsfe_classics.nsfe
new file mode 100644
index 0000000..898e63f
--- /dev/null
+++ b/src/plugins/testdata/nsfe_classics.nsfe
Binary files differ