summaryrefslogtreecommitdiff
path: root/wintest
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-11-19 14:08:18 +1100
committerAndrew Tridgell <tridge@samba.org>2010-11-19 15:17:44 +1100
commit7bfc60e40cae4d71301be27d5c44ce99a471a62b (patch)
tree85e77456f71ae2a55ef4477b33418f96df6eb1b1 /wintest
parent8f1df5726576f045f9c9a3305f388d7d823750e6 (diff)
downloadsamba-7bfc60e40cae4d71301be27d5c44ce99a471a62b.tar.gz
samba-7bfc60e40cae4d71301be27d5c44ce99a471a62b.tar.bz2
samba-7bfc60e40cae4d71301be27d5c44ce99a471a62b.zip
wintest: added del_files, write_file and casefold
Diffstat (limited to 'wintest')
-rwxr-xr-xwintest/test-s4-howto.py23
-rw-r--r--wintest/wintest.py24
2 files changed, 35 insertions, 12 deletions
diff --git a/wintest/test-s4-howto.py b/wintest/test-s4-howto.py
index 6afea1a89b..b925973df1 100755
--- a/wintest/test-s4-howto.py
+++ b/wintest/test-s4-howto.py
@@ -6,8 +6,6 @@ import sys, os
import optparse
import wintest
-vars = {}
-
def check_prerequesites(t):
t.info("Checking prerequesites")
t.setvar('HOSTNAME', t.cmd_output("hostname -s").strip())
@@ -30,8 +28,7 @@ def provision_s4(t, func_level="2008", interfaces=None):
'''provision s4 as a DC'''
t.info('Provisioning s4')
t.chdir('${PREFIX}')
- t.run_cmd("rm -rf etc private")
- t.run_cmd("find var -type f | xargs rm -f")
+ t.del_files(["var", "etc", "private"])
options=' --function-level=%s -d${DEBUGLEVEL}' % func_level
if interfaces:
options += ' --option=interfaces=%s' % interfaces
@@ -68,16 +65,15 @@ def test_smbclient(t):
def create_shares(t):
t.info("Adding test shares")
t.chdir('${PREFIX}')
- f = open("etc/smb.conf", mode='a')
- f.write(t.substitute('''
+ t.write_file("etc/smb.conf", '''
[test]
path = ${PREFIX}/test
read only = no
[profiles]
path = ${PREFIX}/var/profiles
read only = no
- '''))
- f.close()
+ ''',
+ mode='a')
t.run_cmd("mkdir -p test")
t.run_cmd("mkdir -p var/profiles")
@@ -592,19 +588,28 @@ if __name__ == '__main__':
parser.add_option("--list", action='store_true', default=False, help='list the available steps')
parser.add_option("--rebase", action='store_true', default=False, help='do a git pull --rebase')
parser.add_option("--clean", action='store_true', default=False, help='clean the tree')
+ parser.add_option("--prefix", type='string', default=None, help='override install prefix')
+ parser.add_option("--sourcetree", type='string', default=None, help='override sourcetree location')
opts, args = parser.parse_args()
if not opts.conf:
- t.info("Please specify a config file with --conf")
+ print("Please specify a config file with --conf")
sys.exit(1)
t = wintest.wintest()
t.load_config(opts.conf)
t.set_skip(opts.skip)
+
if opts.list:
t.list_steps_mode()
+ if opts.prefix:
+ t.setvar('PREFIX', opts.prefix)
+
+ if opts.sourcetree:
+ t.setvar('SOURCETREE', opts.sourcetree)
+
if opts.rebase:
t.info('rebasing')
t.chdir('${SOURCETREE}')
diff --git a/wintest/wintest.py b/wintest/wintest.py
index f871462fba..5706f88aa9 100644
--- a/wintest/wintest.py
+++ b/wintest/wintest.py
@@ -96,6 +96,16 @@ class wintest():
'''chdir with substitution'''
os.chdir(self.substitute(dir))
+ def del_files(self, dirs):
+ '''delete all files in the given directory'''
+ for d in dirs:
+ self.run_cmd("find %s -type f | xargs rm -f" % d)
+
+ def write_file(self, filename, text, mode='w'):
+ '''write to a file'''
+ f = open(self.substitute(filename), mode=mode)
+ f.write(self.substitute(text))
+ f.close()
def run_cmd(self, cmd, dir=".", show=None, output=False, checkfail=True):
cmd = self.substitute(cmd)
@@ -120,8 +130,13 @@ class wintest():
cmd = self.substitute(cmd)
return self.run_cmd(cmd, output=True)
- def cmd_contains(self, cmd, contains, nomatch=False, ordered=False, regex=False):
+ def cmd_contains(self, cmd, contains, nomatch=False, ordered=False, regex=False,
+ casefold=False):
'''check that command output contains the listed strings'''
+
+ if isinstance(contains, str):
+ contains = [contains]
+
out = self.cmd_output(cmd)
self.info(out)
for c in self.substitute(contains):
@@ -133,6 +148,9 @@ class wintest():
else:
start = m.start()
end = m.end()
+ elif casefold:
+ start = out.upper().find(c.upper())
+ end = start + len(c)
else:
start = out.find(c)
end = start + len(c)
@@ -146,12 +164,12 @@ class wintest():
out = out[end:]
def retry_cmd(self, cmd, contains, retries=30, delay=2, wait_for_fail=False,
- ordered=False, regex=False):
+ ordered=False, regex=False, casefold=False):
'''retry a command a number of times'''
while retries > 0:
try:
self.cmd_contains(cmd, contains, nomatch=wait_for_fail,
- ordered=ordered, regex=regex)
+ ordered=ordered, regex=regex, casefold=casefold)
return
except:
time.sleep(delay)