Unified · Split
| @@ -257,7 +257,7 @@ const char *cpl_doc = · 256 unmodified lines | |||
| 257 | "</SegmentList>" | 257 | "</SegmentList>" |
| 258 | "</CompositionPlaylist>"; | 258 | "</CompositionPlaylist>"; |
| 259 | 259 | ||
| 260 | const char *cpl_bad_doc = "<Composition></Composition>"; | 260 | const char *cpl_bad_empty_doc = "<Composition></Composition>"; |
| 261 | 261 | ||
| 262 | const char *asset_map_doc = | 262 | const char *asset_map_doc = |
| 263 | "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" | 263 | "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" |
| @@ -384,52 +384,31 @@ static int test_cpl_parsing(void) · 120 unmodified lines | |||
| 384 | return 0; | 384 | return 0; |
| 385 | } | 385 | } |
| 386 | 386 | ||
| 387 | static int test_bad_cpl_parsing(FFIMFCPL **cpl) | 387 | static int test_cpl_from_doc(FFIMFCPL **cpl, const char* cpl_doc, int should_pass) { |
| 388 | { | ||
| 389 | xmlDocPtr doc; | ||
| 390 | int ret; | ||
| 391 | |||
| 392 | doc = xmlReadMemory(cpl_bad_doc, strlen(cpl_bad_doc), NULL, NULL, 0); | ||
| 393 | if (doc == NULL) { | ||
| 394 | printf("XML parsing failed.\n"); | ||
| 395 | return 1; | ||
| 396 | } | ||
| 397 | |||
| 398 | ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl); | ||
| 399 | xmlFreeDoc(doc); | ||
| 400 | if (ret) { | ||
| 401 | printf("CPL parsing failed.\n"); | ||
| 402 | return ret; | ||
| 403 | } | ||
| 404 | |||
| 405 | ff_imf_cpl_free(*cpl); | ||
| 406 | *cpl = NULL; | ||
| 407 | |||
| 408 | return 0; | ||
| 409 | } | ||
| 410 | |||
| 411 | static int test_bad_resource_cpl_parsing(FFIMFCPL **cpl) | ||
| 412 | { | ||
| 413 | xmlDocPtr doc; | 388 | xmlDocPtr doc; |
| 414 | int ret; | 389 | int ret; |
| 415 | 390 | ||
| 416 | doc = xmlReadMemory(cpl_bad_resource_doc, strlen(cpl_bad_resource_doc), NULL, NULL, 0); | 391 | doc = xmlReadMemory(cpl_doc, strlen(cpl_doc), NULL, NULL, 0); |
| 417 | if (doc == NULL) { | 392 | if (doc == NULL) { |
| 418 | printf("XML parsing failed.\n"); | 393 | printf("XML parsing failed.\n"); |
| 419 | return 1; | 394 | return should_pass; |
| 420 | } | 395 | } |
| 421 | 396 | ||
| 422 | ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl); | 397 | ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl); |
| 423 | xmlFreeDoc(doc); | 398 | xmlFreeDoc(doc); |
| 424 | if (ret) { | 399 | if (ret) { |
| 425 | printf("CPL parsing failed.\n"); | 400 | printf("CPL parsing failed.\n"); |
| 426 | return ret; | 401 | if (*cpl) { |
| 402 | printf("Improper cleanup after failed CPL parsing\n"); | ||
| 403 | return 1; | ||
| 404 | } | ||
| 405 | return should_pass; | ||
| 427 | } | 406 | } |
| 428 | 407 | ||
| 429 | ff_imf_cpl_free(*cpl); | 408 | ff_imf_cpl_free(*cpl); |
| 430 | *cpl = NULL; | 409 | *cpl = NULL; |
| 431 | 410 | ||
| 432 | return 0; | 411 | return !should_pass; |
| 433 | } | 412 | } |
| 434 | 413 | ||
| 435 | static int check_asset_locator_attributes(IMFAssetLocator *asset, IMFAssetLocator *expected_asset) | 414 | static int check_asset_locator_attributes(IMFAssetLocator *asset, IMFAssetLocator *expected_asset) |
| @@ -591,20 +570,13 @@ int main(int argc, char *argv[]) · 155 unmodified lines | |||
| 591 | ret = 1; | 570 | ret = 1; |
| 592 | 571 | ||
| 593 | printf("#### The following should fail ####\n"); | 572 | printf("#### The following should fail ####\n"); |
| 594 | if (test_bad_cpl_parsing(&cpl) == 0) { | 573 | if (test_cpl_from_doc(&cpl, cpl_bad_empty_doc, 0) != 0) |
| 595 | ret = 1; | 574 | ret = 1; |
| 596 | } else if (cpl) { | ||
| 597 | printf("Improper cleanup after failed CPL parsing\n"); | ||
| 598 | ret = 1; | ||
| 599 | } | ||
| 600 | printf("#### End failing test ####\n"); | 575 | printf("#### End failing test ####\n"); |
| 601 | 576 | ||
| 602 | printf("#### The following should emit errors ####\n"); | 577 | printf("#### The following should emit errors ####\n"); |
| 603 | if (test_bad_resource_cpl_parsing(&cpl) != 0) { | 578 | if (test_cpl_from_doc(&cpl, cpl_bad_resource_doc, 1) != 0) |
| 604 | if (cpl) | ||
| 605 | printf("Improper cleanup after failed CPL parsing\n"); | ||
| 606 | ret = 1; | 579 | ret = 1; |
| 607 | } | ||
| 608 | printf("#### End emission of errors ####\n"); | 580 | printf("#### End emission of errors ####\n"); |
| 609 | 581 | ||
| 610 | return ret; | 582 | return ret; |