diff options
Diffstat (limited to 'src/main/test_extractor.c')
-rw-r--r-- | src/main/test_extractor.c | 146 |
1 files changed, 73 insertions, 73 deletions
diff --git a/src/main/test_extractor.c b/src/main/test_extractor.c index 8c15fca..dd1376f 100644 --- a/src/main/test_extractor.c +++ b/src/main/test_extractor.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <stdlib.h> | 37 | #include <stdlib.h> |
38 | 38 | ||
39 | 39 | ||
40 | |||
41 | /** | 40 | /** |
42 | * Signature of the extract method that each plugin | 41 | * Signature of the extract method that each plugin |
43 | * must provide. | 42 | * must provide. |
@@ -52,94 +51,95 @@ EXTRACTOR_test_extract_method (struct EXTRACTOR_ExtractContext *ec) | |||
52 | if ((NULL == ec->config) || (0 != strcmp (ec->config, "test"))) | 51 | if ((NULL == ec->config) || (0 != strcmp (ec->config, "test"))) |
53 | return; /* only run in test mode */ | 52 | return; /* only run in test mode */ |
54 | if (4 != ec->read (ec->cls, &dp, 4)) | 53 | if (4 != ec->read (ec->cls, &dp, 4)) |
55 | { | 54 | { |
56 | fprintf (stderr, "Reading at offset 0 failed\n"); | 55 | fprintf (stderr, "Reading at offset 0 failed\n"); |
57 | ABORT (); | 56 | ABORT (); |
58 | } | 57 | } |
59 | if (0 != strncmp ("test", dp, 4)) | 58 | if (0 != strncmp ("test", dp, 4)) |
60 | { | 59 | { |
61 | fprintf (stderr, "Unexpected data at offset 0\n"); | 60 | fprintf (stderr, "Unexpected data at offset 0\n"); |
62 | ABORT (); | 61 | ABORT (); |
63 | } | 62 | } |
64 | if ( (1024 * 150 != ec->get_size (ec->cls)) && | 63 | if ( (1024 * 150 != ec->get_size (ec->cls)) && |
65 | (UINT64_MAX != ec->get_size (ec->cls)) ) | 64 | (UINT64_MAX != ec->get_size (ec->cls)) ) |
66 | { | 65 | { |
67 | fprintf (stderr, "Unexpected file size returned (expected 150k)\n"); | 66 | fprintf (stderr, "Unexpected file size returned (expected 150k)\n"); |
68 | ABORT (); | 67 | ABORT (); |
69 | } | 68 | } |
70 | if (1024 * 100 + 4 != ec->seek (ec->cls, 1024 * 100 + 4, SEEK_SET)) | 69 | if (1024 * 100 + 4 != ec->seek (ec->cls, 1024 * 100 + 4, SEEK_SET)) |
71 | { | 70 | { |
72 | fprintf (stderr, "Failure to seek (SEEK_SET)\n"); | 71 | fprintf (stderr, "Failure to seek (SEEK_SET)\n"); |
73 | ABORT (); | 72 | ABORT (); |
74 | } | 73 | } |
75 | if (1 != ec->read (ec->cls, &dp, 1)) | 74 | if (1 != ec->read (ec->cls, &dp, 1)) |
76 | { | 75 | { |
77 | fprintf (stderr, "Failure to read at 100k + 4\n"); | 76 | fprintf (stderr, "Failure to read at 100k + 4\n"); |
78 | ABORT (); | 77 | ABORT (); |
79 | } | 78 | } |
80 | if ((1024 * 100 + 4) % 256 != * (unsigned char *) dp) | 79 | if ((1024 * 100 + 4) % 256 != *(unsigned char *) dp) |
81 | { | 80 | { |
82 | fprintf (stderr, "Unexpected data at offset 100k + 4\n"); | 81 | fprintf (stderr, "Unexpected data at offset 100k + 4\n"); |
83 | ABORT (); | 82 | ABORT (); |
84 | } | 83 | } |
85 | if (((1024 * 100 + 4) + 1 - (1024 * 50 + 7)) != | 84 | if (((1024 * 100 + 4) + 1 - (1024 * 50 + 7)) != |
86 | ec->seek (ec->cls, - (1024 * 50 + 7), SEEK_CUR)) | 85 | ec->seek (ec->cls, -(1024 * 50 + 7), SEEK_CUR)) |
87 | { | 86 | { |
88 | fprintf (stderr, "Failure to seek (SEEK_SET)\n"); | 87 | fprintf (stderr, "Failure to seek (SEEK_SET)\n"); |
89 | ABORT (); | 88 | ABORT (); |
90 | } | 89 | } |
91 | if (1 != ec->read (ec->cls, &dp, 1)) | 90 | if (1 != ec->read (ec->cls, &dp, 1)) |
92 | { | 91 | { |
93 | fprintf (stderr, "Failure to read at 50k - 3\n"); | 92 | fprintf (stderr, "Failure to read at 50k - 3\n"); |
94 | ABORT (); | 93 | ABORT (); |
95 | } | 94 | } |
96 | if (((1024 * 100 + 4) + 1 - (1024 * 50 + 7)) % 256 != * (unsigned char *) dp) | 95 | if (((1024 * 100 + 4) + 1 - (1024 * 50 + 7)) % 256 != *(unsigned char *) dp) |
97 | { | 96 | { |
98 | fprintf (stderr, "Unexpected data at offset 100k - 3\n"); | 97 | fprintf (stderr, "Unexpected data at offset 100k - 3\n"); |
99 | ABORT (); | 98 | ABORT (); |
100 | } | 99 | } |
101 | if (1024 * 150 != ec->seek (ec->cls, 0, SEEK_END)) | 100 | if (1024 * 150 != ec->seek (ec->cls, 0, SEEK_END)) |
102 | { | 101 | { |
103 | fprintf (stderr, "Failure to seek (SEEK_END)\n"); | 102 | fprintf (stderr, "Failure to seek (SEEK_END)\n"); |
104 | ABORT (); | 103 | ABORT (); |
105 | } | 104 | } |
106 | if (0 != ec->read (ec->cls, &dp, 1)) | 105 | if (0 != ec->read (ec->cls, &dp, 1)) |
107 | { | 106 | { |
108 | fprintf (stderr, "Failed to receive EOF at 150k\n"); | 107 | fprintf (stderr, "Failed to receive EOF at 150k\n"); |
109 | ABORT (); | 108 | ABORT (); |
110 | } | 109 | } |
111 | if (1024 * 150 - 2 != ec->seek (ec->cls, -2, SEEK_END)) | 110 | if (1024 * 150 - 2 != ec->seek (ec->cls, -2, SEEK_END)) |
112 | { | 111 | { |
113 | fprintf (stderr, "Failure to seek (SEEK_END - 2)\n"); | 112 | fprintf (stderr, "Failure to seek (SEEK_END - 2)\n"); |
114 | ABORT (); | 113 | ABORT (); |
115 | } | 114 | } |
116 | if (1 != ec->read (ec->cls, &dp, 1)) | 115 | if (1 != ec->read (ec->cls, &dp, 1)) |
117 | { | 116 | { |
118 | fprintf (stderr, "Failure to read at 150k - 3\n"); | 117 | fprintf (stderr, "Failure to read at 150k - 3\n"); |
119 | ABORT (); | 118 | ABORT (); |
120 | } | 119 | } |
121 | if ((1024 * 150 - 2) % 256 != * (unsigned char *) dp) | 120 | if ((1024 * 150 - 2) % 256 != *(unsigned char *) dp) |
122 | { | 121 | { |
123 | fprintf (stderr, "Unexpected data at offset 150k - 3\n"); | 122 | fprintf (stderr, "Unexpected data at offset 150k - 3\n"); |
124 | ABORT (); | 123 | ABORT (); |
125 | } | 124 | } |
126 | if (0 != ec->proc (ec->cls, "test", EXTRACTOR_METATYPE_COMMENT, | 125 | if (0 != ec->proc (ec->cls, "test", EXTRACTOR_METATYPE_COMMENT, |
127 | EXTRACTOR_METAFORMAT_UTF8, "<no mime>", "Hello world!", | 126 | EXTRACTOR_METAFORMAT_UTF8, "<no mime>", "Hello world!", |
128 | strlen ("Hello world!") + 1)) | 127 | strlen ("Hello world!") + 1)) |
129 | { | 128 | { |
130 | fprintf (stderr, "Unexpected return value from 'proc'\n"); | 129 | fprintf (stderr, "Unexpected return value from 'proc'\n"); |
131 | ABORT (); | 130 | ABORT (); |
132 | } | 131 | } |
133 | /* The test assumes that client orders us to stop extraction | 132 | /* The test assumes that client orders us to stop extraction |
134 | * after seeing "Goodbye!". | 133 | * after seeing "Goodbye!". |
135 | */ | 134 | */ |
136 | if (1 != ec->proc (ec->cls, "test", EXTRACTOR_METATYPE_COMMENT, | 135 | if (1 != ec->proc (ec->cls, "test", EXTRACTOR_METATYPE_COMMENT, |
137 | EXTRACTOR_METAFORMAT_UTF8, "<no mime>", "Goodbye!", | 136 | EXTRACTOR_METAFORMAT_UTF8, "<no mime>", "Goodbye!", |
138 | strlen ("Goodbye!") + 1)) | 137 | strlen ("Goodbye!") + 1)) |
139 | { | 138 | { |
140 | fprintf (stderr, "Unexpected return value from 'proc'\n"); | 139 | fprintf (stderr, "Unexpected return value from 'proc'\n"); |
141 | ABORT (); | 140 | ABORT (); |
142 | } | 141 | } |
143 | } | 142 | } |
144 | 143 | ||
144 | |||
145 | /* end of test_extractor.c */ | 145 | /* end of test_extractor.c */ |