Commit 5531d748 authored by David Staessens's avatar David Staessens Committed by Commit Bot

Reland "media/gpu: VDA tests and perf tests uses base::TestLauncher."

This CL relands commit 372610a8, which broke the
test when enabling DCHECK. The breakage has now been fixed.

Original change's description:
> media/gpu: VDA tests and perf tests uses base::TestLauncher.
>
> In CL:1679774 we added a TestLauncher specific argument for each
> Chrome test binary at Tast framework. However, currently VDA test and
> VDA perf test doesn't use base::TestLauncher, so they failed at
> parsing arguments.
> In this CL, we use base::TestLauncher at both VDA tests and perf
> tests.
>
> BUG=chromium:985179
> TEST=./video_decode_accelerator_tests --test-launcher-timeout=3600000
>
> Change-Id: I8155aae78be81bedcb252bfbdb534760e788d3be
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1708150
> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
> Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
> Reviewed-by: David Staessens <dstaessens@chromium.org>
> Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#678603}

BUG=chromium:985179

Change-Id: Iae3a514972498f2f51f0a087662f009fdec72ab1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1710071
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: default avatarChih-Yu Huang <akahuang@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#679032}
parent ba5ecfd4
...@@ -604,6 +604,7 @@ test("video_decode_accelerator_tests") { ...@@ -604,6 +604,7 @@ test("video_decode_accelerator_tests") {
"test:video_player", "test:video_player",
"test:video_player_test_environment", "test:video_player_test_environment",
"test:video_player_thumbnail_renderer", "test:video_player_thumbnail_renderer",
"//base/test:test_support",
"//media:test_support", "//media:test_support",
"//testing/gtest", "//testing/gtest",
] ]
...@@ -620,6 +621,7 @@ test("video_decode_accelerator_perf_tests") { ...@@ -620,6 +621,7 @@ test("video_decode_accelerator_perf_tests") {
":buildflags", ":buildflags",
"test:video_player", "test:video_player",
"test:video_player_test_environment", "test:video_player_test_environment",
"//base/test:test_support",
"//media:test_support", "//media:test_support",
"//testing/gtest", "//testing/gtest",
] ]
......
...@@ -6,10 +6,12 @@ ...@@ -6,10 +6,12 @@
#include <string> #include <string>
#include <tuple> #include <tuple>
#include "base/at_exit.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/hash/md5.h" #include "base/hash/md5.h"
#include "base/test/launcher/unit_test_launcher.h" #include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h" #include "base/test/test_suite.h"
#include "base/test/test_timeouts.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "media/base/video_frame.h" #include "media/base/video_frame.h"
#include "media/base/video_frame_layout.h" #include "media/base/video_frame_layout.h"
...@@ -155,6 +157,12 @@ int main(int argc, char** argv) { ...@@ -155,6 +157,12 @@ int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv); testing::InitGoogleTest(&argc, argv);
base::CommandLine::Init(argc, argv); base::CommandLine::Init(argc, argv);
// Initialize test timeouts and set up an exit manager which is required to
// run callbacks on shutdown.
// TODO(dstaessens): Use base::TestSuite which performs initialization.
TestTimeouts::Initialize();
base::AtExitManager at_exit_manager;
auto* const test_environment = new media::test::VideoTestEnvironment; auto* const test_environment = new media::test::VideoTestEnvironment;
testing::AddGlobalTestEnvironment(test_environment); testing::AddGlobalTestEnvironment(test_environment);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_task_environment.h" #include "base/test/scoped_task_environment.h"
#include "base/test/test_timeouts.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "media/gpu/buildflags.h" #include "media/gpu/buildflags.h"
#include "mojo/core/embedder/embedder.h" #include "mojo/core/embedder/embedder.h"
...@@ -45,7 +44,6 @@ void VideoTestEnvironment::SetUp() { ...@@ -45,7 +44,6 @@ void VideoTestEnvironment::SetUp() {
// 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
// tests to function correctly. // tests to function correctly.
TestTimeouts::Initialize();
task_environment_ = std::make_unique<base::test::ScopedTaskEnvironment>( task_environment_ = std::make_unique<base::test::ScopedTaskEnvironment>(
base::test::ScopedTaskEnvironment::MainThreadType::UI); base::test::ScopedTaskEnvironment::MainThreadType::UI);
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <memory> #include <memory>
#include "base/at_exit.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -45,9 +44,6 @@ class VideoTestEnvironment : public ::testing::Environment { ...@@ -45,9 +44,6 @@ class VideoTestEnvironment : public ::testing::Environment {
// Whether the test environment has been initialized. // Whether the test environment has been initialized.
bool initialized_ = false; bool initialized_ = false;
// An exit manager is required to run callbacks on shutdown.
base::AtExitManager at_exit_manager;
std::unique_ptr<base::test::ScopedTaskEnvironment> task_environment_; std::unique_ptr<base::test::ScopedTaskEnvironment> task_environment_;
#if defined(USE_OZONE) #if defined(USE_OZONE)
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/json/json_writer.h" #include "base/json/json_writer.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
#include "media/base/test_data_util.h" #include "media/base/test_data_util.h"
#include "media/gpu/test/video_player/frame_renderer_dummy.h" #include "media/gpu/test/video_player/frame_renderer_dummy.h"
#include "media/gpu/test/video_player/video.h" #include "media/gpu/test/video_player/video.h"
...@@ -377,7 +379,7 @@ int main(int argc, char** argv) { ...@@ -377,7 +379,7 @@ int main(int argc, char** argv) {
LOG_ASSERT(cmd_line); LOG_ASSERT(cmd_line);
if (cmd_line->HasSwitch("help")) { if (cmd_line->HasSwitch("help")) {
std::cout << media::test::usage_msg << "\n" << media::test::help_msg; std::cout << media::test::usage_msg << "\n" << media::test::help_msg;
return 0; return EXIT_SUCCESS;
} }
// Check if a video was specified on the command line. // Check if a video was specified on the command line.
...@@ -393,8 +395,11 @@ int main(int argc, char** argv) { ...@@ -393,8 +395,11 @@ int main(int argc, char** argv) {
base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); base::CommandLine::SwitchMap switches = cmd_line->GetSwitches();
for (base::CommandLine::SwitchMap::const_iterator it = switches.begin(); for (base::CommandLine::SwitchMap::const_iterator it = switches.begin();
it != switches.end(); ++it) { it != switches.end(); ++it) {
if (it->first.find("gtest_") == 0 || // Handled by GoogleTest // Ignore arguments handled by Chrome, GoogleTest, and base::TestLauncher.
it->first == "v" || it->first == "vmodule") { // Handled by Chrome if (it->first == "v" || it->first == "vmodule" ||
it->first.find("gtest_") == 0 ||
it->first.find("test-launcher") != std::string::npos ||
it->first == "single-process-tests") {
continue; continue;
} }
...@@ -422,5 +427,9 @@ int main(int argc, char** argv) { ...@@ -422,5 +427,9 @@ int main(int argc, char** argv) {
media::test::g_env = static_cast<media::test::VideoPlayerTestEnvironment*>( media::test::g_env = static_cast<media::test::VideoPlayerTestEnvironment*>(
testing::AddGlobalTestEnvironment(test_environment)); testing::AddGlobalTestEnvironment(test_environment));
return RUN_ALL_TESTS(); // Launch all tests sequentially and disable batching.
base::TestSuite test_suite(argc, argv);
return base::LaunchUnitTestsWithOptions(
argc, argv, 1, 0, true,
base::BindOnce(&base::TestSuite::Run, base::Unretained(&test_suite)));
} }
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "base/command_line.h" #include "base/command_line.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
#include "media/base/test_data_util.h" #include "media/base/test_data_util.h"
#include "media/gpu/test/video_frame_file_writer.h" #include "media/gpu/test/video_frame_file_writer.h"
#include "media/gpu/test/video_frame_validator.h" #include "media/gpu/test/video_frame_validator.h"
...@@ -324,7 +326,7 @@ int main(int argc, char** argv) { ...@@ -324,7 +326,7 @@ int main(int argc, char** argv) {
LOG_ASSERT(cmd_line); LOG_ASSERT(cmd_line);
if (cmd_line->HasSwitch("help")) { if (cmd_line->HasSwitch("help")) {
std::cout << media::test::usage_msg << "\n" << media::test::help_msg; std::cout << media::test::usage_msg << "\n" << media::test::help_msg;
return 0; return EXIT_SUCCESS;
} }
// Check if a video was specified on the command line. // Check if a video was specified on the command line.
...@@ -342,8 +344,11 @@ int main(int argc, char** argv) { ...@@ -342,8 +344,11 @@ int main(int argc, char** argv) {
base::CommandLine::SwitchMap switches = cmd_line->GetSwitches(); base::CommandLine::SwitchMap switches = cmd_line->GetSwitches();
for (base::CommandLine::SwitchMap::const_iterator it = switches.begin(); for (base::CommandLine::SwitchMap::const_iterator it = switches.begin();
it != switches.end(); ++it) { it != switches.end(); ++it) {
if (it->first.find("gtest_") == 0 || // Handled by GoogleTest // Ignore arguments handled by Chrome, GoogleTest, and base::TestLauncher.
it->first == "v" || it->first == "vmodule") { // Handled by Chrome if (it->first == "v" || it->first == "vmodule" ||
it->first.find("gtest_") == 0 ||
it->first.find("test-launcher") != std::string::npos ||
it->first == "single-process-tests") {
continue; continue;
} }
...@@ -375,5 +380,9 @@ int main(int argc, char** argv) { ...@@ -375,5 +380,9 @@ int main(int argc, char** argv) {
media::test::g_env = static_cast<media::test::VideoPlayerTestEnvironment*>( media::test::g_env = static_cast<media::test::VideoPlayerTestEnvironment*>(
testing::AddGlobalTestEnvironment(test_environment)); testing::AddGlobalTestEnvironment(test_environment));
return RUN_ALL_TESTS(); // Launch all tests sequentially and disable batching.
base::TestSuite test_suite(argc, argv);
return base::LaunchUnitTestsWithOptions(
argc, argv, 1, 0, true,
base::BindOnce(&base::TestSuite::Run, base::Unretained(&test_suite)));
} }
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