Unified · Split
| @@ -257,7 +257,7 @@ const char *cpl_doc = · 256 unmodified lines | ||
| 257 | 257 | "</SegmentList>" |
| 258 | 258 | "</CompositionPlaylist>"; |
| 259 | 259 | |
| 260 | −const char *cpl_bad_doc = "<Composition></Composition>"; | |
| 260 | +const char *cpl_bad_empty_doc = "<Composition></Composition>"; | |
| 261 | 261 | |
| 262 | 262 | const char *asset_map_doc = |
| 263 | 263 | "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" |
| @@ -384,52 +384,31 @@ static int test_cpl_parsing(void) · 120 unmodified lines | ||
| 384 | 384 | return 0; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | −static int test_bad_cpl_parsing(FFIMFCPL **cpl) | |
| 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 | −{ | |
| 387 | +static int test_cpl_from_doc(FFIMFCPL **cpl, const char* cpl_doc, int should_pass) { | |
| 413 | 388 | xmlDocPtr doc; |
| 414 | 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 | 392 | if (doc == NULL) { |
| 418 | 393 | printf("XML parsing failed.\n"); |
| 419 | − return 1; | |
| 394 | + return should_pass; | |
| 420 | 395 | } |
| 421 | 396 | |
| 422 | 397 | ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl); |
| 423 | 398 | xmlFreeDoc(doc); |
| 424 | 399 | if (ret) { |
| 425 | 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 | 408 | ff_imf_cpl_free(*cpl); |
| 430 | 409 | *cpl = NULL; |
| 431 | 410 | |
| 432 | − return 0; | |
| 411 | + return !should_pass; | |
| 433 | 412 | } |
| 434 | 413 | |
| 435 | 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 | 570 | ret = 1; |
| 592 | 571 | |
| 593 | 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 | 574 | ret = 1; |
| 596 | − } else if (cpl) { | |
| 597 | − printf("Improper cleanup after failed CPL parsing\n"); | |
| 598 | − ret = 1; | |
| 599 | − } | |
| 600 | 575 | printf("#### End failing test ####\n"); |
| 601 | 576 | |
| 602 | 577 | printf("#### The following should emit errors ####\n"); |
| 603 | − if (test_bad_resource_cpl_parsing(&cpl) != 0) { | |
| 604 | − if (cpl) | |
| 605 | − printf("Improper cleanup after failed CPL parsing\n"); | |
| 578 | + if (test_cpl_from_doc(&cpl, cpl_bad_resource_doc, 1) != 0) | |
| 606 | 579 | ret = 1; |
| 607 | − } | |
| 608 | 580 | printf("#### End emission of errors ####\n"); |
| 609 | 581 | |
| 610 | 582 | return ret; |