summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2012-03-04 01:30:58 +0100
committerJelmer Vernooij <jelmer@samba.org>2012-03-04 18:02:06 +0100
commita6056e07e087dd3ea614054129baa3dcc0f13fce (patch)
treec19dc36f54a0b930e5506d6b9619ef9cc2f7a31a
parentfc7f49420bb6d1c8865c5c2b673119f23dd021f3 (diff)
downloadsamba-a6056e07e087dd3ea614054129baa3dcc0f13fce.tar.gz
samba-a6056e07e087dd3ea614054129baa3dcc0f13fce.tar.bz2
samba-a6056e07e087dd3ea614054129baa3dcc0f13fce.zip
selftest: Add python version of socket wrapper utilities.
-rw-r--r--selftest/socket_wrapper.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/selftest/socket_wrapper.py b/selftest/socket_wrapper.py
new file mode 100644
index 0000000000..a45645234a
--- /dev/null
+++ b/selftest/socket_wrapper.py
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+# Bootstrap Samba and run a number of tests against it.
+# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
+
+# 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/>.
+
+__all__ = ['setup_dir', 'setup_pcap', 'set_default_iface']
+
+import os
+import shutil
+
+def setup_dir(dir, pcap):
+ pcap_dir = None
+
+ if dir is not None:
+ if os.path.isdir(dir):
+ shutil.rmtree(dir)
+ os.mkdir(dir, 0777)
+
+ if pcap is not None:
+ pcap_dir = os.path.join(dir, "pcap")
+
+ if os.path.isdir(pcap_dir):
+ shutil.rmtree(pcap_dir)
+ os.mkdir(pcap_dir, 0777)
+
+ if pcap_dir is not None:
+ os.environ["SOCKET_WRAPPER_PCAP_DIR"] = pcap_dir
+ else:
+ del os.environ["SOCKET_WRAPPER_PCAP_DIR"]
+
+ if dir is not None:
+ os.environ["SOCKET_WRAPPER_DIR"] = dir
+ else:
+ del os.environ["SOCKET_WRAPPER_DIR"]
+
+ return dir
+
+def setup_pcap(pcap_file):
+ os.environ["SOCKET_WRAPPER_PCAP_FILE"] = pcap_file
+
+def set_default_iface(i):
+ os.environ["SOCKET_WRAPPER_DEFAULT_IFACE"] = i