Remove SetExecutablePath, simplify ResourcePath
SetExecutablePath isn't used anymore. Nobody was using the fancy select-per-platform functionality, and the documentation was wrong anyway. In the cases somebody needed an override per platform, they were using defines in their own test instead. I think that is more verbose but more predictable and easy to understand (see how it's done in audio_processing_unittest.cc when loading output_data_mac, for instance). Bug: webrtc:9792 Change-Id: I7289bf5883fe43852638922d7c7583eae0c08601 Reviewed-on: https://webrtc-review.googlesource.com/c/104482 Commit-Queue: Patrik Höglund <phoglund@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25062}
This commit is contained in:
committed by
Commit Bot
parent
70045719ab
commit
7730193a49
@ -1756,7 +1756,6 @@ if (rtc_include_tests) {
|
|||||||
":neteq_test_support",
|
":neteq_test_support",
|
||||||
"../..:webrtc_common",
|
"../..:webrtc_common",
|
||||||
"../../rtc_base:rtc_base_approved",
|
"../../rtc_base:rtc_base_approved",
|
||||||
"../../test:fileutils",
|
|
||||||
"../../test:test_support",
|
"../../test:test_support",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
#include "modules/audio_coding/neteq/tools/neteq_performance_test.h"
|
#include "modules/audio_coding/neteq/tools/neteq_performance_test.h"
|
||||||
#include "rtc_base/flags.h"
|
#include "rtc_base/flags.h"
|
||||||
#include "test/testsupport/fileutils.h"
|
|
||||||
|
|
||||||
// Define command line flags.
|
// Define command line flags.
|
||||||
DEFINE_int(runtime_ms, 10000, "Simulated runtime in ms.");
|
DEFINE_int(runtime_ms, 10000, "Simulated runtime in ms.");
|
||||||
@ -33,7 +32,6 @@ int main(int argc, char* argv[]) {
|
|||||||
" --lossrate=N drop every N packets; default is 10\n"
|
" --lossrate=N drop every N packets; default is 10\n"
|
||||||
" --drift=F clockdrift factor between 0.0 and 1.0; "
|
" --drift=F clockdrift factor between 0.0 and 1.0; "
|
||||||
"default is 0.1\n";
|
"default is 0.1\n";
|
||||||
webrtc::test::SetExecutablePath(argv[0]);
|
|
||||||
if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
|
if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
|
||||||
argc != 1) {
|
argc != 1) {
|
||||||
printf("%s", usage.c_str());
|
printf("%s", usage.c_str());
|
||||||
|
|||||||
@ -192,6 +192,7 @@ rtc_source_set("rtc_event") {
|
|||||||
|
|
||||||
rtc_source_set("logging") {
|
rtc_source_set("logging") {
|
||||||
visibility = [ "*" ]
|
visibility = [ "*" ]
|
||||||
|
libs = []
|
||||||
deps = [
|
deps = [
|
||||||
":criticalsection",
|
":criticalsection",
|
||||||
":macromagic",
|
":macromagic",
|
||||||
@ -222,6 +223,10 @@ rtc_source_set("logging") {
|
|||||||
# logging.h needs the deprecation header while downstream projects are
|
# logging.h needs the deprecation header while downstream projects are
|
||||||
# removing code that depends on logging implementation details.
|
# removing code that depends on logging implementation details.
|
||||||
deps += [ ":deprecation" ]
|
deps += [ ":deprecation" ]
|
||||||
|
|
||||||
|
if (is_android) {
|
||||||
|
libs += [ "log" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,6 +253,7 @@ rtc_source_set("atomicops") {
|
|||||||
rtc_source_set("checks") {
|
rtc_source_set("checks") {
|
||||||
# TODO(bugs.webrtc.org/9607): This should not be public.
|
# TODO(bugs.webrtc.org/9607): This should not be public.
|
||||||
visibility = [ "*" ]
|
visibility = [ "*" ]
|
||||||
|
libs = []
|
||||||
sources = [
|
sources = [
|
||||||
"checks.cc",
|
"checks.cc",
|
||||||
"checks.h",
|
"checks.h",
|
||||||
@ -256,6 +262,9 @@ rtc_source_set("checks") {
|
|||||||
":safe_compare",
|
":safe_compare",
|
||||||
"system:inline",
|
"system:inline",
|
||||||
]
|
]
|
||||||
|
if (is_android) {
|
||||||
|
libs += [ "log" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rtc_source_set("rate_limiter") {
|
rtc_source_set("rate_limiter") {
|
||||||
@ -1083,7 +1092,6 @@ if (rtc_include_tests) {
|
|||||||
"../system_wrappers:field_trial",
|
"../system_wrappers:field_trial",
|
||||||
"../system_wrappers:metrics",
|
"../system_wrappers:metrics",
|
||||||
"../test:field_trial",
|
"../test:field_trial",
|
||||||
"../test:fileutils",
|
|
||||||
"../test:test_support",
|
"../test:test_support",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,6 @@
|
|||||||
#include "system_wrappers/include/field_trial.h"
|
#include "system_wrappers/include/field_trial.h"
|
||||||
#include "system_wrappers/include/metrics.h"
|
#include "system_wrappers/include/metrics.h"
|
||||||
#include "test/field_trial.h"
|
#include "test/field_trial.h"
|
||||||
#include "test/testsupport/fileutils.h"
|
|
||||||
|
|
||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
#include "rtc_base/win32socketinit.h"
|
#include "rtc_base/win32socketinit.h"
|
||||||
@ -81,7 +80,6 @@ int main(int argc, char* argv[]) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
webrtc::test::SetExecutablePath(argv[0]);
|
|
||||||
webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials);
|
webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials);
|
||||||
// InitFieldTrialsFromString stores the char*, so the char array must outlive
|
// InitFieldTrialsFromString stores the char*, so the char array must outlive
|
||||||
// the application.
|
// the application.
|
||||||
|
|||||||
@ -218,7 +218,6 @@ int main(int argc, char* argv[]) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
webrtc::test::SetExecutablePath(argv[0]);
|
|
||||||
webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials);
|
webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials);
|
||||||
// InitFieldTrialsFromString stores the char*, so the char array must outlive
|
// InitFieldTrialsFromString stores the char*, so the char array must outlive
|
||||||
// the application.
|
// the application.
|
||||||
|
|||||||
@ -208,12 +208,17 @@ if (rtc_include_tests) {
|
|||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
":field_trial",
|
":field_trial",
|
||||||
":fileutils",
|
|
||||||
":perf_test",
|
":perf_test",
|
||||||
"../rtc_base:rtc_base",
|
"../rtc_base:rtc_base",
|
||||||
"../system_wrappers:field_trial",
|
"../system_wrappers:field_trial",
|
||||||
"../system_wrappers:metrics",
|
"../system_wrappers:metrics",
|
||||||
"//testing/gtest",
|
"//testing/gtest",
|
||||||
|
|
||||||
|
# TODO(bugs.webrtc.org/9792): This is needed for downstream projects on
|
||||||
|
# Android, where it's replaced by an internal version of fileutils that
|
||||||
|
# has a certain flag. Remove this once the internal fileutils has been
|
||||||
|
# eliminated.
|
||||||
|
"../test:fileutils",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -86,7 +86,13 @@ int main(int argc, char* argv[]) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
webrtc::test::SetExecutablePath(argv[0]);
|
// TODO(bugs.webrtc.org/9792): we need to reference something from fileutils.h
|
||||||
|
// so that our downstream hack where we replace fileutils.cc works. Otherwise
|
||||||
|
// the downstream flag implementation will take over and botch the flag
|
||||||
|
// introduced by the hack. Remove this awful thing once the downstream
|
||||||
|
// implementation has been eliminated.
|
||||||
|
(void)webrtc::test::JoinFilename("horrible", "hack");
|
||||||
|
|
||||||
webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials);
|
webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials);
|
||||||
// InitFieldTrialsFromString stores the char*, so the char array must outlive
|
// InitFieldTrialsFromString stores the char*, so the char array must outlive
|
||||||
// the application.
|
// the application.
|
||||||
|
|||||||
@ -81,9 +81,6 @@ const char* kAndroidChromiumTestsRoot = "/sdcard/chromium_tests_root/";
|
|||||||
const char* kResourcesDirName = "resources";
|
const char* kResourcesDirName = "resources";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char relative_dir_path[FILENAME_MAX];
|
|
||||||
bool relative_dir_path_set = false;
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
const char* kCannotFindProjectRootDir = "ERROR_CANNOT_FIND_PROJECT_ROOT_DIR";
|
const char* kCannotFindProjectRootDir = "ERROR_CANNOT_FIND_PROJECT_ROOT_DIR";
|
||||||
@ -101,27 +98,6 @@ std::string DirName(const std::string& path) {
|
|||||||
return result.substr(0, result.find_last_of(kPathDelimiter));
|
return result.substr(0, result.find_last_of(kPathDelimiter));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetExecutablePath(const std::string& path) {
|
|
||||||
std::string working_dir = WorkingDir();
|
|
||||||
std::string temp_path = path;
|
|
||||||
|
|
||||||
// Handle absolute paths; convert them to relative paths to the working dir.
|
|
||||||
if (path.find(working_dir) != std::string::npos) {
|
|
||||||
temp_path = path.substr(working_dir.length() + 1);
|
|
||||||
}
|
|
||||||
// On Windows, when tests are run under memory tools like DrMemory and TSan,
|
|
||||||
// slashes occur in the path as directory separators. Make sure we replace
|
|
||||||
// such cases with backslashes in order for the paths to be correct.
|
|
||||||
#ifdef WIN32
|
|
||||||
std::replace(temp_path.begin(), temp_path.end(), '/', '\\');
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Trim away the executable name; only store the relative dir path.
|
|
||||||
temp_path = DirName(temp_path);
|
|
||||||
strncpy(relative_dir_path, temp_path.c_str(), FILENAME_MAX);
|
|
||||||
relative_dir_path_set = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FileExists(const std::string& file_name) {
|
bool FileExists(const std::string& file_name) {
|
||||||
struct stat file_info = {0};
|
struct stat file_info = {0};
|
||||||
return stat(file_name.c_str(), &file_info) == 0;
|
return stat(file_name.c_str(), &file_info) == 0;
|
||||||
@ -325,27 +301,10 @@ std::string ResourcePath(const std::string& name,
|
|||||||
#if defined(WEBRTC_IOS)
|
#if defined(WEBRTC_IOS)
|
||||||
return IOSResourcePath(name, extension);
|
return IOSResourcePath(name, extension);
|
||||||
#else
|
#else
|
||||||
std::string platform = "win";
|
|
||||||
#ifdef WEBRTC_LINUX
|
|
||||||
platform = "linux";
|
|
||||||
#endif // WEBRTC_LINUX
|
|
||||||
#ifdef WEBRTC_MAC
|
|
||||||
platform = "mac";
|
|
||||||
#endif // WEBRTC_MAC
|
|
||||||
#ifdef WEBRTC_ANDROID
|
|
||||||
platform = "android";
|
|
||||||
#endif // WEBRTC_ANDROID
|
|
||||||
|
|
||||||
std::string resources_path =
|
std::string resources_path =
|
||||||
ProjectRootPath() + kResourcesDirName + kPathDelimiter;
|
ProjectRootPath() + kResourcesDirName + kPathDelimiter;
|
||||||
std::string resource_file =
|
|
||||||
resources_path + name + "_" + platform + "." + extension;
|
|
||||||
if (FileExists(resource_file)) {
|
|
||||||
return resource_file;
|
|
||||||
}
|
|
||||||
// Fall back on name without platform.
|
|
||||||
return resources_path + name + "." + extension;
|
return resources_path + name + "." + extension;
|
||||||
#endif // defined (WEBRTC_IOS)
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string JoinFilename(const std::string& dir, const std::string& name) {
|
std::string JoinFilename(const std::string& dir, const std::string& name) {
|
||||||
|
|||||||
@ -51,18 +51,8 @@ std::string TempFilename(const std::string& dir, const std::string& prefix);
|
|||||||
std::string GenerateTempFilename(const std::string& dir,
|
std::string GenerateTempFilename(const std::string& dir,
|
||||||
const std::string& prefix);
|
const std::string& prefix);
|
||||||
|
|
||||||
// Returns a path to a resource file for the currently executing platform.
|
// Returns a path to a resource file in [project-root]/resources/ dir.
|
||||||
// Adapts to what filenames are currently present in the
|
// Returns an absolute path
|
||||||
// [project-root]/resources/ dir.
|
|
||||||
// Returns an absolute path according to this priority list (the directory
|
|
||||||
// part of the path is left out for readability):
|
|
||||||
// 1. [name]_[platform]_[architecture].[extension]
|
|
||||||
// 2. [name]_[platform].[extension]
|
|
||||||
// 3. [name]_[architecture].[extension]
|
|
||||||
// 4. [name].[extension]
|
|
||||||
// Where
|
|
||||||
// * platform is either of "win", "mac" or "linux".
|
|
||||||
// * architecture is either of "32" or "64".
|
|
||||||
//
|
//
|
||||||
// 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)
|
||||||
@ -110,15 +100,6 @@ std::string DirName(const std::string& path);
|
|||||||
// empty or if the file does not exist/is readable.
|
// empty or if the file does not exist/is readable.
|
||||||
size_t GetFileSize(const std::string& filename);
|
size_t GetFileSize(const std::string& filename);
|
||||||
|
|
||||||
// Sets the executable path, i.e. the path to the executable that is being used
|
|
||||||
// when launching it. This is usually the path relative to the working directory
|
|
||||||
// but can also be an absolute path. The intention with this function is to pass
|
|
||||||
// the argv[0] being sent into the main function to make it possible for
|
|
||||||
// fileutils.h to find the correct project paths even when the working directory
|
|
||||||
// is outside the project tree (which happens in some cases).
|
|
||||||
// TODO(bugs.webrtc.org/9792): Deprecated - going away soon.
|
|
||||||
void SetExecutablePath(const std::string& path_to_executable);
|
|
||||||
|
|
||||||
} // namespace test
|
} // namespace test
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user