dl: Add support for dlopen
Change-Id: I3fd109860a1eb0a945ddc3a0376ade248a4b2f75
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/dl.cpp b/test/dl.cpp
new file mode 100644
index 0000000..cc16293
--- /dev/null
+++ b/test/dl.cpp
@@ -0,0 +1,21 @@
+#include <gtest/gtest.h>
+#include <stdplus/dl.hpp>
+
+namespace stdplus
+{
+
+TEST(Dl, FailedOpen)
+{
+ EXPECT_THROW(Dl("nodl.so", DlOpenFlags(DlOpenType::Now)),
+ std::runtime_error);
+}
+
+TEST(Dl, GetLinkMap)
+{
+ Dl dl(nullptr, DlOpenFlags(DlOpenType::Now)
+ .set(DlOpenFlag::Global)
+ .set(DlOpenFlag::NoLoad));
+ EXPECT_NE(nullptr, dl.linkMap());
+}
+
+} // namespace stdplus
diff --git a/test/meson.build b/test/meson.build
index b303032..7d26297 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -29,6 +29,16 @@
'util/string',
]
+if has_dl
+ gtests += [
+ 'dl',
+ ]
+elif build_tests.enabled()
+ error('Not testing libdl feature')
+else
+ warning('Not testing libdl feature')
+endif
+
if has_fd
gtests += [
'fd/dupable',