BIND 10 trac1292_2, updated. 6690b8985d656aba3f25082cb62c9c02e5ad5a0b [1292_2] add some more tests
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Dec 1 11:14:58 UTC 2011
The branch, trac1292_2 has been updated
via 6690b8985d656aba3f25082cb62c9c02e5ad5a0b (commit)
from 4464612807e6c4bd120298ca105b0503af0d3110 (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 6690b8985d656aba3f25082cb62c9c02e5ad5a0b
Author: Jelte Jansen <jelte at isc.org>
Date: Thu Dec 1 12:14:37 2011 +0100
[1292_2] add some more tests
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/factory.cc | 6 +++++-
src/lib/datasrc/factory.h | 2 +-
src/lib/datasrc/tests/factory_unittest.cc | 28 ++++++++++++++++++++++++++++
3 files changed, 34 insertions(+), 2 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/factory.cc b/src/lib/datasrc/factory.cc
index ddb9493..9c2adab 100644
--- a/src/lib/datasrc/factory.cc
+++ b/src/lib/datasrc/factory.cc
@@ -39,9 +39,13 @@ namespace {
const std::string
getDataSourceLibFile(const std::string& type) {
if (type.empty()) {
- isc_throw(DataSourceError,
+ isc_throw(DataSourceLibraryError,
"DataSourceClient container called with empty type value");
}
+ if (type == ".so") {
+ isc_throw(DataSourceLibraryError, "DataSourceClient container called"
+ "with bad type or file name");
+ }
// Type can be either a short name, in which case we need to
// append "_ds.so", or it can be a direct .so library.
diff --git a/src/lib/datasrc/factory.h b/src/lib/datasrc/factory.h
index fc0a8e6..9d0a762 100644
--- a/src/lib/datasrc/factory.h
+++ b/src/lib/datasrc/factory.h
@@ -68,7 +68,7 @@ public:
/// the library path.
///
/// \exception DataSourceLibraryError If the library cannot be found or
- /// cannot be loaded.
+ /// cannot be loaded, or if name is an empty string.
LibraryContainer(const std::string& name);
/// \brief Destructor
diff --git a/src/lib/datasrc/tests/factory_unittest.cc b/src/lib/datasrc/tests/factory_unittest.cc
index 51407f9..e98f9bc 100644
--- a/src/lib/datasrc/tests/factory_unittest.cc
+++ b/src/lib/datasrc/tests/factory_unittest.cc
@@ -14,6 +14,7 @@
#include <boost/scoped_ptr.hpp>
+#include <datasrc/datasrc_config.h>
#include <datasrc/factory.h>
#include <datasrc/data_source.h>
#include <datasrc/sqlite3_accessor.h>
@@ -41,6 +42,7 @@ pathtestHelper(const std::string& file, const std::string& expected_error) {
} catch (const DataSourceLibraryError& dsle) {
error = dsle.what();
}
+ ASSERT_LT(expected_error.size(), error.size());
EXPECT_EQ(expected_error, error.substr(0, expected_error.size()));
}
@@ -65,6 +67,32 @@ TEST(FactoryTest, paths) {
"/src/lib/datasrc/.libs/no_such_file.so");
pathtestHelper("no_such_file", error + builddir +
"/src/lib/datasrc/.libs/no_such_file_ds.so");
+
+ // Some tests with '.so' in the name itself
+ pathtestHelper("no_such_file.so.something", error + builddir +
+ "/src/lib/datasrc/.libs/no_such_file.so.something_ds.so");
+ pathtestHelper("/no_such_file.so.something", error +
+ "/no_such_file.so.something_ds.so");
+ pathtestHelper("/no_such_file.so.something.so", error +
+ "/no_such_file.so.something.so");
+ pathtestHelper("/no_such_file.so.so", error +
+ "/no_such_file.so.so");
+ pathtestHelper("no_such_file.so.something", error + builddir +
+ "/src/lib/datasrc/.libs/no_such_file.so.something_ds.so");
+
+ // Temporarily unset B10_FROM_BUILD to see that BACKEND_LIBRARY_PATH
+ // is used
+ unsetenv("B10_FROM_BUILD");
+ pathtestHelper("no_such_file.so", error + BACKEND_LIBRARY_PATH +
+ "no_such_file.so");
+ // Put it back just in case
+ setenv("B10_FROM_BUILD", builddir.c_str(), 1);
+
+ // Test some bad input values
+ ASSERT_THROW(DataSourceClientContainer("", ElementPtr()),
+ DataSourceLibraryError);
+ ASSERT_THROW(DataSourceClientContainer(".so", ElementPtr()),
+ DataSourceLibraryError);
}
TEST(FactoryTest, sqlite3ClientBadConfig) {
More information about the bind10-changes
mailing list