xref: /llvm-project/libc/test/UnitTest/BazelFilePath.cpp (revision 5ff3ff33ff930e4ec49da7910612d8a41eb068cb)
1d94fe972SMichael Jones //===-- Implementation of the file path generator for bazel ---------------===//
2d94fe972SMichael Jones //
3d94fe972SMichael Jones // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4d94fe972SMichael Jones // See https://llvm.org/LICENSE.txt for license information.
5d94fe972SMichael Jones // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6d94fe972SMichael Jones //
7d94fe972SMichael Jones //===----------------------------------------------------------------------===//
8d94fe972SMichael Jones 
9d94fe972SMichael Jones #include "LibcTest.h"
10d94fe972SMichael Jones 
11d94fe972SMichael Jones #include <stdlib.h>
12d94fe972SMichael Jones 
13d94fe972SMichael Jones #include "src/__support/CPP/string.h"
14d94fe972SMichael Jones #include "src/__support/c_string.h"
15*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
16d94fe972SMichael Jones 
17*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
18*5ff3ff33SPetr Hosek namespace testing {
19d94fe972SMichael Jones 
20d94fe972SMichael Jones CString libc_make_test_file_path_func(const char *file_name) {
21d94fe972SMichael Jones   // This is the path to the folder bazel wants the test outputs written to.
22d94fe972SMichael Jones   const char *UNDECLARED_OUTPUTS_PATH = getenv("TEST_UNDECLARED_OUTPUTS_DIR");
23d94fe972SMichael Jones 
24d94fe972SMichael Jones   return cpp::string(UNDECLARED_OUTPUTS_PATH) + file_name;
25d94fe972SMichael Jones }
26d94fe972SMichael Jones 
27*5ff3ff33SPetr Hosek } // namespace testing
28*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
29