diff --git a/packager/media/base/container_names_unittest.cc b/packager/media/base/container_names_unittest.cc index 9dd5ecdcbe..517d0b85f9 100644 --- a/packager/media/base/container_names_unittest.cc +++ b/packager/media/base/container_names_unittest.cc @@ -146,6 +146,7 @@ TEST(ContainerNamesTest, CheckFixedStrings) { void TestFile(MediaContainerName expected, const std::string& name) { std::filesystem::path path = GetTestDataFilePath(name); std::vector data = ReadTestDataFile(name); + ASSERT_FALSE(data.empty()); // Now verify the type. EXPECT_EQ(expected, DetermineContainer(data.data(), data.size())) diff --git a/packager/media/codecs/av1_parser_unittest.cc b/packager/media/codecs/av1_parser_unittest.cc index 4e8df86a45..4188ecd019 100644 --- a/packager/media/codecs/av1_parser_unittest.cc +++ b/packager/media/codecs/av1_parser_unittest.cc @@ -23,6 +23,7 @@ inline bool operator==(const AV1Parser::Tile& lhs, const AV1Parser::Tile& rhs) { TEST(AV1ParserTest, ParseIFrameSuccess) { const std::vector buffer = ReadTestDataFile("av1-I-frame-320x240"); + ASSERT_FALSE(buffer.empty()); AV1Parser parser; std::vector tiles; diff --git a/packager/media/codecs/h264_parser_unittest.cc b/packager/media/codecs/h264_parser_unittest.cc index 7a5f650acf..cb8aecdd11 100644 --- a/packager/media/codecs/h264_parser_unittest.cc +++ b/packager/media/codecs/h264_parser_unittest.cc @@ -46,6 +46,7 @@ const uint8_t kPps2[] = { TEST(H264ParserTest, StreamFileParsing) { std::vector buffer = ReadTestDataFile("test-25fps.h264"); + ASSERT_FALSE(buffer.empty()); // Number of NALUs in the test stream to be parsed. int num_nalus = 759; diff --git a/packager/media/formats/mp2t/es_parser_h264_unittest.cc b/packager/media/formats/mp2t/es_parser_h264_unittest.cc index 19273311b3..e4e39b9bff 100644 --- a/packager/media/formats/mp2t/es_parser_h264_unittest.cc +++ b/packager/media/formats/mp2t/es_parser_h264_unittest.cc @@ -153,6 +153,7 @@ class EsParserH264Test : public testing::Test { void EsParserH264Test::LoadStream(const char* filename) { std::vector buffer = ReadTestDataFile(filename); + ASSERT_FALSE(buffer.empty()); // The input file does not have AUDs. std::vector access_units_without_aud = diff --git a/packager/media/formats/mp2t/mp2t_media_parser_unittest.cc b/packager/media/formats/mp2t/mp2t_media_parser_unittest.cc index 011be293c6..18e13debb0 100644 --- a/packager/media/formats/mp2t/mp2t_media_parser_unittest.cc +++ b/packager/media/formats/mp2t/mp2t_media_parser_unittest.cc @@ -122,6 +122,7 @@ class Mp2tMediaParserTest : public testing::Test { InitializeParser(); std::vector buffer = ReadTestDataFile(filename); + ASSERT_FALSE(buffer.empty()); EXPECT_TRUE(AppendDataInPieces(buffer.data(), buffer.size(), append_bytes)); diff --git a/packager/media/formats/mp4/mp4_media_parser_unittest.cc b/packager/media/formats/mp4/mp4_media_parser_unittest.cc index 8239499ef2..c73b66766a 100644 --- a/packager/media/formats/mp4/mp4_media_parser_unittest.cc +++ b/packager/media/formats/mp4/mp4_media_parser_unittest.cc @@ -103,9 +103,13 @@ class MP4MediaParserTest : public testing::Test { bool ParseMP4File(const std::string& filename, int append_bytes) { InitializeParser(NULL); + if (!parser_->LoadMoov(GetTestDataFilePath(filename).AsUTF8Unsafe())) return false; + std::vector buffer = ReadTestDataFile(filename); + ASSERT_FALSE(buffer.empty()); + return AppendDataInPieces(buffer.data(), buffer.size(), append_bytes); } }; @@ -206,6 +210,8 @@ TEST_F(MP4MediaParserTest, Flush) { InitializeParser(NULL); std::vector buffer = ReadTestDataFile("bear-640x360-av_frag.mp4"); + ASSERT_FALSE(buffer.empty()); + EXPECT_TRUE(AppendDataInPieces(buffer.data(), 65536, 512)); EXPECT_TRUE(parser_->Flush()); EXPECT_EQ(2u, num_streams_); @@ -226,6 +232,8 @@ TEST_F(MP4MediaParserTest, NoMoovAfterFlush) { InitializeParser(NULL); std::vector buffer = ReadTestDataFile("bear-640x360-av_frag.mp4"); + ASSERT_FALSE(buffer.empty()); + EXPECT_TRUE(AppendDataInPieces(buffer.data(), buffer.size(), 512)); EXPECT_TRUE(parser_->Flush()); @@ -255,6 +263,8 @@ TEST_F(MP4MediaParserTest, CencInitWithoutDecryptionSource) { std::vector buffer = ReadTestDataFile("bear-640x360-v_frag-cenc-aux.mp4"); + ASSERT_FALSE(buffer.empty()); + const int kFirstMoofOffset = 1646; EXPECT_TRUE(AppendDataInPieces(buffer.data(), kFirstMoofOffset, 512)); EXPECT_EQ(1u, num_streams_); @@ -274,6 +284,8 @@ TEST_F(MP4MediaParserTest, CencWithDecryptionSourceAndAuxInMdat) { std::vector buffer = ReadTestDataFile("bear-640x360-v_frag-cenc-aux.mp4"); + ASSERT_FALSE(buffer.empty()); + EXPECT_TRUE(AppendDataInPieces(buffer.data(), buffer.size(), 512)); EXPECT_EQ(1u, num_streams_); EXPECT_EQ(82u, num_samples_); @@ -293,6 +305,8 @@ TEST_F(MP4MediaParserTest, CencWithDecryptionSourceAndSenc) { std::vector buffer = ReadTestDataFile("bear-640x360-v_frag-cenc-senc.mp4"); + ASSERT_FALSE(buffer.empty()); + EXPECT_TRUE(AppendDataInPieces(buffer.data(), buffer.size(), 512)); EXPECT_EQ(1u, num_streams_); EXPECT_EQ(82u, num_samples_); diff --git a/packager/media/formats/wvm/wvm_media_parser_unittest.cc b/packager/media/formats/wvm/wvm_media_parser_unittest.cc index 4984bda34f..8eb66f3c24 100644 --- a/packager/media/formats/wvm/wvm_media_parser_unittest.cc +++ b/packager/media/formats/wvm/wvm_media_parser_unittest.cc @@ -154,6 +154,8 @@ class WvmMediaParserTest : public testing::Test { InitializeParser(); std::vector buffer = ReadTestDataFile(filename); + ASSERT_FALSE(buffer.empty()); + EXPECT_TRUE(parser_->Parse(buffer.data(), static_cast(buffer.size()))); } }; @@ -161,7 +163,10 @@ class WvmMediaParserTest : public testing::Test { TEST_F(WvmMediaParserTest, ParseWvmWithoutKeySource) { key_source_.reset(); InitializeParser(); + std::vector buffer = ReadTestDataFile(kWvmFile); + ASSERT_FALSE(buffer.empty()); + EXPECT_TRUE(parser_->Parse(buffer.data(), static_cast(buffer.size()))); EXPECT_EQ(kExpectedStreams, stream_map_.size()); EXPECT_EQ(kExpectedVideoFrameCount, video_frame_count_); @@ -184,7 +189,10 @@ TEST_F(WvmMediaParserTest, ParseWvmWithoutKeySource) { TEST_F(WvmMediaParserTest, ParseWvmInitWithoutKeySource) { key_source_.reset(); InitializeParser(); + std::vector buffer = ReadTestDataFile(kWvmFile); + ASSERT_FALSE(buffer.empty()); + EXPECT_TRUE(parser_->Parse(buffer.data(), kInitDataSize)); EXPECT_EQ(kExpectedStreams, stream_map_.size()); } diff --git a/packager/media/test/test_data_util.cc b/packager/media/test/test_data_util.cc index 6e44c645c9..c06e4d81fe 100644 --- a/packager/media/test/test_data_util.cc +++ b/packager/media/test/test_data_util.cc @@ -29,7 +29,7 @@ std::vector ReadTestDataFile(const std::string& name) { FILE* f = fopen(path.string().c_str(), "rb"); if (!f) { - LOG(FATAL) << "Failed to read test data from " << path; + LOG(ERROR) << "Failed to read test data from " << path; return std::vector(); }