Skip to content

Commit 01fb500

Browse files
committed
Move the libtestsharedlib to a more convenient place
Signed-off-by: Shreyas Atre <[email protected]>
1 parent 9a693a6 commit 01fb500

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

unittests/CppInterOp/DynamicLibraryManagerTest.cpp

+11-19
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
#include "../../lib/Interpreter/Paths.h"
99

10-
#include "../../lib/Interpreter/DynamicLibraryManager.h"
11-
1210
// This function isn't referenced outside its translation unit, but it
1311
// can't use the "static" keyword because its address is used for
1412
// GetMainExecutable (since some platforms don't support taking the
@@ -44,6 +42,17 @@ TEST(DynamicLibraryManagerTest, Sanity) {
4442
<< "Cannot find: '" << PathToTestSharedLib << "' in '" << Dir.str()
4543
<< "'";
4644

45+
// DLOPEN DLCLOSE Test
46+
std::string err = "";
47+
auto* dlopen_handle = Cpp::utils::platform::DLOpen(PathToTestSharedLib, err);
48+
EXPECT_TRUE(dlopen_handle) << "Error occurred: " << err << "\n";
49+
Cpp::utils::platform::DLClose(dlopen_handle, err);
50+
EXPECT_TRUE(err.empty()) << "Error occurred: " << err << "\n";
51+
Cpp::utils::platform::DLOpen("missing", err);
52+
EXPECT_TRUE(err.find("no such file") != std::string::npos ||
53+
err.find("No such file") != std::string::npos);
54+
// DLOPEN DLCLOSE Test end
55+
4756
EXPECT_TRUE(Cpp::LoadLibrary(PathToTestSharedLib.c_str()));
4857
// Force ExecutionEngine to be created.
4958
Cpp::Process("");
@@ -58,20 +67,3 @@ TEST(DynamicLibraryManagerTest, Sanity) {
5867
// invalidated...
5968
// EXPECT_FALSE(Cpp::GetFunctionAddress("ret_zero"));
6069
}
61-
62-
TEST(UtilsPlatform, DLTest) {
63-
std::string err = "";
64-
std::string BinaryPath = GetExecutablePath(/*Argv0=*/nullptr);
65-
llvm::StringRef Dir = llvm::sys::path::parent_path(BinaryPath);
66-
Cpp::AddSearchPath(Dir.str().c_str());
67-
std::string path =
68-
(new Cpp::DynamicLibraryManager)->lookupLibrary("libTestSharedLib");
69-
EXPECT_FALSE(path.empty());
70-
std::cout<<path<<"\n";
71-
auto dlopen_handle = Cpp::utils::platform::DLOpen(path, err);
72-
EXPECT_TRUE(dlopen_handle);
73-
EXPECT_TRUE(err.empty());
74-
Cpp::utils::platform::DLOpen("missing", err);
75-
EXPECT_TRUE(err.find("no such file") != std::string::npos ||
76-
err.find("No such file") != std::string::npos);
77-
}

0 commit comments

Comments
 (0)