BIND 10 trac1292_2, updated. 4464612807e6c4bd120298ca105b0503af0d3110 [1292_2] address review comments
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Nov 30 17:47:38 UTC 2011
The branch, trac1292_2 has been updated
via 4464612807e6c4bd120298ca105b0503af0d3110 (commit)
from ada65c7115b9840f509f2b0c640368735fe69520 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 4464612807e6c4bd120298ca105b0503af0d3110
Author: Jelte Jansen <jelte at isc.org>
Date: Wed Nov 30 18:47:28 2011 +0100
[1292_2] address review comments
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/datasrc_config.h.pre.in | 8 ++++----
src/lib/datasrc/factory.cc | 13 ++++++++-----
src/lib/datasrc/factory.h | 4 +++-
src/lib/datasrc/tests/factory_unittest.cc | 26 +++++++++++++-------------
4 files changed, 28 insertions(+), 23 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/datasrc_config.h.pre.in b/src/lib/datasrc/datasrc_config.h.pre.in
index a11218c..ff99601 100644
--- a/src/lib/datasrc/datasrc_config.h.pre.in
+++ b/src/lib/datasrc/datasrc_config.h.pre.in
@@ -17,13 +17,13 @@
namespace isc {
namespace datasrc {
-/// \brief Default directory to find the loadable data source modules
+/// \brief Default directory to find the loadable data source libraries
///
-/// This is the directory where, once installed, modules such as
-/// memory_ds.so and sqlite3_ds.so are found. It is used by the
+/// This is the directory where, once installed, loadable backend libraries
+/// such as memory_ds.so and sqlite3_ds.so are found. It is used by the
/// DataSourceClient loader if no absolute path is used and
/// B10_FROM_BUILD is not set in the environment.
-const char* const MODULE_PATH = "@@PKGLIBEXECDIR@@/";
+const char* const BACKEND_LIBRARY_PATH = "@@PKGLIBEXECDIR@@/";
} // end namespace datasrc
} // end namespace isc
diff --git a/src/lib/datasrc/factory.cc b/src/lib/datasrc/factory.cc
index 64dd221..ddb9493 100644
--- a/src/lib/datasrc/factory.cc
+++ b/src/lib/datasrc/factory.cc
@@ -44,22 +44,22 @@ getDataSourceLibFile(const std::string& type) {
}
// Type can be either a short name, in which case we need to
- // append "_ds.so", or it can be a direct .so module.
+ // append "_ds.so", or it can be a direct .so library.
std::string lib_file = type;
const int ext_pos = lib_file.rfind(".so");
if (ext_pos == std::string::npos || ext_pos + 3 != lib_file.length()) {
lib_file.append("_ds.so");
}
// And if it is not an absolute path, prepend it with our
- // module path
+ // loadable backend library path
if (type[0] != '/') {
// When running from the build tree, we do NOT want
- // to load the installed module
+ // to load the installed loadable library
if (getenv("B10_FROM_BUILD") != NULL) {
lib_file = std::string(getenv("B10_FROM_BUILD")) +
"/src/lib/datasrc/.libs/" + lib_file;
} else {
- lib_file = isc::datasrc::MODULE_PATH + lib_file;
+ lib_file = isc::datasrc::BACKEND_LIBRARY_PATH + lib_file;
}
}
return (lib_file);
@@ -74,7 +74,10 @@ LibraryContainer::LibraryContainer(const std::string& name) {
// are recognized as such
ds_lib_ = dlopen(name.c_str(), RTLD_NOW | RTLD_GLOBAL);
if (ds_lib_ == NULL) {
- isc_throw(DataSourceLibraryError, dlerror());
+ // This may cause the filename to appear twice in the actual
+ // error, but the output of dlerror is implementation-dependent
+ isc_throw(DataSourceLibraryError, "dlopen failed for " << name <<
+ ": " << dlerror());
}
}
diff --git a/src/lib/datasrc/factory.h b/src/lib/datasrc/factory.h
index 2777ad2..fc0a8e6 100644
--- a/src/lib/datasrc/factory.h
+++ b/src/lib/datasrc/factory.h
@@ -119,7 +119,9 @@ private:
/// with '.so', the loader will not add '_ds.so'.
/// It may also be an absolute path; if it starts with '/', nothing is
/// prepended. If it does not, the loadable library will be taken from the
-/// libexec/backends/ installation directory.
+/// installation directory, see the value of
+/// isc::datasrc::BACKEND_LIBRARY_PATH in datasrc_config.h for the exact path.
+///
/// \note When 'B10_FROM_BUILD' is set in the environment, the build
/// directory is used instead of the install directory.
///
diff --git a/src/lib/datasrc/tests/factory_unittest.cc b/src/lib/datasrc/tests/factory_unittest.cc
index 0f00411..51407f9 100644
--- a/src/lib/datasrc/tests/factory_unittest.cc
+++ b/src/lib/datasrc/tests/factory_unittest.cc
@@ -30,41 +30,41 @@ std::string SQLITE_DBFILE_EXAMPLE_ORG = TEST_DATA_DIR "/example.org.sqlite3";
namespace {
+// note this helper only checks the error that is received up to the length
+// of the expected string. It will always pass if you give it an empty
+// expected_error
void
-pathtest_helper(const std::string& file, const std::string& expected_error) {
+pathtestHelper(const std::string& file, const std::string& expected_error) {
std::string error;
try {
DataSourceClientContainer(file, ElementPtr());
} catch (const DataSourceLibraryError& dsle) {
error = dsle.what();
}
- EXPECT_EQ(expected_error, error);
+ EXPECT_EQ(expected_error, error.substr(0, expected_error.size()));
}
TEST(FactoryTest, paths) {
// Test whether the paths are made absolute if they are not,
// by inspecting the error that is raised when they are wrong
- const std::string error(": cannot open shared object file: "
- "No such file or directory");
+ const std::string error("dlopen failed for ");
// With the current implementation, we can safely assume this has
// been set for this test (as the loader would otherwise also fail
- // unless the module happens to be installed)
+ // unless the loadable backend library happens to be installed)
const std::string builddir(getenv("B10_FROM_BUILD"));
// Absolute and ending with .so should have no change
- pathtest_helper("/no_such_file.so", "/no_such_file.so" + error);
+ pathtestHelper("/no_such_file.so", error + "/no_such_file.so");
// If no ending in .so, it should get _ds.so
- pathtest_helper("/no_such_file", "/no_such_file_ds.so" + error);
+ pathtestHelper("/no_such_file", error + "/no_such_file_ds.so");
// If not starting with /, path should be added. For this test that
// means the build directory as set in B10_FROM_BUILD
- pathtest_helper("no_such_file.so",
- builddir + "/src/lib/datasrc/.libs/no_such_file.so" +
- error);
- pathtest_helper("no_such_file",
- builddir + "/src/lib/datasrc/.libs/no_such_file_ds.so" +
- error);
+ pathtestHelper("no_such_file.so", error + builddir +
+ "/src/lib/datasrc/.libs/no_such_file.so");
+ pathtestHelper("no_such_file", error + builddir +
+ "/src/lib/datasrc/.libs/no_such_file_ds.so");
}
TEST(FactoryTest, sqlite3ClientBadConfig) {
More information about the bind10-changes
mailing list