xref: /aosp_15_r20/external/webrtc/test/testsupport/file_utils_override.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef TEST_TESTSUPPORT_FILE_UTILS_OVERRIDE_H_
12 #define TEST_TESTSUPPORT_FILE_UTILS_OVERRIDE_H_
13 
14 #include <string>
15 
16 #include "absl/strings/string_view.h"
17 
18 namespace webrtc {
19 namespace test {
20 namespace internal {
21 
22 // Returns the absolute path to the output directory where log files and other
23 // test artifacts should be put. The output directory is generally a directory
24 // named "out" at the project root. This root is assumed to be two levels above
25 // where the test binary is located; this is because tests execute in a dir
26 // out/Whatever relative to the project root. This convention is also followed
27 // in Chromium.
28 //
29 // The exception is Android where we use /sdcard/ instead.
30 //
31 // If symbolic links occur in the path they will be resolved and the actual
32 // directory will be returned.
33 //
34 // Returns the path WITH a trailing path delimiter. If the project root is not
35 // found, the current working directory ("./") is returned as a fallback.
36 std::string OutputPath();
37 
38 // Gets the current working directory for the executing program.
39 // Returns "./" if for some reason it is not possible to find the working
40 // directory.
41 std::string WorkingDir();
42 
43 // Returns a full path to a resource file in the resources_dir dir.
44 //
45 // Arguments:
46 //    name - Name of the resource file. If a plain filename (no directory path)
47 //           is supplied, the file is assumed to be located in resources/
48 //           If a directory path is prepended to the filename, a subdirectory
49 //           hierarchy reflecting that path is assumed to be present.
50 //    extension - File extension, without the dot, i.e. "bmp" or "yuv".
51 std::string ResourcePath(absl::string_view name, absl::string_view extension);
52 
53 }  // namespace internal
54 }  // namespace test
55 }  // namespace webrtc
56 
57 #endif  // TEST_TESTSUPPORT_FILE_UTILS_OVERRIDE_H_
58