1 //===-- TestBase.cpp --------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "TestBase.h"
11 #include <cstdlib>
12 
13 using namespace llgs_tests;
14 using namespace llvm;
15 
16 std::string TestBase::getLogFileName() {
17   const auto *test_info =
18       ::testing::UnitTest::GetInstance()->current_test_info();
19   assert(test_info);
20 
21   const char *Dir = getenv("LOG_FILE_DIRECTORY");
22   if (!Dir)
23     return "";
24 
25   if (!llvm::sys::fs::is_directory(Dir)) {
26     GTEST_LOG_(WARNING) << "Cannot access log directory: " << Dir;
27     return "";
28   }
29 
30   SmallString<64> DirStr(Dir);
31   sys::path::append(DirStr, std::string("server-") +
32                                 test_info->test_case_name() + "-" +
33                                 test_info->name() + ".log");
34   return DirStr.str();
35 }
36 
37