ref: ff078e58c7ff4d589a43a98fc877e42df8b7bcf9
parent: c1765573149e2c0fe2acabc224c0f9085b9e7f2b
author: James Zern <jzern@google.com>
date: Thu Jun 18 06:54:23 EDT 2020
vp9_skip_loopfilter_test: make Init() return a bool ASSERT's in the function only force a return, not termination. this fixes a static analyzer issue with using a null decoder object in following calls. BUG=webm:1695,webm:1686 Change-Id: I79762df8076d029c5c8fef4d5e06ed655719de62 (cherry picked from commit 0370a43816cadc4939661d7b214a2077f8d25e88)
--- a/test/vp9_skip_loopfilter_test.cc
+++ b/test/vp9_skip_loopfilter_test.cc
@@ -33,11 +33,14 @@
}
// If |threads| > 0 then set the decoder with that number of threads.
- void Init(int num_threads) {
+ bool Init(int num_threads) {
expected_md5_[0] = '\0';
junk_[0] = '\0';
video_ = new libvpx_test::WebMVideoSource(kVp9TestFile);
- ASSERT_TRUE(video_ != NULL);
+ if (video_ == NULL) {
+ EXPECT_TRUE(video_ != NULL);
+ return false;
+ }
video_->Init();
video_->Begin();
@@ -44,13 +47,18 @@
vpx_codec_dec_cfg_t cfg = vpx_codec_dec_cfg_t();
if (num_threads > 0) cfg.threads = num_threads;
decoder_ = new libvpx_test::VP9Decoder(cfg, 0);
- ASSERT_TRUE(decoder_ != NULL);
+ if (decoder_ == NULL) {
+ EXPECT_TRUE(decoder_ != NULL);
+ return false;
+ }
OpenMd5File(kVp9Md5File);
+ return !::testing::Test::HasFailure();
}
// Set the VP9 skipLoopFilter control value.
void SetSkipLoopFilter(int value, vpx_codec_err_t expected_value) {
+ ASSERT_NE(decoder_, nullptr);
decoder_->Control(VP9_SET_SKIP_LOOP_FILTER, value, expected_value);
}
@@ -121,7 +129,7 @@
const int non_zero_value = 1;
const int num_threads = 0;
SkipLoopFilterTest skip_loop_filter;
- skip_loop_filter.Init(num_threads);
+ ASSERT_TRUE(skip_loop_filter.Init(num_threads));
skip_loop_filter.SetSkipLoopFilter(non_zero_value, VPX_CODEC_OK);
ASSERT_EQ(VPX_CODEC_OK, skip_loop_filter.DecodeRemainingFrames());
skip_loop_filter.CheckMd5(false);
@@ -131,7 +139,7 @@
const int non_zero_value = 1;
const int num_threads = 1;
SkipLoopFilterTest skip_loop_filter;
- skip_loop_filter.Init(num_threads);
+ ASSERT_TRUE(skip_loop_filter.Init(num_threads));
skip_loop_filter.SetSkipLoopFilter(non_zero_value, VPX_CODEC_OK);
ASSERT_EQ(VPX_CODEC_OK, skip_loop_filter.DecodeRemainingFrames());
skip_loop_filter.CheckMd5(false);
@@ -141,7 +149,7 @@
const int non_zero_value = 1;
const int num_threads = 8;
SkipLoopFilterTest skip_loop_filter;
- skip_loop_filter.Init(num_threads);
+ ASSERT_TRUE(skip_loop_filter.Init(num_threads));
skip_loop_filter.SetSkipLoopFilter(non_zero_value, VPX_CODEC_OK);
ASSERT_EQ(VPX_CODEC_OK, skip_loop_filter.DecodeRemainingFrames());
skip_loop_filter.CheckMd5(false);
@@ -151,7 +159,7 @@
const int non_zero_value = 1;
const int num_threads = 0;
SkipLoopFilterTest skip_loop_filter;
- skip_loop_filter.Init(num_threads);
+ ASSERT_TRUE(skip_loop_filter.Init(num_threads));
skip_loop_filter.SetSkipLoopFilter(non_zero_value, VPX_CODEC_OK);
skip_loop_filter.SetSkipLoopFilter(0, VPX_CODEC_OK);
ASSERT_EQ(VPX_CODEC_OK, skip_loop_filter.DecodeRemainingFrames());
@@ -161,7 +169,7 @@
TEST(SkipLoopFilterTest, ToggleLoopFilter) {
const int num_threads = 0;
SkipLoopFilterTest skip_loop_filter;
- skip_loop_filter.Init(num_threads);
+ ASSERT_TRUE(skip_loop_filter.Init(num_threads));
for (int i = 0; i < 10; ++i) {
skip_loop_filter.SetSkipLoopFilter(i % 2, VPX_CODEC_OK);