[MemProf] Templatize CallStackRadixTreeBuilder (NFC) (#117014)
[llvm-project.git] / lldb / unittests / tools / lldb-server / tests / TestBase.cpp
blobeeb73f0557565ed507153b1adb82d0cfa155c2e7
1 //===-- TestBase.cpp ------------------------------------------------------===//
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-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "TestBase.h"
10 #include <cstdlib>
12 using namespace llgs_tests;
13 using namespace llvm;
15 std::string TestBase::getLogFileName() {
16 const auto *test_info =
17 ::testing::UnitTest::GetInstance()->current_test_info();
18 assert(test_info);
20 const char *Dir = getenv("LOG_FILE_DIRECTORY");
21 if (!Dir)
22 return "";
24 if (!llvm::sys::fs::is_directory(Dir)) {
25 GTEST_LOG_(WARNING) << "Cannot access log directory: " << Dir;
26 return "";
29 SmallString<64> DirStr(Dir);
30 sys::path::append(DirStr, std::string("server-") +
31 test_info->test_case_name() + "-" +
32 test_info->name() + ".log");
33 return std::string(DirStr.str());