Commit 9ce537e5 authored by Miguel Casas's avatar Miguel Casas Committed by Commit Bot

media/gpu/test: s/LOG_ASSERT/ASSERT_TRUE or ADD_FAILURE/

This CL continues substituting LOG_ASSERT()s with ASSERT_TRUE()s,
where the function has void(...) signature, or with ADD_FAILURE()
otherwise. This avoids crashing the test binary in Tast test runs.

Bug: 1020776
Change-Id: I228dc570d5b1c19fdc766313d194f637f8418f58
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1904848Reviewed-by: default avatarDavid Staessens <dstaessens@chromium.org>
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713706}
parent ba304ae6
...@@ -73,7 +73,10 @@ size_t EncodedDataHelper::GetBytesForNextNALU(size_t start_pos) { ...@@ -73,7 +73,10 @@ size_t EncodedDataHelper::GetBytesForNextNALU(size_t start_pos) {
size_t pos = start_pos; size_t pos = start_pos;
if (pos + 4 > data_.size()) if (pos + 4 > data_.size())
return pos; return pos;
LOG_ASSERT(IsNALHeader(data_, pos)); if (!IsNALHeader(data_, pos)) {
ADD_FAILURE();
return std::numeric_limits<std::size_t>::max();
}
pos += 4; pos += 4;
while (pos + 4 <= data_.size() && !IsNALHeader(data_, pos)) { while (pos + 4 <= data_.size() && !IsNALHeader(data_, pos)) {
++pos; ++pos;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "media/gpu/video_frame_mapper.h" #include "media/gpu/video_frame_mapper.h"
#include "media/gpu/video_frame_mapper_factory.h" #include "media/gpu/video_frame_mapper_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/codec/png_codec.h" #include "ui/gfx/codec/png_codec.h"
namespace media { namespace media {
...@@ -127,7 +128,7 @@ void VideoFrameFileWriter::ProcessVideoFrameTask( ...@@ -127,7 +128,7 @@ void VideoFrameFileWriter::ProcessVideoFrameTask(
!video_frame_mapper_) { !video_frame_mapper_) {
video_frame_mapper_ = VideoFrameMapperFactory::CreateMapper( video_frame_mapper_ = VideoFrameMapperFactory::CreateMapper(
video_frame->format(), video_frame->storage_type()); video_frame->format(), video_frame->storage_type());
LOG_ASSERT(video_frame_mapper_) << "Failed to create VideoFrameMapper"; ASSERT_TRUE(video_frame_mapper_) << "Failed to create VideoFrameMapper";
} }
#endif #endif
...@@ -180,7 +181,7 @@ void VideoFrameFileWriter::WriteVideoFramePNG( ...@@ -180,7 +181,7 @@ void VideoFrameFileWriter::WriteVideoFramePNG(
argb_out_frame->stride(VideoFrame::kARGBPlane), argb_out_frame->stride(VideoFrame::kARGBPlane),
true, /* discard_transparency */ true, /* discard_transparency */
std::vector<gfx::PNGCodec::Comment>(), &png_output); std::vector<gfx::PNGCodec::Comment>(), &png_output);
LOG_ASSERT(png_encode_status); ASSERT_TRUE(png_encode_status);
// Write the PNG data to file. // Write the PNG data to file.
base::FilePath file_path( base::FilePath file_path(
...@@ -188,7 +189,7 @@ void VideoFrameFileWriter::WriteVideoFramePNG( ...@@ -188,7 +189,7 @@ void VideoFrameFileWriter::WriteVideoFramePNG(
const int size = base::checked_cast<int>(png_output.size()); const int size = base::checked_cast<int>(png_output.size());
const int bytes_written = base::WriteFile( const int bytes_written = base::WriteFile(
file_path, reinterpret_cast<char*>(png_output.data()), size); file_path, reinterpret_cast<char*>(png_output.data()), size);
LOG_ASSERT(bytes_written == size); ASSERT_TRUE(bytes_written == size);
} }
void VideoFrameFileWriter::WriteVideoFrameYUV( void VideoFrameFileWriter::WriteVideoFrameYUV(
...@@ -235,7 +236,7 @@ void VideoFrameFileWriter::WriteVideoFrameYUV( ...@@ -235,7 +236,7 @@ void VideoFrameFileWriter::WriteVideoFrameYUV(
VideoFrame::Rows(i, pixel_format, visible_size.height()); VideoFrame::Rows(i, pixel_format, visible_size.height());
const int row_bytes = const int row_bytes =
VideoFrame::RowBytes(i, pixel_format, visible_size.width()); VideoFrame::RowBytes(i, pixel_format, visible_size.width());
LOG_ASSERT(stride > 0); ASSERT_TRUE(stride > 0);
for (size_t row = 0; row < rows; ++row) { for (size_t row = 0; row < rows; ++row) {
if (yuv_file.WriteAtCurrentPos( if (yuv_file.WriteAtCurrentPos(
reinterpret_cast<const char*>(data + (stride * row)), reinterpret_cast<const char*>(data + (stride * row)),
......
...@@ -107,7 +107,7 @@ void TestVDAVideoDecoder::Initialize(const VideoDecoderConfig& config, ...@@ -107,7 +107,7 @@ void TestVDAVideoDecoder::Initialize(const VideoDecoderConfig& config,
} }
if (!decoder_factory) { if (!decoder_factory) {
LOG_ASSERT(decoder_) << "Failed to create VideoDecodeAccelerator factory"; ASSERT_TRUE(decoder_) << "Failed to create VideoDecodeAccelerator factory";
std::move(init_cb).Run(false); std::move(init_cb).Run(false);
return; return;
} }
...@@ -128,7 +128,7 @@ void TestVDAVideoDecoder::Initialize(const VideoDecoderConfig& config, ...@@ -128,7 +128,7 @@ void TestVDAVideoDecoder::Initialize(const VideoDecoderConfig& config,
this, vda_config, gpu_driver_bug_workarounds, gpu_preferences); this, vda_config, gpu_driver_bug_workarounds, gpu_preferences);
if (!decoder_) { if (!decoder_) {
LOG_ASSERT(decoder_) << "Failed to create VideoDecodeAccelerator factory"; ASSERT_TRUE(decoder_) << "Failed to create VideoDecodeAccelerator factory";
std::move(init_cb).Run(false); std::move(init_cb).Run(false);
return; return;
} }
...@@ -229,7 +229,7 @@ void TestVDAVideoDecoder::ProvidePictureBuffersWithVisibleRect( ...@@ -229,7 +229,7 @@ void TestVDAVideoDecoder::ProvidePictureBuffersWithVisibleRect(
gfx::BufferUsage::SCANOUT_VDA_WRITE); gfx::BufferUsage::SCANOUT_VDA_WRITE);
#endif // BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION) #endif // BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
LOG_ASSERT(video_frame) << "Failed to create video frame"; ASSERT_TRUE(video_frame) << "Failed to create video frame";
video_frames_.emplace(picture_buffer.id(), video_frame); video_frames_.emplace(picture_buffer.id(), video_frame);
gfx::GpuMemoryBufferHandle handle; gfx::GpuMemoryBufferHandle handle;
...@@ -240,7 +240,7 @@ void TestVDAVideoDecoder::ProvidePictureBuffersWithVisibleRect( ...@@ -240,7 +240,7 @@ void TestVDAVideoDecoder::ProvidePictureBuffersWithVisibleRect(
NOTREACHED(); NOTREACHED();
#endif // BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION) #endif // BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
LOG_ASSERT(!handle.is_null()) << "Failed to create GPU memory handle"; ASSERT_TRUE(!handle.is_null()) << "Failed to create GPU memory handle";
decoder_->ImportBufferForPicture(picture_buffer.id(), format, decoder_->ImportBufferForPicture(picture_buffer.id(), format,
std::move(handle)); std::move(handle));
} }
...@@ -252,7 +252,7 @@ void TestVDAVideoDecoder::ProvidePictureBuffersWithVisibleRect( ...@@ -252,7 +252,7 @@ void TestVDAVideoDecoder::ProvidePictureBuffersWithVisibleRect(
uint32_t texture_id; uint32_t texture_id;
auto video_frame = frame_renderer_->CreateVideoFrame( auto video_frame = frame_renderer_->CreateVideoFrame(
format, dimensions, texture_target, &texture_id); format, dimensions, texture_target, &texture_id);
LOG_ASSERT(video_frame) << "Failed to create video frame"; ASSERT_TRUE(video_frame) << "Failed to create video frame";
int32_t picture_buffer_id = GetNextPictureBufferId(); int32_t picture_buffer_id = GetNextPictureBufferId();
PictureBuffer::TextureIds texture_ids(1, texture_id); PictureBuffer::TextureIds texture_ids(1, texture_id);
picture_buffers.emplace_back(picture_buffer_id, dimensions, texture_ids, picture_buffers.emplace_back(picture_buffer_id, dimensions, texture_ids,
...@@ -282,7 +282,7 @@ void TestVDAVideoDecoder::PictureReady(const Picture& picture) { ...@@ -282,7 +282,7 @@ void TestVDAVideoDecoder::PictureReady(const Picture& picture) {
DVLOGF(4) << "Picture buffer ID: " << picture.picture_buffer_id(); DVLOGF(4) << "Picture buffer ID: " << picture.picture_buffer_id();
auto it = video_frames_.find(picture.picture_buffer_id()); auto it = video_frames_.find(picture.picture_buffer_id());
LOG_ASSERT(it != video_frames_.end()); ASSERT_TRUE(it != video_frames_.end());
scoped_refptr<VideoFrame> video_frame = it->second; scoped_refptr<VideoFrame> video_frame = it->second;
// Look up the time at which the decode started. // Look up the time at which the decode started.
...@@ -359,7 +359,7 @@ void TestVDAVideoDecoder::NotifyEndOfBitstreamBuffer( ...@@ -359,7 +359,7 @@ void TestVDAVideoDecoder::NotifyEndOfBitstreamBuffer(
DCHECK_CALLED_ON_VALID_SEQUENCE(vda_wrapper_sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(vda_wrapper_sequence_checker_);
auto it = decode_cbs_.find(bitstream_buffer_id); auto it = decode_cbs_.find(bitstream_buffer_id);
LOG_ASSERT(it != decode_cbs_.end()) ASSERT_TRUE(it != decode_cbs_.end())
<< "Couldn't find decode callback for picture buffer with id " << "Couldn't find decode callback for picture buffer with id "
<< bitstream_buffer_id; << bitstream_buffer_id;
......
...@@ -32,7 +32,8 @@ VideoTestEnvironment::VideoTestEnvironment() { ...@@ -32,7 +32,8 @@ VideoTestEnvironment::VideoTestEnvironment() {
logging::LoggingSettings settings; logging::LoggingSettings settings;
settings.logging_dest = settings.logging_dest =
logging::LOG_TO_SYSTEM_DEBUG_LOG | logging::LOG_TO_STDERR; logging::LOG_TO_SYSTEM_DEBUG_LOG | logging::LOG_TO_STDERR;
LOG_ASSERT(logging::InitLogging(settings)); if (!logging::InitLogging(settings))
ADD_FAILURE();
// Setting up a task environment will create a task runner for the current // Setting up a task environment will create a task runner for the current
// thread and allow posting tasks to other threads. This is required for video // thread and allow posting tasks to other threads. This is required for video
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment