mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
a5ef8dbacb
As far as I can tell from revision history, there's no good reason to call these files .so instead of .dll in Windows, so use the normal extension. Also change PipSquak from SHARED to MODULE -- it's never passed to target_link_libraries() and only loaded via dlopen(), so MODULE is more appropriate. This makes it possible to delete a workaround for SHARED ldflags being not quite right as well. No intended behavior change. https://reviews.llvm.org/D46898 llvm-svn: 332487
62 lines
1.9 KiB
C++
62 lines
1.9 KiB
C++
//===- unittests/Passes/Plugins/PluginsTest.cpp ---------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/Analysis/CGSCCPassManager.h"
|
|
#include "llvm/Config/config.h"
|
|
#include "llvm/IR/PassManager.h"
|
|
#include "llvm/Passes/PassBuilder.h"
|
|
#include "llvm/Passes/PassPlugin.h"
|
|
#include "llvm/Support/FileSystem.h"
|
|
#include "llvm/Support/ManagedStatic.h"
|
|
#include "llvm/Support/Path.h"
|
|
#include "llvm/Transforms/Scalar/LoopPassManager.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "TestPlugin.h"
|
|
|
|
#include <cstdint>
|
|
|
|
using namespace llvm;
|
|
|
|
void anchor() {}
|
|
|
|
static std::string LibPath(const std::string Name = "TestPlugin") {
|
|
const std::vector<testing::internal::string> &Argvs =
|
|
testing::internal::GetArgvs();
|
|
const char *Argv0 = Argvs.size() > 0 ? Argvs[0].c_str() : "PluginsTests";
|
|
void *Ptr = (void *)(intptr_t)anchor;
|
|
std::string Path = sys::fs::getMainExecutable(Argv0, Ptr);
|
|
llvm::SmallString<256> Buf{sys::path::parent_path(Path)};
|
|
sys::path::append(Buf, (Name + LTDL_SHLIB_EXT).c_str());
|
|
return Buf.str();
|
|
}
|
|
|
|
TEST(PluginsTests, LoadPlugin) {
|
|
#if !defined(LLVM_ENABLE_PLUGINS)
|
|
// Disable the test if plugins are disabled.
|
|
return;
|
|
#endif
|
|
|
|
auto PluginPath = LibPath();
|
|
ASSERT_NE("", PluginPath);
|
|
|
|
Expected<PassPlugin> Plugin = PassPlugin::Load(PluginPath);
|
|
ASSERT_TRUE(!!Plugin) << "Plugin path: " << PluginPath;
|
|
|
|
ASSERT_EQ(TEST_PLUGIN_NAME, Plugin->getPluginName());
|
|
ASSERT_EQ(TEST_PLUGIN_VERSION, Plugin->getPluginVersion());
|
|
|
|
PassBuilder PB;
|
|
ModulePassManager PM;
|
|
ASSERT_FALSE(PB.parsePassPipeline(PM, "plugin-pass"));
|
|
|
|
Plugin->registerPassBuilderCallbacks(PB);
|
|
ASSERT_TRUE(PB.parsePassPipeline(PM, "plugin-pass"));
|
|
}
|