[SCM] Samba Shared Repository - branch master updated
Andrew Bartlett
abartlet at samba.org
Thu Sep 6 01:08:02 MDT 2012
The branch, master has been updated
via baf2db6 selftest: Test configure stage of dlz_bind9
via 52f0ded selftest: Add tests for the dlz_bind9 module
from 0d99175 join.py: Only replicate DNS zones if the source DC had DNS zones
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit baf2db685f1d2bff712d45288abf116f903039ed
Author: Andrew Bartlett <abartlet at samba.org>
Date: Thu Sep 6 15:22:17 2012 +1000
selftest: Test configure stage of dlz_bind9
Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
Autobuild-Date(master): Thu Sep 6 09:07:11 CEST 2012 on sn-devel-104
commit 52f0dedc1a63c75f87adc0f70f10aae2b2bfaf72
Author: Andrew Bartlett <abartlet at samba.org>
Date: Thu Sep 6 14:26:57 2012 +1000
selftest: Add tests for the dlz_bind9 module
This will help ensure that we do not break the fundemental loading etc.
From here, it should be easy to extend this to more comprehensive tests.
Andrew Bartlett
-----------------------------------------------------------------------
Summary of changes:
source4/dns_server/wscript_build | 7 ++
source4/selftest/tests.py | 4 +
source4/torture/dns/dlz_bind9.c | 152 +++++++++++++++++++++++++++++++++++++
source4/torture/dns/wscript_build | 10 +++
source4/torture/wscript_build | 1 +
5 files changed, 174 insertions(+), 0 deletions(-)
create mode 100644 source4/torture/dns/dlz_bind9.c
create mode 100644 source4/torture/dns/wscript_build
Changeset truncated at 500 lines:
diff --git a/source4/dns_server/wscript_build b/source4/dns_server/wscript_build
index b8e2708..280f8de 100644
--- a/source4/dns_server/wscript_build
+++ b/source4/dns_server/wscript_build
@@ -30,3 +30,10 @@ bld.SAMBA_LIBRARY('dlz_bind9_9',
install_path='${MODULESDIR}/bind9',
deps='samba-hostconfig samdb-common gensec popt',
enabled=bld.AD_DC_BUILD_IS_ENABLED())
+
+bld.SAMBA_LIBRARY('dlz_bind9_for_torture',
+ source='dlz_bind9.c',
+ cflags='-DBIND_VERSION_9_8',
+ private_library=True,
+ deps='samba-hostconfig samdb-common gensec popt',
+ enabled=bld.AD_DC_BUILD_IS_ENABLED())
diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py
index b9944cb..fd4b669 100755
--- a/source4/selftest/tests.py
+++ b/source4/selftest/tests.py
@@ -296,6 +296,10 @@ for f in sorted(os.listdir(os.path.join(samba4srcdir, "../pidl/tests"))):
# DNS tests
planpythontestsuite("dc", "samba.tests.dns")
+# Local tests
+for t in smb4torture_testsuites("dlz_bind9."):
+ #The dlz_bind9 tests needs to look at the DNS database
+ plansmbtorturetestsuite(t, "dc:local", "ncalrpc:localhost")
planpythontestsuite("s3dc", "samba.tests.libsmb_samba_internal");
diff --git a/source4/torture/dns/dlz_bind9.c b/source4/torture/dns/dlz_bind9.c
new file mode 100644
index 0000000..d01e506
--- /dev/null
+++ b/source4/torture/dns/dlz_bind9.c
@@ -0,0 +1,152 @@
+/*
+ Unix SMB/CIFS implementation.
+ SMB torture tester
+ Copyright (C) Andrew Bartlett 2012
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "torture/smbtorture.h"
+#include "dlz_minimal.h"
+#include <talloc.h>
+#include <ldb.h>
+#include "lib/param/param.h"
+#include "dsdb/samdb/samdb.h"
+#include "dsdb/common/util.h"
+#include "auth/session.h"
+
+struct torture_context *tctx_static;
+
+static void dlz_bind9_log_wrapper(int level, const char *fmt, ...)
+{
+ va_list ap;
+ char *msg;
+ va_start(ap, fmt);
+ msg = talloc_vasprintf(NULL, fmt, ap);
+ torture_comment(tctx_static, "%s\n", msg);
+ TALLOC_FREE(msg);
+ va_end(ap);
+}
+
+static bool test_dlz_bind9_version(struct torture_context *tctx)
+{
+ unsigned int flags = 0;
+ torture_assert_int_equal(tctx, dlz_version(&flags),
+ DLZ_DLOPEN_VERSION, "got wrong DLZ version");
+ return true;
+}
+
+static bool test_dlz_bind9_create(struct torture_context *tctx)
+{
+ void *dbdata;
+ const char *argv[] = {
+ "samba_dlz",
+ "-H",
+ lpcfg_private_path(tctx, tctx->lp_ctx, "dns/sam.ldb"),
+ NULL
+ };
+ tctx_static = tctx;
+ torture_assert_int_equal(tctx, dlz_create("samba_dlz", 3, argv, &dbdata,
+ "log", dlz_bind9_log_wrapper, NULL), ISC_R_SUCCESS,
+ "Failed to create samba_dlz");
+
+ dlz_destroy(dbdata);
+
+ return true;
+}
+
+static isc_result_t dlz_bind9_writeable_zone_hook(dns_view_t *view,
+ const char *zone_name)
+{
+ struct torture_context *tctx = talloc_get_type((void *)view, struct torture_context);
+ struct ldb_context *samdb = samdb_connect_url(tctx, NULL, tctx->lp_ctx,
+ system_session(tctx->lp_ctx),
+ 0, lpcfg_private_path(tctx, tctx->lp_ctx, "dns/sam.ldb"));
+ struct ldb_message *msg;
+ int ret;
+ const char *attrs[] = {
+ NULL
+ };
+ if (!samdb) {
+ torture_fail(tctx, "Failed to connect to samdb");
+ return ISC_R_FAILURE;
+ }
+
+ ret = dsdb_search_one(samdb, tctx, &msg, NULL,
+ LDB_SCOPE_SUBTREE, attrs, DSDB_SEARCH_SEARCH_ALL_PARTITIONS,
+ "(&(objectClass=dnsZone)(name=%s))", zone_name);
+ if (ret != LDB_SUCCESS) {
+ torture_fail(tctx, talloc_asprintf(tctx, "Failed to search for %s: %s", zone_name, ldb_errstring(samdb)));
+ return ISC_R_FAILURE;
+ }
+ talloc_free(msg);
+
+ return ISC_R_SUCCESS;
+}
+
+static bool test_dlz_bind9_configure(struct torture_context *tctx)
+{
+ void *dbdata;
+ const char *argv[] = {
+ "samba_dlz",
+ "-H",
+ lpcfg_private_path(tctx, tctx->lp_ctx, "dns/sam.ldb"),
+ NULL
+ };
+ tctx_static = tctx;
+ torture_assert_int_equal(tctx, dlz_create("samba_dlz", 3, argv, &dbdata,
+ "log", dlz_bind9_log_wrapper,
+ "writeable_zone", dlz_bind9_writeable_zone_hook, NULL),
+ ISC_R_SUCCESS,
+ "Failed to create samba_dlz");
+
+ torture_assert_int_equal(tctx, dlz_configure((void*)tctx, dbdata),
+ ISC_R_SUCCESS,
+ "Failed to configure samba_dlz");
+
+ dlz_destroy(dbdata);
+
+ return true;
+}
+
+
+
+static struct torture_suite *dlz_bind9_suite(TALLOC_CTX *ctx)
+{
+ struct torture_suite *suite = torture_suite_create(ctx, "dlz_bind9");
+
+ suite->description = talloc_strdup(suite,
+ "Tests for the BIND 9 DLZ module");
+ torture_suite_add_simple_test(suite, "version", test_dlz_bind9_version);
+ torture_suite_add_simple_test(suite, "create", test_dlz_bind9_create);
+ torture_suite_add_simple_test(suite, "configure", test_dlz_bind9_configure);
+ return suite;
+}
+
+/**
+ * DNS torture module initialization
+ */
+NTSTATUS torture_dns_init(void)
+{
+ struct torture_suite *suite;
+ TALLOC_CTX *mem_ctx = talloc_autofree_context();
+
+ /* register DNS related test cases */
+ suite = dlz_bind9_suite(mem_ctx);
+ if (!suite) return NT_STATUS_NO_MEMORY;
+ torture_register_suite(suite);
+
+ return NT_STATUS_OK;
+}
diff --git a/source4/torture/dns/wscript_build b/source4/torture/dns/wscript_build
new file mode 100644
index 0000000..83df02f
--- /dev/null
+++ b/source4/torture/dns/wscript_build
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+
+bld.SAMBA_MODULE('TORTURE_DNS',
+ source='dlz_bind9.c',
+ subsystem='smbtorture',
+ init_function='torture_dns_init',
+ cflags='-DBIND_VERSION_9_8',
+ deps='torture talloc torturemain dlz_bind9_for_torture',
+ internal_module=True
+ )
diff --git a/source4/torture/wscript_build b/source4/torture/wscript_build
index fbed394..a45bf38 100755
--- a/source4/torture/wscript_build
+++ b/source4/torture/wscript_build
@@ -57,6 +57,7 @@ bld.SAMBA_MODULE('torture_rpc',
)
bld.RECURSE('drs')
+bld.RECURSE('dns')
bld.SAMBA_MODULE('TORTURE_RAP',
source='rap/rap.c rap/rpc.c rap/printing.c rap/sam.c',
--
Samba Shared Repository
More information about the samba-cvs
mailing list