7
7
8
8
#include " ../../lib/Interpreter/Paths.h"
9
9
10
- #include " ../../lib/Interpreter/DynamicLibraryManager.h"
11
-
12
10
// This function isn't referenced outside its translation unit, but it
13
11
// can't use the "static" keyword because its address is used for
14
12
// GetMainExecutable (since some platforms don't support taking the
@@ -44,6 +42,17 @@ TEST(DynamicLibraryManagerTest, Sanity) {
44
42
<< " Cannot find: '" << PathToTestSharedLib << " ' in '" << Dir.str ()
45
43
<< " '" ;
46
44
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
+
47
56
EXPECT_TRUE (Cpp::LoadLibrary (PathToTestSharedLib.c_str ()));
48
57
// Force ExecutionEngine to be created.
49
58
Cpp::Process (" " );
@@ -58,20 +67,3 @@ TEST(DynamicLibraryManagerTest, Sanity) {
58
67
// invalidated...
59
68
// EXPECT_FALSE(Cpp::GetFunctionAddress("ret_zero"));
60
69
}
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