The branch, master has been updated
via 09104dc unittests: Fix missing include of signal.h
via 01e89ad python: Fix Python 2.6 compatibility
via 88dc82d tests: Improve tests of samba.registry Python module
via 87154bc python: Port samba.registry module to Python 3 compatible
form
from 3bc8880 ctdb-tests: Add tests for event scripts with multiple '.'s
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 09104dc41758bfee6dea2aebc80de52ac32a3c88
Author: Lumir Balhar <[email protected]>
Date: Wed Oct 11 21:02:24 2017 +0200
unittests: Fix missing include of signal.h
Signed-off-by: Lumir Balhar <[email protected]>
Reviewed-by: Andrew Bartlet <[email protected]>
Reviewed-by: Andreas Schneider <[email protected]>
Autobuild-User(master): Andreas Schneider <[email protected]>
Autobuild-Date(master): Wed Oct 18 14:24:39 CEST 2017 on sn-devel-144
commit 01e89ada251eb8bf0556568604298d56d9b41043
Author: Lumir Balhar <[email protected]>
Date: Wed Oct 11 21:00:29 2017 +0200
python: Fix Python 2.6 compatibility
PyErr_NewExceptionWithDoc() isn't available in Python 2.6 so it can
be used only in higher versions of Python.
Signed-off-by: Lumir Balhar <[email protected]>
Reviewed-by: Andrew Bartlet <[email protected]>
Reviewed-by: Andreas Schneider <[email protected]>
commit 88dc82d1f9d8b415f8bc3dc4272a9c2c12e5ad80
Author: Lumir Balhar <[email protected]>
Date: Wed Oct 11 13:05:01 2017 +0200
tests: Improve tests of samba.registry Python module
Signed-off-by: Lumir Balhar <[email protected]>
Reviewed-by: Andrew Bartlet <[email protected]>
Reviewed-by: Andreas Schneider <[email protected]>
commit 87154bcfa9235a726f9d874e122620c678665434
Author: Lumir Balhar <[email protected]>
Date: Wed Oct 11 12:46:11 2017 +0200
python: Port samba.registry module to Python 3 compatible form
Signed-off-by: Lumir Balhar <[email protected]>
Reviewed-by: Andrew Bartlet <[email protected]>
Reviewed-by: Andreas Schneider <[email protected]>
-----------------------------------------------------------------------
Summary of changes:
lib/pam_wrapper/python/pypamtest.c | 9 +++++++++
python/samba/tests/registry.py | 25 ++++++++++++++++++-----
selftest/tests.py | 2 +-
source4/lib/registry/pyregistry.c | 31 +++++++++++++++++++----------
source4/lib/registry/wscript_build | 16 ++++++++-------
testsuite/unittests/rpc_test_dummy_module.c | 1 +
6 files changed, 60 insertions(+), 24 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/pam_wrapper/python/pypamtest.c
b/lib/pam_wrapper/python/pypamtest.c
index 585f27d..a71fd35 100644
--- a/lib/pam_wrapper/python/pypamtest.c
+++ b/lib/pam_wrapper/python/pypamtest.c
@@ -1004,12 +1004,14 @@ static struct PyModuleDef pypamtestdef = {
*** Initialize the module
**********************************************************/
+#if PY_VERSION_HEX >= 0x02070000 /* >= 2.7.0 */
PyDoc_STRVAR(PamTestError__doc__,
"pypamtest specific exception\n\n"
"This exception is raised if the _pamtest() function fails. If _pamtest() "
"returns PAMTEST_ERR_CASE (a test case returns unexpected error code), then "
"the exception also details which test case failed."
);
+#endif
#if IS_PYTHON3
PyMODINIT_FUNC PyInit_pypamtest(void)
@@ -1034,10 +1036,17 @@ PyMODINIT_FUNC initpypamtest(void)
pypamtest_module_methods);
#endif
+#if PY_VERSION_HEX >= 0x02070000 /* >= 2.7.0 */
PyExc_PamTestError = PyErr_NewExceptionWithDoc(discard_const_p(char,
"pypamtest.PamTestError"),
PamTestError__doc__,
PyExc_EnvironmentError,
NULL);
+#else /* < 2.7.0 */
+ PyExc_PamTestError = PyErr_NewException(discard_const_p(char,
"pypamtest.PamTestError"),
+ PyExc_EnvironmentError,
+ NULL);
+#endif
+
if (PyExc_PamTestError == NULL) {
RETURN_ON_ERROR;
}
diff --git a/python/samba/tests/registry.py b/python/samba/tests/registry.py
index 8016a0b..1a8a126 100644
--- a/python/samba/tests/registry.py
+++ b/python/samba/tests/registry.py
@@ -20,6 +20,9 @@
import os
from samba import registry
import samba.tests
+from samba import WERRORError
+from subprocess import Popen, PIPE
+
class HelperTests(samba.tests.TestCase):
@@ -31,7 +34,6 @@ class HelperTests(samba.tests.TestCase):
self.assertEquals("REG_DWORD", registry.str_regtype(4))
-
class HiveTests(samba.tests.TestCaseInTempDir):
def setUp(self):
@@ -47,14 +49,27 @@ class HiveTests(samba.tests.TestCaseInTempDir):
def test_ldb_new(self):
self.assertTrue(self.hive is not None)
- #def test_flush(self):
- # self.hive.flush()
+ def test_set_value(self):
+ self.assertIsNone(self.hive.set_value('foo1', 1, 'bar1'))
+
+ def test_flush(self):
+ self.assertIsNone(self.hive.set_value('foo2', 1, 'bar2'))
+ self.assertIsNone(self.hive.flush())
+
+ proc = Popen(['bin/tdbdump', self.hive_path], stdout=PIPE, stderr=PIPE)
+ tdb_dump, err = proc.communicate()
+ self.assertTrue(b'DN=VALUE=FOO2,HIVE=NONE' in tdb_dump)
+
+ def test_del_value(self):
+ self.assertIsNone(self.hive.set_value('foo3', 1, 'bar3'))
+ self.assertIsNone(self.hive.del_value('foo3'))
- #def test_del_value(self):
- # self.hive.del_value("FOO")
+ def test_del_nonexisting_value(self):
+ self.assertRaises(WERRORError, self.hive.del_value, 'foo4')
class RegistryTests(samba.tests.TestCase):
def test_new(self):
self.registry = registry.Registry()
+ self.assertIsNotNone(self.registry)
diff --git a/selftest/tests.py b/selftest/tests.py
index 9d1d9d3..3e3ef84 100644
--- a/selftest/tests.py
+++ b/selftest/tests.py
@@ -55,7 +55,7 @@ else:
planpythontestsuite("none", "samba.tests.blackbox.ndrdump")
planpythontestsuite("none", "api", name="ldb.python",
extra_path=['lib/ldb/tests/python'])
planpythontestsuite("none", "samba.tests.credentials", py3_compatible=True)
-planpythontestsuite("none", "samba.tests.registry")
+planpythontestsuite("none", "samba.tests.registry", py3_compatible=True)
planpythontestsuite("none", "samba.tests.auth", py3_compatible=True)
planpythontestsuite("none", "samba.tests.get_opt", py3_compatible=True)
planpythontestsuite("none", "samba.tests.security", py3_compatible=True)
diff --git a/source4/lib/registry/pyregistry.c
b/source4/lib/registry/pyregistry.c
index 78a0b1d..f36973f 100644
--- a/source4/lib/registry/pyregistry.c
+++ b/source4/lib/registry/pyregistry.c
@@ -19,6 +19,7 @@
*/
#include <Python.h>
+#include "python/py3compat.h"
#include "includes.h"
#include "libcli/util/pyerrors.h"
#include "lib/registry/registry.h"
@@ -31,8 +32,6 @@ extern PyTypeObject PyRegistryKey;
extern PyTypeObject PyRegistry;
extern PyTypeObject PyHiveKey;
-void initregistry(void);
-
/*#define PyRegistryKey_AsRegistryKey(obj) pytalloc_get_type(obj, struct
registry_key)*/
#define PyRegistry_AsRegistryContext(obj) ((struct registry_context
*)pytalloc_get_ptr(obj))
#define PyHiveKey_AsHiveKey(obj) ((struct hive_key*)pytalloc_get_ptr(obj))
@@ -121,7 +120,7 @@ static PyObject *py_mount_hive(PyObject *self, PyObject
*args)
int i;
elements = talloc_array(NULL, const char *,
PyList_Size(py_elements));
for (i = 0; i < PyList_Size(py_elements); i++)
- elements[i] =
PyString_AsString(PyList_GetItem(py_elements, i));
+ elements[i] =
PyStr_AsString(PyList_GetItem(py_elements, i));
}
SMB_ASSERT(ctx != NULL);
@@ -412,7 +411,7 @@ static PyObject *py_str_regtype(PyObject *self, PyObject
*args)
if (!PyArg_ParseTuple(args, "i", ®type))
return NULL;
- return PyString_FromString(str_regtype(regtype));
+ return PyStr_FromString(str_regtype(regtype));
}
static PyObject *py_get_predef_name(PyObject *self, PyObject *args)
@@ -426,7 +425,7 @@ static PyObject *py_get_predef_name(PyObject *self,
PyObject *args)
str = reg_get_predef_name(hkey);
if (str == NULL)
Py_RETURN_NONE;
- return PyString_FromString(str);
+ return PyStr_FromString(str);
}
static PyMethodDef py_registry_methods[] = {
@@ -438,22 +437,30 @@ static PyMethodDef py_registry_methods[] = {
{ NULL }
};
-void initregistry(void)
+static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ .m_name = "registry",
+ .m_doc = "Registry",
+ .m_size = -1,
+ .m_methods = py_registry_methods,
+};
+
+MODULE_INIT_FUNC(registry)
{
PyObject *m;
if (pytalloc_BaseObject_PyType_Ready(&PyHiveKey) < 0)
- return;
+ return NULL;
if (pytalloc_BaseObject_PyType_Ready(&PyRegistry) < 0)
- return;
+ return NULL;
if (pytalloc_BaseObject_PyType_Ready(&PyRegistryKey) < 0)
- return;
+ return NULL;
- m = Py_InitModule3("registry", py_registry_methods, "Registry");
+ m = PyModule_Create(&moduledef);
if (m == NULL)
- return;
+ return NULL;
PyModule_AddObject(m, "HKEY_CLASSES_ROOT",
PyInt_FromLong(HKEY_CLASSES_ROOT));
PyModule_AddObject(m, "HKEY_CURRENT_USER",
PyInt_FromLong(HKEY_CURRENT_USER));
@@ -473,4 +480,6 @@ void initregistry(void)
Py_INCREF(&PyRegistryKey);
PyModule_AddObject(m, "RegistryKey", (PyObject *)&PyRegistryKey);
+
+ return m;
}
diff --git a/source4/lib/registry/wscript_build
b/source4/lib/registry/wscript_build
index c558b22..06508fb 100644
--- a/source4/lib/registry/wscript_build
+++ b/source4/lib/registry/wscript_build
@@ -59,10 +59,12 @@ bld.SAMBA_SUBSYSTEM('torture_registry',
deps='torture registry'
)
-
-bld.SAMBA_PYTHON('py_registry',
- source='pyregistry.c',
- public_deps='registry pytalloc-util pyparam_util',
- realname='samba/registry.so'
- )
-
+for env in bld.gen_python_environments():
+ pytalloc_util = bld.pyembed_libname('pytalloc-util')
+ pyparam_util = bld.pyembed_libname('pyparam_util')
+
+ bld.SAMBA_PYTHON('py_registry',
+ source='pyregistry.c',
+ public_deps='registry %s %s' % (pytalloc_util, pyparam_util),
+ realname='samba/registry.so'
+ )
diff --git a/testsuite/unittests/rpc_test_dummy_module.c
b/testsuite/unittests/rpc_test_dummy_module.c
index 20d0571..2b4e6e2 100644
--- a/testsuite/unittests/rpc_test_dummy_module.c
+++ b/testsuite/unittests/rpc_test_dummy_module.c
@@ -1,5 +1,6 @@
#include "replace.h"
#include <sys/types.h>
+#include <signal.h>
#include <unistd.h>
#include "libcli/util/ntstatus.h"
--
Samba Shared Repository