From d3d0951a28387cbb20e842a1e725ead4a76a0d21 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Tue, 8 Apr 2003 05:01:18 +0000 Subject: Merge from 1.2.2.2: Update for new ComfyChair interface. (This used to be commit 9de9899165fbf403e369d8ebadd171ffdde8c3b7) --- source3/stf/strings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/stf') diff --git a/source3/stf/strings.py b/source3/stf/strings.py index a67e137058..8fc12d4e39 100755 --- a/source3/stf/strings.py +++ b/source3/stf/strings.py @@ -33,7 +33,7 @@ def signum(a): class StrCaseCmp_Ascii_Tests(comfychair.TestCase): """String comparisons in simple ASCII""" def run_strcmp(self, a, b, expect): - out = self.runcmd('t_strcmp \"%s\" \"%s\"' % (a, b)) + out, err = self.runcmd('t_strcmp \"%s\" \"%s\"' % (a, b)) if signum(int(out)) != expect: self.fail("comparison failed:\n" " a=%s\n" -- cgit From bce94d35f125eaeaa4db7866503418b8f281edf2 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Tue, 8 Apr 2003 08:05:01 +0000 Subject: Integrate abartlet's t_push_ucs2 test into test framework: - Build t_push_ucs2 as part of check-programs, the prerequisite for "make check". - t_push_ucs2.c: Load configuration from /dev/null so that we get a unix_charset of UTF-8 and can do meaningful UCS2 tests. Better comment. - Add a test to strings.py which tries conversion UTF8->UCS2->UTF8 and checks the results. Do this for English, Latin-1, and Katakana strings. - Add Python module with symbolic names for a handful of UNICODE characters. (This used to be commit 275e095c92ac74815ab9e388a0e83cdb7ddd85f3) --- source3/stf/strings.py | 40 ++++++++++++++++++++++++++++++++++++++-- source3/stf/unicodenames.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 source3/stf/unicodenames.py (limited to 'source3/stf') diff --git a/source3/stf/strings.py b/source3/stf/strings.py index 8fc12d4e39..4e070c0444 100755 --- a/source3/stf/strings.py +++ b/source3/stf/strings.py @@ -1,4 +1,4 @@ -#! /usr/bin/python +#! /usr/bin/python # Comfychair test cases for Samba string functions. @@ -19,7 +19,22 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA +# XXX: All this code assumes that the Unix character set is UTF-8, +# which is the most common setting. I guess it would be better to +# force it to that value while running the tests. I'm not sure of the +# best way to do that yet. +# +# Note that this is NOT the case in C code until the loadparm table is +# intialized -- the default seems to be ASCII, which rather lets Samba +# off the hook. :-) The best way seems to be to put this in the test +# harnesses: +# +# lp_load("/dev/null", True, False, False); +# +# -- mbp + import sys, re, comfychair +from unicodenames import * def signum(a): if a < 0: @@ -28,6 +43,23 @@ def signum(a): return +1 else: return 0 + + +class PushUCS2_Tests(comfychair.TestCase): + """Conversion to/from UCS2""" + def runtest(self): + OE = LATIN_CAPITAL_LETTER_O_WITH_DIARESIS + oe = LATIN_CAPITAL_LETTER_O_WITH_DIARESIS + cases = ['hello', + 'hello world', + 'g' + OE + OE + 'gomobile', + 'g' + OE + oe + 'gomobile', + u'foo\u0100', + KATAKANA_LETTER_A * 20, + ] + for u8str in cases: + out, err = self.runcmd("t_push_ucs2 \"%s\"" % u8str.encode('utf-8')) + self.assert_equal(out, "0\n") class StrCaseCmp_Ascii_Tests(comfychair.TestCase): @@ -61,9 +93,13 @@ class StrCaseCmp_Ascii_Tests(comfychair.TestCase): self.run_strcmp(a, b, expect) # Define the tests exported by this module -tests = [StrCaseCmp_Ascii_Tests] +tests = [StrCaseCmp_Ascii_Tests, + PushUCS2_Tests] # Handle execution of this file as a main program if __name__ == '__main__': comfychair.main(tests) +# Local variables: +# coding: utf-8 +# End: diff --git a/source3/stf/unicodenames.py b/source3/stf/unicodenames.py new file mode 100644 index 0000000000..d4100cb7f9 --- /dev/null +++ b/source3/stf/unicodenames.py @@ -0,0 +1,33 @@ +#! /usr/bin/python + +# Copyright (C) 2003 by Martin Pool +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA + + +""" +Defines symbolic names for a few UNICODE characters, to make test +source code more readable on machines that don't have all the +necessary fonts. + +You can do "import *" on this file safely. +""" + +LATIN_CAPITAL_LETTER_N_WITH_TILDE = u'\u004e' +LATIN_CAPITAL_LETTER_O_WITH_DIARESIS = u'\u00d6' +LATIN_SMALL_LETTER_O_WITH_DIARESIS = u'\u00f6' + +KATAKANA_LETTER_A = u'\u30a2' -- cgit From a62cd3285aa0dd83aabb6d40a76d51e1eff323b6 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 9 Apr 2003 05:55:33 +0000 Subject: Ignore testtmp directory. (This used to be commit 862e3ee421efc92ebfcb17eabe06efea3a64999f) --- source3/stf/.cvsignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/stf') diff --git a/source3/stf/.cvsignore b/source3/stf/.cvsignore index 7e99e367f8..bcf4150606 100644 --- a/source3/stf/.cvsignore +++ b/source3/stf/.cvsignore @@ -1 +1,2 @@ -*.pyc \ No newline at end of file +*.pyc +testtmp -- cgit From 29883705106dc433b1ff0e3bb7bdd3558430f9cf Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 9 Apr 2003 05:57:00 +0000 Subject: Tests for smbcontrol. (This used to be commit 7bf68a533ee76ffebf77c4d09abf42079579646f) --- source3/stf/smbcontrol.py | 238 +++++++++++++++++++++++++++++++++++++++++++ source3/stf/standardcheck.py | 3 +- 2 files changed, 240 insertions(+), 1 deletion(-) create mode 100755 source3/stf/smbcontrol.py (limited to 'source3/stf') diff --git a/source3/stf/smbcontrol.py b/source3/stf/smbcontrol.py new file mode 100755 index 0000000000..30c331819c --- /dev/null +++ b/source3/stf/smbcontrol.py @@ -0,0 +1,238 @@ +#!/usr/bin/python +# +# Test for smbcontrol command line argument handling. +# + +import comfychair + +class NoArgs(comfychair.TestCase): + """Test no arguments produces usage message.""" + def runtest(self): + out = self.runcmd("smbcontrol", expectedResult = 1) + self.assert_re_match("Usage: smbcontrol", out[1]) + +class OneArg(comfychair.TestCase): + """Test single argument produces usage message.""" + def runtest(self): + out = self.runcmd("smbcontrol foo", expectedResult = 1) + self.assert_re_match("Usage: smbcontrol", out[1]) + +class SmbdDest(comfychair.TestCase): + """Test the broadcast destination 'smbd'.""" + def runtest(self): + out = self.runcmd("smbcontrol smbd noop") + +class NmbdDest(comfychair.TestCase): + """Test the destination 'nmbd'.""" + def runtest(self): + # We need a way to start/stop/whatever nmbd + raise comfychair.NotRunError, "not implemented" + +class PidDest(comfychair.TestCase): + """Test a pid number destination'.""" + def runtest(self): + out = self.runcmd("smbcontrol 1234 noop") + +class SelfDest(comfychair.TestCase): + """Test the destination 'self'.""" + def runtest(self): + out = self.runcmd("smbcontrol self noop") + +class WinbinddDest(comfychair.TestCase): + """Test the destination 'winbindd'.""" + def runtest(self): + # We need a way to start/stop/whatever winbindd + raise comfychair.NotRunError, "not implemented" + +class BadDest(comfychair.TestCase): + """Test a bad destination.""" + def runtest(self): + out = self.runcmd("smbcontrol foo noop", expectedResult = 1) + +class BadCmd(comfychair.TestCase): + """Test a bad command.""" + def runtest(self): + out = self.runcmd("smbcontrol self spottyfoot", expectedResult = 1) + self.assert_re_match("smbcontrol: unknown command", out[1]); + +class NoArgCmdTest(comfychair.TestCase): + """A test class that tests a command with no argument.""" + def runtest(self): + self.require_root() + out = self.runcmd("smbcontrol self %s" % self.cmd) + out = self.runcmd("smbcontrol self %s spottyfoot" % self.cmd, + expectedResult = 1) + +class ForceElection(NoArgCmdTest): + """Test a force-election message.""" + def setup(self): + self.cmd = "force-election" + +class SamSync(NoArgCmdTest): + """Test a samsync message.""" + def setup(self): + self.cmd = "samsync" + +class SamRepl(NoArgCmdTest): + """Test a samrepl message.""" + def setup(self): + self.cmd = "samrepl" + +class DmallocChanged(NoArgCmdTest): + """Test a dmalloc-changed message.""" + def setup(self): + self.cmd = "dmalloc-log-changed" + +class DmallocMark(NoArgCmdTest): + """Test a dmalloc-mark message.""" + def setup(self): + self.cmd = "dmalloc-mark" + +class Shutdown(NoArgCmdTest): + """Test a shutdown message.""" + def setup(self): + self.cmd = "shutdown" + +class Ping(NoArgCmdTest): + """Test a ping message.""" + def setup(self): + self.cmd = "ping" + +class Debuglevel(NoArgCmdTest): + """Test a debuglevel message.""" + def setup(self): + self.cmd = "debuglevel" + +class OneArgCmdTest(comfychair.TestCase): + """A test class that tests a command with one argument.""" + def runtest(self): + self.require_root() + out = self.runcmd("smbcontrol self %s spottyfoot" % self.cmd) + out = self.runcmd("smbcontrol self %s" % self.cmd, expectedResult = 1) + +class DrvUpgrade(OneArgCmdTest): + """Test driver upgrade message.""" + def setup(self): + self.cmd = "drvupgrade" + +class CloseShare(OneArgCmdTest): + """Test close share message.""" + def setup(self): + self.cmd = "close-share" + +class Debug(OneArgCmdTest): + """Test a debug message.""" + def setup(self): + self.cmd = "debug" + +class PrintNotify(comfychair.TestCase): + """Test print notification commands.""" + def runtest(self): + + # No subcommand + + out = self.runcmd("smbcontrol self printnotify", expectedResult = 1) + self.assert_re_match("Must specify subcommand", out[1]); + + # Invalid subcommand name + + out = self.runcmd("smbcontrol self printnotify spottyfoot", + expectedResult = 1) + self.assert_re_match("Invalid subcommand", out[1]); + + # Queue commands + + for cmd in ["queuepause", "queueresume"]: + + out = self.runcmd("smbcontrol self printnotify %s" % cmd, + expectedResult = 1) + self.assert_re_match("Usage:", out[1]) + + out = self.runcmd("smbcontrol self printnotify %s spottyfoot" + % cmd) + + # Job commands + + for cmd in ["jobpause", "jobresume", "jobdelete"]: + + out = self.runcmd("smbcontrol self printnotify %s" % cmd, + expectedResult = 1) + self.assert_re_match("Usage:", out[1]) + + out = self.runcmd("smbcontrol self printnotify %s spottyfoot" + % cmd, expectedResult = 1) + self.assert_re_match("Usage:", out[1]) + + out = self.runcmd("smbcontrol self printnotify %s spottyfoot 123" + % cmd) + + # Printer properties + + out = self.runcmd("smbcontrol self printnotify printer", + expectedResult = 1) + self.assert_re_match("Usage", out[1]) + + out = self.runcmd("smbcontrol self printnotify printer spottyfoot", + expectedResult = 1) + self.assert_re_match("Usage", out[1]) + + for cmd in ["comment", "port", "driver"]: + + out = self.runcmd("smbcontrol self printnotify printer spottyfoot " + "%s" % cmd, expectedResult = 1) + self.assert_re_match("Usage", out[1]) + + out = self.runcmd("smbcontrol self printnotify printer spottyfoot " + "%s value" % cmd) + +class Profile(comfychair.TestCase): + """Test setting the profiling level.""" + def runtest(self): + self.require_root() + out = self.runcmd("smbcontrol self profile", expectedResult = 1) + self.assert_re_match("Usage", out[1]) + + out = self.runcmd("smbcontrol self profile spottyfoot", + expectedResult = 1) + self.assert_re_match("Unknown", out[1]) + + for cmd in ["off", "count", "on", "flush"]: + out = self.runcmd("smbcontrol self profile %s" % cmd) + +class ProfileLevel(comfychair.TestCase): + """Test requesting the current profiling level.""" + def runtest(self): + self.require_root() + out = self.runcmd("smbcontrol self profilelevel spottyfoot", + expectedResult = 1) + self.assert_re_match("Usage", out[1]) + + out = self.runcmd("smbcontrol self profilelevel") + +class TimeoutArg(comfychair.TestCase): + """Test the --timeout argument.""" + def runtest(self): + out = self.runcmd("smbcontrol --timeout 5 self noop") + out = self.runcmd("smbcontrol --timeout spottyfoot self noop", + expectedResult = 1) + +class ConfigFileArg(comfychair.TestCase): + """Test the --configfile argument.""" + def runtest(self): + out = self.runcmd("smbcontrol --configfile /dev/null self noop") + +class BogusArg(comfychair.TestCase): + """Test a bogus command line argument.""" + def runtest(self): + out = self.runcmd("smbcontrol --bogus self noop", expectedResult = 1) + +tests = [NoArgs, OneArg, SmbdDest, NmbdDest, WinbinddDest, PidDest, + SelfDest, BadDest, BadCmd, Debug, ForceElection, SamSync, + SamRepl, DmallocMark, DmallocChanged, Shutdown, DrvUpgrade, + CloseShare, Ping, Debuglevel, PrintNotify, Profile, ProfileLevel, + TimeoutArg, ConfigFileArg, BogusArg] + +# Handle execution of this file as a main program + +if __name__ == '__main__': + comfychair.main(tests) diff --git a/source3/stf/standardcheck.py b/source3/stf/standardcheck.py index 5af1c78376..bec21b8ec5 100644 --- a/source3/stf/standardcheck.py +++ b/source3/stf/standardcheck.py @@ -22,12 +22,13 @@ """These tests are run by Samba's "make check".""" import strings, comfychair +import smbcontrol # There should not be any actual tests in here: this file just serves # to define the ones run by default. They're imported from other # modules. -tests = strings.tests +tests = strings.tests + smbcontrol.tests if __name__ == '__main__': comfychair.main(tests) -- cgit From 1e9be586c8b59240cd3a4b583543972f89bdaa54 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Wed, 9 Apr 2003 06:50:59 +0000 Subject: StrCaseCmp tests: Add some tests in Katakana. Convert strings to UTF-8 before passing to test harness. (This used to be commit 79b292de98208571e49648cf88d9b565396151be) --- source3/stf/strings.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source3/stf') diff --git a/source3/stf/strings.py b/source3/stf/strings.py index 4e070c0444..328849b1ce 100755 --- a/source3/stf/strings.py +++ b/source3/stf/strings.py @@ -62,10 +62,10 @@ class PushUCS2_Tests(comfychair.TestCase): self.assert_equal(out, "0\n") -class StrCaseCmp_Ascii_Tests(comfychair.TestCase): +class StrCaseCmp(comfychair.TestCase): """String comparisons in simple ASCII""" def run_strcmp(self, a, b, expect): - out, err = self.runcmd('t_strcmp \"%s\" \"%s\"' % (a, b)) + out, err = self.runcmd('t_strcmp \"%s\" \"%s\"' % (a.encode('utf-8'), b.encode('utf-8'))) if signum(int(out)) != expect: self.fail("comparison failed:\n" " a=%s\n" @@ -88,12 +88,14 @@ class StrCaseCmp_Ascii_Tests(comfychair.TestCase): ('longstring ' * 100, 'longstring ' * 100, 0), ('longstring ' * 100, 'longstring ' * 100 + 'a', -1), ('longstring ' * 100 + 'a', 'longstring ' * 100, +1), + (KATAKANA_LETTER_A, KATAKANA_LETTER_A, 0), + (KATAKANA_LETTER_A, 'a', 1), ] for a, b, expect in cases: self.run_strcmp(a, b, expect) # Define the tests exported by this module -tests = [StrCaseCmp_Ascii_Tests, +tests = [StrCaseCmp, PushUCS2_Tests] # Handle execution of this file as a main program -- cgit