summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-09-22 12:52:29 -0700
committerJelmer Vernooij <jelmer@samba.org>2010-09-22 17:48:23 -0700
commit5a75fb194a290cb09fc03312262bd57196e86cb9 (patch)
treeefe5704fe4efb1d60f923b853a1fdac599f6abf1
parent18f10eec0ea55108e97da019f07a18b8854c2883 (diff)
downloadsamba-5a75fb194a290cb09fc03312262bd57196e86cb9.tar.gz
samba-5a75fb194a290cb09fc03312262bd57196e86cb9.tar.bz2
samba-5a75fb194a290cb09fc03312262bd57196e86cb9.zip
ndrdump: Move blackbox test to standard python namespace.
-rwxr-xr-xsource4/librpc/tests/test_ndrdump.sh20
-rw-r--r--source4/scripting/python/samba/tests/__init__.py13
-rw-r--r--source4/scripting/python/samba/tests/blackbox/__init__.py0
-rwxr-xr-xsource4/scripting/python/samba/tests/blackbox/ndrdump.py28
-rwxr-xr-xsource4/selftest/tests.sh2
5 files changed, 42 insertions, 21 deletions
diff --git a/source4/librpc/tests/test_ndrdump.sh b/source4/librpc/tests/test_ndrdump.sh
deleted file mode 100755
index dccf86df88..0000000000
--- a/source4/librpc/tests/test_ndrdump.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-# Blackbox tests for masktest
-# Copyright (C) 2008 Andrew Tridgell
-# Copyright (C) 2008 Andrew Bartlett
-# based on test_smbclient.sh
-
-. `dirname $0`/../../../testprogs/blackbox/subunit.sh
-
-failed=0
-
-samba4bindir="$BUILDDIR/bin"
-ndrdump="$samba4bindir/ndrdump$EXEEXT"
-files=`dirname $0`/
-
-testit "ndrdump with in" $VALGRIND $ndrdump samr samr_CreateUser in $files/samr-CreateUser-in.dat $@ || failed=`expr $failed + 1`
-testit "ndrdump with out" $VALGRIND $ndrdump samr samr_CreateUser out $files/samr-CreateUser-out.dat $@ || failed=`expr $failed + 1`
-testit "ndrdump with --context-file" $VALGRIND $ndrdump --context-file $files/samr-CreateUser-in.dat samr samr_CreateUser out $files/samr-CreateUser-out.dat $@ || failed=`expr $failed + 1`
-testit "ndrdump with validate" $VALGRIND $ndrdump --validate samr samr_CreateUser in $files/samr-CreateUser-in.dat $@ || failed=`expr $failed + 1`
-
-exit $failed
diff --git a/source4/scripting/python/samba/tests/__init__.py b/source4/scripting/python/samba/tests/__init__.py
index cee3397ba6..9644bad4cf 100644
--- a/source4/scripting/python/samba/tests/__init__.py
+++ b/source4/scripting/python/samba/tests/__init__.py
@@ -23,6 +23,7 @@ import os
import ldb
import samba
from samba import param
+import subprocess
import tempfile
# Other modules import these two classes from here, for convenience:
@@ -128,3 +129,15 @@ class ValidNetbiosNameTests(TestCase):
def test_invalid_characters(self):
self.assertFalse(samba.valid_netbios_name("*BLA"))
+
+
+class BlackboxTestCase(TestCase):
+ """Base test case for blackbox tests."""
+
+ def check_run(self, line):
+ bindir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../bin"))
+ parts = line.split(" ")
+ if os.path.exists(os.path.join(bindir, parts[0])):
+ parts[0] = os.path.join(bindir, parts[0])
+ line = " ".join(parts)
+ subprocess.check_call(line, shell=True)
diff --git a/source4/scripting/python/samba/tests/blackbox/__init__.py b/source4/scripting/python/samba/tests/blackbox/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/source4/scripting/python/samba/tests/blackbox/__init__.py
diff --git a/source4/scripting/python/samba/tests/blackbox/ndrdump.py b/source4/scripting/python/samba/tests/blackbox/ndrdump.py
new file mode 100755
index 0000000000..06c1b5c7d3
--- /dev/null
+++ b/source4/scripting/python/samba/tests/blackbox/ndrdump.py
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+# Blackbox tests for masktest
+# Copyright (C) 2008 Andrew Tridgell
+# Copyright (C) 2008 Andrew Bartlett
+# based on test_smbclient.sh
+
+import os
+from samba.tests import BlackboxTestCase
+
+data_path_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../../librpc/tests"))
+
+class NdrDumpTests(BlackboxTestCase):
+ """Blackbox tests for ndrdump."""
+
+ def data_path(self, name):
+ return os.path.join(data_path_dir, name)
+
+ def test_ndrdump_with_in(self):
+ self.check_run("ndrdump samr samr_CreateUser in %s" % (self.data_path("samr-CreateUser-in.dat")))
+
+ def test_ndrdump_with_out(self):
+ self.check_run("ndrdump samr samr_CreateUser out %s" % (self.data_path("samr-CreateUser-out.dat")))
+
+ def test_ndrdump_context_file(self):
+ self.check_run("ndrdump --context-file %s samr samr_CreateUser out %s" % (self.data_path("samr-CreateUser-in.dat"), self.data_path("samr-CreateUser-out.dat")))
+
+ def test_ndrdump_with_validate(self):
+ self.check_run("ndrdump --validate samr samr_CreateUser in %s" % (self.data_path("samr-CreateUser-in.dat")))
diff --git a/source4/selftest/tests.sh b/source4/selftest/tests.sh
index 86d483e7de..b4f893e221 100755
--- a/source4/selftest/tests.sh
+++ b/source4/selftest/tests.sh
@@ -388,7 +388,7 @@ planperltestsuite "selftest.samba4.pl" none $samba4srcdir/../selftest/test_samba
# the API. These mainly test that the various command-line options of commands
# work correctly.
-plantestsuite "blackbox.ndrdump" none $samba4srcdir/librpc/tests/test_ndrdump.sh
+planpythontestsuite none samba.tests.blackbox.ndrdump
plantestsuite "blackbox.net" dc:local $samba4srcdir/utils/tests/test_net.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN"
plantestsuite "blackbox.pkinit" dc:local $bbdir/test_pkinit.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$REALM" "\$DOMAIN" "$PREFIX" aes256-cts-hmac-sha1-96 $CONFIGURATION
plantestsuite "blackbox.kinit" dc:local $bbdir/test_kinit.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$REALM" "\$DOMAIN" "$PREFIX" aes256-cts-hmac-sha1-96 $CONFIGURATION