|
16 | 16 |
|
17 | 17 | #include "mp4parse.h"
|
18 | 18 |
|
19 |
| -intptr_t error_read(uint8_t *buffer, uintptr_t size, void *userdata) |
| 19 | +intptr_t error_read(uint8_t *, uintptr_t, void *) |
20 | 20 | {
|
21 | 21 | return -1;
|
22 | 22 | }
|
@@ -91,9 +91,9 @@ void test_arg_validation_with_parser()
|
91 | 91 | assert(dummy_value == 42);
|
92 | 92 | }
|
93 | 93 |
|
94 |
| -void test_arg_validation_with_data(const std::string& filename) |
| 94 | +void test_arg_validation_with_data(const char* filename) |
95 | 95 | {
|
96 |
| - FILE* f = fopen(filename.c_str(), "rb"); |
| 96 | + FILE* f = fopen(filename, "rb"); |
97 | 97 | assert(f != nullptr);
|
98 | 98 | Mp4parseIo io = { io_read, f };
|
99 | 99 | Mp4parseParser *parser = nullptr;
|
@@ -210,23 +210,20 @@ int32_t read_file(const char* filename)
|
210 | 210 | return MP4PARSE_STATUS_OK;
|
211 | 211 | }
|
212 | 212 |
|
213 |
| -int main(int argc, char* argv[]) |
| 213 | +extern "C" |
| 214 | +int test_main(const char* test_path) |
214 | 215 | {
|
215 |
| - // Parse command line options. |
216 |
| - std::vector<std::string> args(argv + 1, argv + argc); |
217 |
| - |
218 | 216 | test_arg_validation();
|
219 | 217 | test_arg_validation_with_parser();
|
| 218 | + test_arg_validation_with_data(test_path); |
| 219 | + return 0; |
| 220 | +} |
220 | 221 |
|
221 |
| - // Find our test file relative to our executable file path. |
222 |
| - char* real = realpath(argv[0], NULL); |
223 |
| - std::string path(real); |
224 |
| - free(real); |
225 |
| - auto split = path.rfind('/'); |
226 |
| - path.replace(split, path.length() - split, "/../../mp4parse/tests/minimal.mp4"); |
227 |
| - test_arg_validation_with_data(path); |
| 222 | +extern "C" |
| 223 | +int run_main(int argc, char* argv[]) |
| 224 | +{ |
| 225 | + std::vector<std::string> args(argv + 1, argv + argc); |
228 | 226 |
|
229 |
| - // Run any other test files passed on the command line. |
230 | 227 | for (auto arg: args) {
|
231 | 228 | read_file(arg.c_str());
|
232 | 229 | }
|
|
0 commit comments