summaryrefslogtreecommitdiff
path: root/wintest/wintest.py
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/wintest.py
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/wintest.py')
-rw-r--r--wintest/wintest.py24
1 files changed, 21 insertions, 3 deletions
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)