diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn index 4982d19a7b..5889018ec6 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -1756,7 +1756,6 @@ if (rtc_include_tests) { ":neteq_test_support", "../..:webrtc_common", "../../rtc_base:rtc_base_approved", - "../../test:fileutils", "../../test:test_support", ] } diff --git a/modules/audio_coding/neteq/test/neteq_speed_test.cc b/modules/audio_coding/neteq/test/neteq_speed_test.cc index c486ac60bd..c1d78c5730 100644 --- a/modules/audio_coding/neteq/test/neteq_speed_test.cc +++ b/modules/audio_coding/neteq/test/neteq_speed_test.cc @@ -14,7 +14,6 @@ #include "modules/audio_coding/neteq/tools/neteq_performance_test.h" #include "rtc_base/flags.h" -#include "test/testsupport/fileutils.h" // Define command line flags. 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" " --drift=F clockdrift factor between 0.0 and 1.0; " "default is 0.1\n"; - webrtc::test::SetExecutablePath(argv[0]); if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help || argc != 1) { printf("%s", usage.c_str()); diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index 5c225a2c39..140d2ffc2c 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -192,6 +192,7 @@ rtc_source_set("rtc_event") { rtc_source_set("logging") { visibility = [ "*" ] + libs = [] deps = [ ":criticalsection", ":macromagic", @@ -222,6 +223,10 @@ rtc_source_set("logging") { # logging.h needs the deprecation header while downstream projects are # removing code that depends on logging implementation details. deps += [ ":deprecation" ] + + if (is_android) { + libs += [ "log" ] + } } } @@ -248,6 +253,7 @@ rtc_source_set("atomicops") { rtc_source_set("checks") { # TODO(bugs.webrtc.org/9607): This should not be public. visibility = [ "*" ] + libs = [] sources = [ "checks.cc", "checks.h", @@ -256,6 +262,9 @@ rtc_source_set("checks") { ":safe_compare", "system:inline", ] + if (is_android) { + libs += [ "log" ] + } } rtc_source_set("rate_limiter") { @@ -1083,7 +1092,6 @@ if (rtc_include_tests) { "../system_wrappers:field_trial", "../system_wrappers:metrics", "../test:field_trial", - "../test:fileutils", "../test:test_support", ] diff --git a/rtc_base/unittest_main.cc b/rtc_base/unittest_main.cc index 8d4ff2df2d..12543a357c 100644 --- a/rtc_base/unittest_main.cc +++ b/rtc_base/unittest_main.cc @@ -22,7 +22,6 @@ #include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" #include "test/field_trial.h" -#include "test/testsupport/fileutils.h" #if defined(WEBRTC_WIN) #include "rtc_base/win32socketinit.h" @@ -81,7 +80,6 @@ int main(int argc, char* argv[]) { return 0; } - webrtc::test::SetExecutablePath(argv[0]); webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials); // InitFieldTrialsFromString stores the char*, so the char array must outlive // the application. diff --git a/rtc_tools/event_log_visualizer/main.cc b/rtc_tools/event_log_visualizer/main.cc index 0c3689c1bc..2a52d064bb 100644 --- a/rtc_tools/event_log_visualizer/main.cc +++ b/rtc_tools/event_log_visualizer/main.cc @@ -218,7 +218,6 @@ int main(int argc, char* argv[]) { return 0; } - webrtc::test::SetExecutablePath(argv[0]); webrtc::test::ValidateFieldTrialsStringOrDie(FLAG_force_fieldtrials); // InitFieldTrialsFromString stores the char*, so the char array must outlive // the application. diff --git a/test/BUILD.gn b/test/BUILD.gn index 666e3c08a4..a393448671 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -208,12 +208,17 @@ if (rtc_include_tests) { ] deps = [ ":field_trial", - ":fileutils", ":perf_test", "../rtc_base:rtc_base", "../system_wrappers:field_trial", "../system_wrappers:metrics", "//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", ] } diff --git a/test/test_main.cc b/test/test_main.cc index c8d0b1b584..ec32f2d383 100644 --- a/test/test_main.cc +++ b/test/test_main.cc @@ -86,7 +86,13 @@ int main(int argc, char* argv[]) { 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); // InitFieldTrialsFromString stores the char*, so the char array must outlive // the application. diff --git a/test/testsupport/fileutils.cc b/test/testsupport/fileutils.cc index cb88472e42..ba1e793510 100644 --- a/test/testsupport/fileutils.cc +++ b/test/testsupport/fileutils.cc @@ -81,9 +81,6 @@ const char* kAndroidChromiumTestsRoot = "/sdcard/chromium_tests_root/"; const char* kResourcesDirName = "resources"; #endif -char relative_dir_path[FILENAME_MAX]; -bool relative_dir_path_set = false; - } // namespace 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)); } -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) { struct stat 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) return IOSResourcePath(name, extension); #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 = 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; -#endif // defined (WEBRTC_IOS) +#endif } std::string JoinFilename(const std::string& dir, const std::string& name) { diff --git a/test/testsupport/fileutils.h b/test/testsupport/fileutils.h index 5ff019600e..693944e2ae 100644 --- a/test/testsupport/fileutils.h +++ b/test/testsupport/fileutils.h @@ -51,18 +51,8 @@ std::string TempFilename(const std::string& dir, const std::string& prefix); std::string GenerateTempFilename(const std::string& dir, const std::string& prefix); -// Returns a path to a resource file for the currently executing platform. -// Adapts to what filenames are currently present in the -// [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". +// Returns a path to a resource file in [project-root]/resources/ dir. +// Returns an absolute path // // Arguments: // 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. 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 webrtc