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 //===----------------------------------------------------------------------===// 8 9 #include "TestBase.h" 10 #include <cstdlib> 11 12 using namespace llgs_tests; 13 using namespace llvm; 14 getLogFileName()15std::string TestBase::getLogFileName() { 16 const auto *test_info = 17 ::testing::UnitTest::GetInstance()->current_test_info(); 18 assert(test_info); 19 20 const char *Dir = getenv("LOG_FILE_DIRECTORY"); 21 if (!Dir) 22 return ""; 23 24 if (!llvm::sys::fs::is_directory(Dir)) { 25 GTEST_LOG_(WARNING) << "Cannot access log directory: " << Dir; 26 return ""; 27 } 28 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()); 34 } 35 36