comparison unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp @ 148:63bd29f05246

merged
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 14 Aug 2019 19:46:37 +0900
parents c2174574ed3a
children
comparison
equal deleted inserted replaced
146:3fc4d5c3e21e 148:63bd29f05246
1 //===- llvm/unittest/Support/DynamicLibrary/DynamicLibraryTest.cpp --------===// 1 //===- llvm/unittest/Support/DynamicLibrary/DynamicLibraryTest.cpp --------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // 4 // See https://llvm.org/LICENSE.txt for license information.
5 // This file is distributed under the University of Illinois Open Source 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 // License. See LICENSE.TXT for details.
7 // 6 //
8 //===----------------------------------------------------------------------===// 7 //===----------------------------------------------------------------------===//
9 8
10 #include "llvm/Support/DynamicLibrary.h" 9 #include "llvm/Support/DynamicLibrary.h"
11 #include "llvm/Config/config.h" 10 #include "llvm/Config/config.h"
18 17
19 using namespace llvm; 18 using namespace llvm;
20 using namespace llvm::sys; 19 using namespace llvm::sys;
21 20
22 std::string LibPath(const std::string Name = "PipSqueak") { 21 std::string LibPath(const std::string Name = "PipSqueak") {
23 const std::vector<testing::internal::string>& Argvs = testing::internal::GetArgvs(); 22 const std::vector<testing::internal::string> &Argvs =
24 const char *Argv0 = Argvs.size() > 0 ? Argvs[0].c_str() : "DynamicLibraryTests"; 23 testing::internal::GetArgvs();
24 const char *Argv0 =
25 Argvs.size() > 0 ? Argvs[0].c_str() : "DynamicLibraryTests";
25 void *Ptr = (void*)(intptr_t)TestA; 26 void *Ptr = (void*)(intptr_t)TestA;
26 std::string Path = fs::getMainExecutable(Argv0, Ptr); 27 std::string Path = fs::getMainExecutable(Argv0, Ptr);
27 llvm::SmallString<256> Buf(path::parent_path(Path)); 28 llvm::SmallString<256> Buf(path::parent_path(Path));
28 path::append(Buf, (Name+".so").c_str()); 29 path::append(Buf, (Name + LTDL_SHLIB_EXT).c_str());
29 return Buf.str(); 30 return Buf.str();
30 } 31 }
31 32
32 #if defined(_WIN32) || (defined(HAVE_DLFCN_H) && defined(HAVE_DLOPEN)) 33 #if defined(_WIN32) || (defined(HAVE_DLFCN_H) && defined(HAVE_DLOPEN))
33 34