diff options
author | Volker Lendecke <vl@samba.org> | 2012-08-15 14:08:45 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2012-08-16 22:49:06 +0200 |
commit | f3b69da2aeb637398b0670cfb4a29379a8000d91 (patch) | |
tree | 3cfbba3e04d3132ecf58a41e86c96627eee7cd60 | |
parent | fbebd7530ed365ac6a7c7ae004975850b4f4d162 (diff) | |
download | samba-f3b69da2aeb637398b0670cfb4a29379a8000d91.tar.gz samba-f3b69da2aeb637398b0670cfb4a29379a8000d91.tar.bz2 samba-f3b69da2aeb637398b0670cfb4a29379a8000d91.zip |
s3-libsmb: Add a simple test for python bindings
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Aug 16 22:49:06 CEST 2012 on sn-devel-104
-rw-r--r-- | source4/scripting/python/samba/tests/libsmb_samba_internal.py | 78 | ||||
-rwxr-xr-x | source4/selftest/tests.py | 2 |
2 files changed, 80 insertions, 0 deletions
diff --git a/source4/scripting/python/samba/tests/libsmb_samba_internal.py b/source4/scripting/python/samba/tests/libsmb_samba_internal.py new file mode 100644 index 0000000000..fe9f197a2c --- /dev/null +++ b/source4/scripting/python/samba/tests/libsmb_samba_internal.py @@ -0,0 +1,78 @@ +# Unix SMB/CIFS implementation. +# Copyright Volker Lendecke <vl@samba.org> 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/>. +# + +"""Tests for samba.samba3.libsmb_samba_internal.""" + +from samba.samba3 import libsmb_samba_internal +from samba.dcerpc import security +from samba.samba3 import param as s3param +from samba import credentials +import samba.tests +import threading +import sys +import os + +class LibsmbTestCase(samba.tests.TestCase): + + class OpenClose(threading.Thread): + + def __init__(self, conn, filename, num_ops): + threading.Thread.__init__(self) + self.conn = conn + self.filename = filename + self.num_ops = num_ops + self.exc = False + + def run(self): + c = self.conn + try: + for i in range(self.num_ops): + f = c.create(self.filename, CreateDisposition=3, + DesiredAccess=security.SEC_STD_DELETE) + c.delete_on_close(f, True) + c.close(f) + except Exception: + self.exc = sys.exc_info() + + def test_OpenClose(self): + + lp = s3param.get_context() + lp.load(os.getenv("SMB_CONF_PATH")) + + creds = credentials.Credentials() + creds.set_username(os.getenv("USERNAME")) + creds.set_password(os.getenv("PASSWORD")) + + c = libsmb_samba_internal.Conn(os.getenv("SERVER_IP"), "tmp", creds) + + mythreads = [] + + for i in range(3): + t = LibsmbTestCase.OpenClose(c, "test" + str(i), 10) + mythreads.append(t) + + for t in mythreads: + t.start() + + for t in mythreads: + t.join() + if t.exc: + raise t.exc[0](t.exc[1]) + +if __name__ == "__main__": + import unittest + unittest.main() diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index 12c84a3dbd..76ef681fec 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -297,6 +297,8 @@ for f in sorted(os.listdir(os.path.join(samba4srcdir, "../pidl/tests"))): # DNS tests planpythontestsuite("dc", "samba.tests.dns") +planpythontestsuite("s3dc", "samba.tests.libsmb_samba_internal"); + # Blackbox Tests: # tests that interact directly with the command-line tools rather than using # the API. These mainly test that the various command-line options of commands |