wintest: cope with w2k3 form of dcdiag output
[kai/samba.git] / wintest / wintest.py
index 5f7bd0a8d53d1e390d828fd8d0783ccc59b6ce2d..b8e6ea2dd19d69aa69e04402f86ecf1af52c0262 100644 (file)
@@ -177,7 +177,7 @@ class wintest():
         return self.run_cmd(cmd, output=True)
 
     def cmd_contains(self, cmd, contains, nomatch=False, ordered=False, regex=False,
-                     casefold=False):
+                     casefold=True):
         '''check that command output contains the listed strings'''
 
         if isinstance(contains, str):
@@ -187,6 +187,9 @@ class wintest():
         self.info(out)
         for c in self.substitute(contains):
             if regex:
+                if casefold:
+                    c = c.upper()
+                    out = out.upper()
                 m = re.search(c, out)
                 if m is None:
                     start = -1
@@ -210,7 +213,7 @@ class wintest():
                 out = out[end:]
 
     def retry_cmd(self, cmd, contains, retries=30, delay=2, wait_for_fail=False,
-                  ordered=False, regex=False, casefold=False):
+                  ordered=False, regex=False, casefold=True):
         '''retry a command a number of times'''
         while retries > 0:
             try:
@@ -340,11 +343,15 @@ class wintest():
         child.expect("C:")
 
     def get_is_dc(self, child):
+        '''check if a windows machine is a domain controller'''
         child.sendline("dcdiag")
-        i = child.expect(["is not a Directory Server", "is not recognized as an internal or external command", "Home Server = "])
+        i = child.expect(["is not a Directory Server",
+                          "is not recognized as an internal or external command",
+                          "Home Server = ",
+                          "passed test Replications"])
         if i == 0:
             return False
-        if i == 1:
+        if i == 1 or i == 3:
             child.expect("C:")
             child.sendline("net config Workstation")
             child.expect("Workstation domain")