brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 7f9f42b Raw
33 lines · cpp
1//===-- Implementation of the file path generator for bazel ---------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "LibcTest.h"10 11#include <stdlib.h>12 13#include "src/__support/CPP/string.h"14#include "src/__support/c_string.h"15#include "src/__support/macros/config.h"16 17namespace LIBC_NAMESPACE_DECL {18namespace testing {19 20CString libc_make_test_file_path_func(const char *file_name) {21  // This is the path to the folder bazel wants the test outputs written to.22  const char *UNDECLARED_OUTPUTS_PATH = getenv("TEST_UNDECLARED_OUTPUTS_DIR");23  // Do something sensible if not run under bazel, otherwise this may segfault24  // when constructing the string.25  if (UNDECLARED_OUTPUTS_PATH == nullptr)26    UNDECLARED_OUTPUTS_PATH = "";27 28  return cpp::string(UNDECLARED_OUTPUTS_PATH) + file_name;29}30 31} // namespace testing32} // namespace LIBC_NAMESPACE_DECL33