|
16 | 16 |
|
17 | 17 | #include "mp4parse.h"
|
18 | 18 |
|
19 |
| -intptr_t abort_read(uint8_t *buffer, uintptr_t size, void *userdata) |
| 19 | +intptr_t abort_read(uint8_t *, uintptr_t, void *) |
20 | 20 | {
|
21 | 21 | // This shouldn't be called when allocating a parser.
|
22 | 22 | abort();
|
23 | 23 | }
|
24 | 24 |
|
25 |
| -intptr_t error_read(uint8_t *buffer, uintptr_t size, void *userdata) |
| 25 | +intptr_t error_read(uint8_t *, uintptr_t, void *) |
26 | 26 | {
|
27 | 27 | return -1;
|
28 | 28 | }
|
@@ -108,9 +108,9 @@ void test_arg_validation_with_parser()
|
108 | 108 | assert(dummy_value == 42);
|
109 | 109 | }
|
110 | 110 |
|
111 |
| -void test_arg_validation_with_data(const std::string& filename) |
| 111 | +void test_arg_validation_with_data(const char* filename) |
112 | 112 | {
|
113 |
| - FILE* f = fopen(filename.c_str(), "rb"); |
| 113 | + FILE* f = fopen(filename, "rb"); |
114 | 114 | assert(f != nullptr);
|
115 | 115 | Mp4parseIo io = { io_read, f };
|
116 | 116 | Mp4parseParser *parser = mp4parse_new(&io);
|
@@ -229,24 +229,21 @@ int32_t read_file(const char* filename)
|
229 | 229 | return MP4PARSE_STATUS_OK;
|
230 | 230 | }
|
231 | 231 |
|
232 |
| -int main(int argc, char* argv[]) |
| 232 | +extern "C" |
| 233 | +int test_main(const char* test_path) |
233 | 234 | {
|
234 |
| - // Parse command line options. |
235 |
| - std::vector<std::string> args(argv + 1, argv + argc); |
236 |
| - |
237 | 235 | test_new_parser();
|
238 | 236 | test_arg_validation();
|
239 | 237 | test_arg_validation_with_parser();
|
| 238 | + test_arg_validation_with_data(test_path); |
| 239 | + return 0; |
| 240 | +} |
240 | 241 |
|
241 |
| - // Find our test file relative to our executable file path. |
242 |
| - char* real = realpath(argv[0], NULL); |
243 |
| - std::string path(real); |
244 |
| - free(real); |
245 |
| - auto split = path.rfind('/'); |
246 |
| - path.replace(split, path.length() - split, "/../../mp4parse/tests/minimal.mp4"); |
247 |
| - test_arg_validation_with_data(path); |
| 242 | +extern "C" |
| 243 | +int run_main(int argc, char* argv[]) |
| 244 | +{ |
| 245 | + std::vector<std::string> args(argv + 1, argv + argc); |
248 | 246 |
|
249 |
| - // Run any other test files passed on the command line. |
250 | 247 | for (auto arg: args) {
|
251 | 248 | read_file(arg.c_str());
|
252 | 249 | }
|
|
0 commit comments