svn commit: samba r26040 - in branches/4.0-python: .
source/lib/registry source/lib/registry/tests
source/libcli/util source/scripting/python/samba source/selftest
jelmer at samba.org
jelmer at samba.org
Mon Nov 19 18:20:56 GMT 2007
Author: jelmer
Date: 2007-11-19 18:20:55 +0000 (Mon, 19 Nov 2007)
New Revision: 26040
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=26040
Log:
Add registry tests, run python tests when possible.
Added:
branches/4.0-python/source/lib/registry/tests/bindings.py
Modified:
branches/4.0-python/
branches/4.0-python/.bzrignore
branches/4.0-python/source/lib/registry/registry.i
branches/4.0-python/source/libcli/util/errors.i
branches/4.0-python/source/scripting/python/samba/provision.py
branches/4.0-python/source/selftest/samba4_tests.sh
Changeset:
Property changes on: branches/4.0-python
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:file-ids
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...
Modified: branches/4.0-python/.bzrignore
===================================================================
--- branches/4.0-python/.bzrignore 2007-11-19 18:20:50 UTC (rev 26039)
+++ branches/4.0-python/.bzrignore 2007-11-19 18:20:55 UTC (rev 26040)
@@ -221,3 +221,12 @@
libtalloc.so.*
source/lib/registry/tests/proto.h
source/dsdb/samdb/util.h
+source/auth/credentials/credentials.py
+source/auth/credentials/credentials.py
+source/bin/python/*
+source/lib/registry/registry.py
+source/lib/registry/registry.py
+source/auth/credentials/credentials_wrap.c
+source/lib/registry/registry_wrap.c
+source/lib/ldb/ldb_wrap.c
+source/lib/ldb/ldb.py
Modified: branches/4.0-python/source/lib/registry/registry.i
===================================================================
--- branches/4.0-python/source/lib/registry/registry.i 2007-11-19 18:20:50 UTC (rev 26039)
+++ branches/4.0-python/source/lib/registry/registry.i 2007-11-19 18:20:55 UTC (rev 26040)
@@ -60,6 +60,33 @@
struct auth_session_info *session_info,
struct cli_credentials *credentials);
+%typemap(in) const char ** {
+ /* Check if is a list */
+ if (PyList_Check($input)) {
+ int size = PyList_Size($input);
+ int i = 0;
+ $1 = (char **) malloc((size+1)*sizeof(const char *));
+ for (i = 0; i < size; i++) {
+ PyObject *o = PyList_GetItem($input,i);
+ if (PyString_Check(o))
+ $1[i] = PyString_AsString(PyList_GetItem($input,i));
+ else {
+ PyErr_SetString(PyExc_TypeError,"list must contain strings");
+ free($1);
+ return NULL;
+ }
+ }
+ $1[i] = 0;
+ } else {
+ PyErr_SetString(PyExc_TypeError,"not a list");
+ return NULL;
+ }
+}
+
+%typemap(freearg) const char ** {
+ free((char **) $1);
+}
+
typedef struct registry_context {
%extend {
@@ -67,19 +94,19 @@
WERROR get_predefined_key_by_name(const char *name,
struct registry_key **key);
- WERROR get_predefined_key(uint32_t hkey, struct registry_key **key);
+ WERROR get_predefined_key(uint32_t hkey_id, struct registry_key **key);
WERROR apply_patchfile(const char *filename)
{
return reg_diff_apply(filename, $self);
}
- WERROR mount_hive(struct hive_key *hive_key, uint32_t key_id,
+ WERROR mount_hive(struct hive_key *hive_key, uint32_t hkey_id,
const char **elements=NULL);
}
%pythoncode {
- def mount(self, path, key_id, elements=[]):
- self.mount_hive(Hive(path), key_id, elements)
+ def mount(self, path, hkey_id, elements=[]):
+ self.mount_hive(Hive(path), hkey_id, elements)
}
} reg;
Added: branches/4.0-python/source/lib/registry/tests/bindings.py
===================================================================
--- branches/4.0-python/source/lib/registry/tests/bindings.py 2007-11-19 18:20:50 UTC (rev 26039)
+++ branches/4.0-python/source/lib/registry/tests/bindings.py 2007-11-19 18:20:55 UTC (rev 26040)
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+
+# Unix SMB/CIFS implementation.
+# Copyright (C) Jelmer Vernooij <jelmer at samba.org> 2007
+#
+# 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/>.
+#
+
+import unittest
+import registry
+
+class HelperTests(unittest.TestCase):
+ def test_predef_to_name(self):
+ self.assertEquals("HKEY_LOCAL_MACHINE",
+ registry.reg_get_predef_name(0x80000002))
+
+ def test_str_regtype(self):
+ self.assertEquals("REG_DWORD", registry.str_regtype(4))
+
+
+class RegistryTests(unittest.TestCase):
+ def test_new(self):
+ self.registry = registry.Registry()
Modified: branches/4.0-python/source/libcli/util/errors.i
===================================================================
--- branches/4.0-python/source/libcli/util/errors.i 2007-11-19 18:20:50 UTC (rev 26039)
+++ branches/4.0-python/source/libcli/util/errors.i 2007-11-19 18:20:55 UTC (rev 26040)
@@ -22,6 +22,8 @@
if (!W_ERROR_IS_OK($1)) {
PyObject *obj = Py_BuildValue("(i,s)", $1.v, win_errstr($1));
PyErr_SetObject(PyExc_RuntimeError, obj);
+ } else if ($result == NULL) {
+ $result = Py_None;
}
};
@@ -29,6 +31,8 @@
if (NT_STATUS_IS_ERR($1)) {
PyObject *obj = Py_BuildValue("(i,s)", $1.v, nt_errstr($1));
PyErr_SetObject(PyExc_RuntimeError, obj);
+ } else if ($result == NULL) {
+ $result = Py_None;
}
};
Modified: branches/4.0-python/source/scripting/python/samba/provision.py
===================================================================
--- branches/4.0-python/source/scripting/python/samba/provision.py 2007-11-19 18:20:50 UTC (rev 26039)
+++ branches/4.0-python/source/scripting/python/samba/provision.py 2007-11-19 18:20:55 UTC (rev 26040)
@@ -467,7 +467,7 @@
message("Setting up registry")
import registry
reg = registry.Registry()
- reg.mount(paths.hklm, registry.HKEY_LOCAL_MACHINE)
+ reg.mount(paths.hklm, registry.HKEY_LOCAL_MACHINE, [])
reg.apply_patchfile(os.path.join(setup_dir, "provision.reg"))
message("Setting up templates into %s" % paths.templates)
Modified: branches/4.0-python/source/selftest/samba4_tests.sh
===================================================================
--- branches/4.0-python/source/selftest/samba4_tests.sh 2007-11-19 18:20:50 UTC (rev 26039)
+++ branches/4.0-python/source/selftest/samba4_tests.sh 2007-11-19 18:20:55 UTC (rev 26040)
@@ -283,6 +283,15 @@
# export PYTHONPATH=lib/tdb/swig:lib/ldb/swig:scripting/swig:$PYTHONPATH
# export LD_LIBRARY_PATH=bin:$LD_LIBRARY_PATH
+# if trial is available, run the python tests:
+if which trial 2>/dev/null >/dev/null
+then
+ plantest "ldb.python" none PYTHONPATH=bin/python trial lib/ldb/tests/python/api.py
+ plantest "credentials.python" none PYTHONPATH=bin/python trial auth/credentials/tests/bindings.py
+ #plantest "tdb.python" none PYTHONPATH=bin/python trial lib/tdb/python/tests/simple.py
+ plantest "registry.python" none PYTHONPATH=bin/python trial lib/registry/tests/bindings.py
+fi
+
# plantest "tdb wrappers" scripting/swig/torture/torture_tdb.py
# plantest "ldb wrappers" scripting/swig/torture/torture_ldb.py
More information about the samba-cvs
mailing list