Commit 842f85f3 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

media/gpu/test/VideoTestEnvironment: Returns test_suite_name+test_name by GetTestName()

This CL changes GetTestName() to return test_suite_name+test_name, which
originally returns test_name. This change mainly affects the directory where
frames and images are saved.
For example, the saved directory in video_decode_accelerator_tests is changed
to $(CUR_DIR)/VideoDecoderTest/FlushAtEndOfStream from
$(CUR_DIR)/FlushAtEndOfStream. The saved directory in image_processor_test is
changed to $(CUR_DIR)/PixelFormatConversionToNV12/ConvertOneTime_MemToMem/0 from
$(CUR_DIR)/ConvertOneTime_MemToMem/0.

This is useful for a parameterised test like image_processor_test. For instance,
before this change, image_processor_test saves the processed images in
PixelFormatConversionToNV12 and NV12Scaleing to $(CUR_DIR)/ConvertOneTime_MemToMem/0.

Bug: 917951
Test: video_decode_accelerator_tests --output_frames
Test: video_decode_accelerator_perf_tests
Test: image_processor_test --save_images
Test: tast run video.DecodeAccelVDH264
Test: tast run video.DecodeAccelVDPerfH2641080P30FPS
Change-Id: Ife8412603dc95ca24e87960523d249abc6bcacfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1778104Reviewed-by: default avatarDavid Staessens <dstaessens@chromium.org>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#694647}
parent dec4e74b
......@@ -7,6 +7,7 @@
#include <tuple>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/hash/md5.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
......@@ -113,7 +114,7 @@ class ImageProcessorParamTest
if (g_save_images) {
base::FilePath output_dir =
base::FilePath(base::FilePath::kCurrentDirectory)
.Append(base::FilePath(g_env->GetTestName()));
.Append(g_env->GetTestOutputFilePath());
test::VideoFrameFileWriter::OutputFormat saved_file_format =
IsYuvPlanar(output_format)
? test::VideoFrameFileWriter::OutputFormat::kYUV
......
......@@ -51,8 +51,11 @@ std::unique_ptr<VideoFrameFileWriter> VideoFrameFileWriter::Create(
}
// Create the directory tree if it doesn't exist yet.
if (!DirectoryExists(resolved_output_folder)) {
base::CreateDirectory(resolved_output_folder);
if (!DirectoryExists(resolved_output_folder) &&
!base::CreateDirectory(resolved_output_folder)) {
LOG(ERROR) << "Failed to create a output directory: "
<< resolved_output_folder;
return nullptr;
}
auto frame_file_writer = base::WrapUnique(
......
......@@ -85,16 +85,21 @@ void VideoTestEnvironment::TearDown() {
task_environment_->RunUntilIdle();
}
base::FilePath::StringType VideoTestEnvironment::GetTestName() const {
base::FilePath VideoTestEnvironment::GetTestOutputFilePath() const {
const ::testing::TestInfo* const test_info =
::testing::UnitTest::GetInstance()->current_test_info();
base::FilePath::StringType test_name;
base::FilePath::StringType test_suite_name;
#if defined(OS_WIN)
// On Windows the default file path string type is UTF16. Since the test name
// is always returned in UTF8 we need to do a conversion here.
return base::UTF8ToUTF16(test_info->name());
test_name = base::UTF8ToUTF16(test_info->name());
test_suite_name = base::UTF8ToUTF16(test_info->test_suite_name());
#else
return test_info->name();
test_name = test_info->name();
test_suite_name = test_info->test_suite_name();
#endif
return base::FilePath(test_suite_name).Append(test_name);
}
} // namespace test
......
......@@ -38,8 +38,8 @@ class VideoTestEnvironment : public ::testing::Environment {
// Tear down video test environment, called once for entire test run.
void TearDown() override;
// Get the name of the current test.
base::FilePath::StringType GetTestName() const;
// Get the name of the test output file path (testsuitename/testname).
base::FilePath GetTestOutputFilePath() const;
private:
// Whether the test environment has been initialized.
......
......@@ -273,10 +273,10 @@ void PerformanceEvaluator::WriteMetricsToFile() const {
std::string metrics_str;
ASSERT_TRUE(base::JSONWriter::WriteWithOptions(
metrics, base::JSONWriter::OPTIONS_PRETTY_PRINT, &metrics_str));
base::FilePath metrics_file_path =
output_folder_path.Append(base::FilePath(g_env->GetTestName())
.AddExtension(FILE_PATH_LITERAL(".json")));
base::FilePath metrics_file_path = output_folder_path.Append(
g_env->GetTestOutputFilePath().AddExtension(FILE_PATH_LITERAL(".json")));
// Make sure that the directory into which json is saved is created.
LOG_ASSERT(base::CreateDirectory(metrics_file_path.DirName()));
base::File metrics_output_file(
base::FilePath(metrics_file_path),
base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "media/base/test_data_util.h"
#include "media/gpu/test/video_frame_file_writer.h"
#include "media/gpu/test/video_frame_validator.h"
......@@ -80,7 +81,7 @@ class VideoDecoderTest : public ::testing::Test {
config.allocation_mode == AllocationMode::kImport) {
base::FilePath output_folder =
base::FilePath(g_env->OutputFolder())
.Append(base::FilePath(g_env->GetTestName()));
.Append(g_env->GetTestOutputFilePath());
frame_processors.push_back(VideoFrameFileWriter::Create(output_folder));
VLOG(0) << "Writing video frames to: " << output_folder;
}
......@@ -279,10 +280,8 @@ TEST_F(VideoDecoderTest, FlushAtEndOfStream_RenderThumbnails) {
GTEST_SKIP();
}
base::FilePath output_folder =
base::FilePath(g_env->OutputFolder())
.Append(base::FilePath(g_env->GetTestName()));
base::FilePath output_folder = base::FilePath(g_env->OutputFolder())
.Append(g_env->GetTestOutputFilePath());
VideoDecoderClientConfig config;
config.allocation_mode = AllocationMode::kAllocate;
auto tvp = CreateVideoPlayer(
......
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