Move --resources_dir to its right place.
We needed a hack in test_main_lib.cc to ensure fileutils were always linked with test binaries downstream. When I removed the hack, it broke the binaries that were _not_ using fileutils because a certain bazel rule expects to be able to pass the flag to all test binaries. The solution is to move the flag to test_main_lib.cc. This is the right place for it since it's apparently in the contract of a WebRTC test binary to support this flag. We then have to pass the value down to the override, which is why I add a new function for that. I leave the flag unimplemented in OSS because no one is using it here anyway. It will be implemented downstream. Bug: webrtc:9792 Change-Id: I21b3deb43bf0cd56d6aa2622dc5519370a0307a9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/156568 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Patrik Höglund <phoglund@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29474}
This commit is contained in:

committed by
Commit Bot

parent
3f0d8e46a8
commit
2f28370e65
@ -253,6 +253,7 @@ if (rtc_include_tests) {
|
|||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
":field_trial",
|
":field_trial",
|
||||||
|
":fileutils_override_api",
|
||||||
":perf_test",
|
":perf_test",
|
||||||
":test_support",
|
":test_support",
|
||||||
"../rtc_base",
|
"../rtc_base",
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "test/gmock.h"
|
#include "test/gmock.h"
|
||||||
#include "test/gtest.h"
|
#include "test/gtest.h"
|
||||||
#include "test/testsupport/file_utils.h"
|
#include "test/testsupport/file_utils.h"
|
||||||
|
#include "test/testsupport/file_utils_override.h"
|
||||||
#include "test/testsupport/perf_test.h"
|
#include "test/testsupport/perf_test.h"
|
||||||
|
|
||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
@ -80,6 +81,14 @@ ABSL_FLAG(std::vector<std::string>,
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ABSL_FLAG(std::string,
|
||||||
|
resources_dir,
|
||||||
|
"",
|
||||||
|
"Where to look for the runtime dependencies. If not specified, we "
|
||||||
|
"will use a reasonable default depending on where we are running. "
|
||||||
|
"This flag is useful if we copy over test resources to a phone and "
|
||||||
|
"need to tell the tests where their resources are.");
|
||||||
|
|
||||||
ABSL_FLAG(bool, logs, true, "print logs to stderr");
|
ABSL_FLAG(bool, logs, true, "print logs to stderr");
|
||||||
ABSL_FLAG(bool, verbose, false, "verbose logs to stderr");
|
ABSL_FLAG(bool, verbose, false, "verbose logs to stderr");
|
||||||
|
|
||||||
@ -106,6 +115,10 @@ class TestMainImpl : public TestMain {
|
|||||||
::testing::InitGoogleMock(argc, argv);
|
::testing::InitGoogleMock(argc, argv);
|
||||||
absl::ParseCommandLine(*argc, argv);
|
absl::ParseCommandLine(*argc, argv);
|
||||||
|
|
||||||
|
std::string resources_dir = absl::GetFlag(FLAGS_resources_dir);
|
||||||
|
if (!resources_dir.empty())
|
||||||
|
test::internal::OverrideResourcesDir(resources_dir);
|
||||||
|
|
||||||
// Default to LS_INFO, even for release builds to provide better test
|
// Default to LS_INFO, even for release builds to provide better test
|
||||||
// logging.
|
// logging.
|
||||||
if (rtc::LogMessage::GetLogToDebug() > rtc::LS_INFO)
|
if (rtc::LogMessage::GetLogToDebug() > rtc::LS_INFO)
|
||||||
|
@ -150,6 +150,12 @@ std::string ResourcePath(const std::string& name,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OverrideResourcesDir(const std::string& resources_dir) {
|
||||||
|
RTC_CHECK(false)
|
||||||
|
<< "Setting the resource dir is not supported in open-source "
|
||||||
|
"tests.";
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace test
|
} // namespace test
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -38,8 +38,7 @@ std::string OutputPath();
|
|||||||
// directory.
|
// directory.
|
||||||
std::string WorkingDir();
|
std::string WorkingDir();
|
||||||
|
|
||||||
// Returns a path to a resource file in [project-root]/resources/ dir.
|
// Returns a full path to a resource file in the resources_dir dir.
|
||||||
// Returns an absolute path
|
|
||||||
//
|
//
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// name - Name of the resource file. If a plain filename (no directory path)
|
// name - Name of the resource file. If a plain filename (no directory path)
|
||||||
@ -49,6 +48,15 @@ std::string WorkingDir();
|
|||||||
// extension - File extension, without the dot, i.e. "bmp" or "yuv".
|
// extension - File extension, without the dot, i.e. "bmp" or "yuv".
|
||||||
std::string ResourcePath(const std::string& name, const std::string& extension);
|
std::string ResourcePath(const std::string& name, const std::string& extension);
|
||||||
|
|
||||||
|
// Overrides the root resource dir. See ResourcePath for more information.
|
||||||
|
//
|
||||||
|
// This is not necessary in most cases, but it can be if we're running on
|
||||||
|
// phones and copy over resources to some custom location.
|
||||||
|
//
|
||||||
|
// Arguments:
|
||||||
|
// resources_dir - Where resources are located.
|
||||||
|
void OverrideResourcesDir(const std::string& resources_dir);
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace test
|
} // namespace test
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
Reference in New Issue
Block a user