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}
diff --git a/test/testsupport/fileutils.cc b/test/testsupport/fileutils.cc
index cb88472..ba1e793 100644
--- a/test/testsupport/fileutils.cc
+++ b/test/testsupport/fileutils.cc
@@ -81,9 +81,6 @@
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 @@
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 @@
#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) {