summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLRN <lrn1986@gmail.com>2015-04-20 09:49:45 +0000
committerLRN <lrn1986@gmail.com>2015-04-20 09:49:45 +0000
commit4d543bd37dbb28ed956ce490f77c39f14ef9be43 (patch)
tree31f9bffca159bdb6110fbb295fe72789bc723d3e
parent83454890939e53e7f239cb27ce65951ddf98f3eb (diff)
downloadlibextractor-4d543bd37dbb28ed956ce490f77c39f14ef9be43.tar.gz
libextractor-4d543bd37dbb28ed956ce490f77c39f14ef9be43.zip
Adapt mime test to work with different libmagic versions
-rw-r--r--src/plugins/test_mime.c50
1 files changed, 45 insertions, 5 deletions
diff --git a/src/plugins/test_mime.c b/src/plugins/test_mime.c
index 67cf1aa..e0a3939 100644
--- a/src/plugins/test_mime.c
+++ b/src/plugins/test_mime.c
@@ -37,7 +37,10 @@
37int 37int
38main (int argc, char *argv[]) 38main (int argc, char *argv[])
39{ 39{
40 struct SolutionData courseclear_sol[] = 40 int result = 0;
41 int test_result;
42 int test_result_around_19, test_result_around_22;
43 struct SolutionData courseclear_file_around_19_sol[] =
41 { 44 {
42 { 45 {
43 EXTRACTOR_METATYPE_MIMETYPE, 46 EXTRACTOR_METATYPE_MIMETYPE,
@@ -59,6 +62,18 @@ main (int argc, char *argv[])
59 }, 62 },
60 { 0, 0, NULL, NULL, 0, -1 } 63 { 0, 0, NULL, NULL, 0, -1 }
61 }; 64 };
65 struct SolutionData courseclear_file_around_22_sol[] =
66 {
67 {
68 EXTRACTOR_METATYPE_MIMETYPE,
69 EXTRACTOR_METAFORMAT_UTF8,
70 "text/plain",
71 "audio/ogg",
72 strlen ("audio/ogg") + 1,
73 0
74 },
75 { 0, 0, NULL, NULL, 0, -1 }
76 };
62 struct SolutionData gif_image_sol[] = 77 struct SolutionData gif_image_sol[] =
63 { 78 {
64 { 79 {
@@ -71,15 +86,40 @@ main (int argc, char *argv[])
71 }, 86 },
72 { 0, 0, NULL, NULL, 0, -1 } 87 { 0, 0, NULL, NULL, 0, -1 }
73 }; 88 };
74 struct ProblemSet ps[] = 89 struct ProblemSet ps_gif[] =
75 { 90 {
76 { "testdata/ogg_courseclear.ogg",
77 courseclear_sol },
78 { "testdata/gif_image.gif", 91 { "testdata/gif_image.gif",
79 gif_image_sol }, 92 gif_image_sol },
80 { NULL, NULL } 93 { NULL, NULL }
81 }; 94 };
82 return ET_main ("mime", ps); 95 struct ProblemSet ps_ogg_around_19[] =
96 {
97 { "testdata/ogg_courseclear.ogg",
98 courseclear_file_around_19_sol },
99 { NULL, NULL }
100 };
101 struct ProblemSet ps_ogg_around_22[] =
102 {
103 { "testdata/ogg_courseclear.ogg",
104 courseclear_file_around_22_sol },
105 { NULL, NULL }
106 };
107 printf ("Running gif test on libmagic:\n");
108 test_result = (0 == ET_main ("mime", ps_gif) ? 0 : 1);
109 printf ("gif libmagic test result: %s\n", test_result == 0 ? "OK" : "FAILED");
110 result += test_result;
111
112 printf ("Running ogg test on libmagic, assuming version ~5.19:\n");
113 test_result_around_19 = (0 == ET_main ("mime", ps_ogg_around_19) ? 0 : 1);
114 printf ("ogg libmagic test result: %s\n", test_result_around_19 == 0 ? "OK" : "FAILED");
115
116 printf ("Running ogg test on libmagic, assuming version ~5.22:\n");
117 test_result_around_22 = (0 == ET_main ("mime", ps_ogg_around_22) ? 0 : 1);
118 printf ("ogg libmagic test result: %s\n", test_result_around_22 == 0 ? "OK" : "FAILED");
119
120 if ((test_result_around_19 != 0) && (test_result_around_22 != 0))
121 result++;
122 return result;
83} 123}
84 124
85/* end of test_mime.c */ 125/* end of test_mime.c */