wintest: added README
[kai/samba.git] / wintest / wintest.py
index 910297ed4b91dfbce4f2c4f323ca7a6ab5b05492..b8e6ea2dd19d69aa69e04402f86ecf1af52c0262 100644 (file)
@@ -68,7 +68,8 @@ class wintest():
 
     def set_vms(self, vms):
         '''set a list of VMs to test'''
-        self.vms = vms.split(',')
+        if vms is not None:
+            self.vms = vms.split(',')
 
     def skip(self, step):
         '''return True if we should skip a step'''
@@ -176,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):
@@ -186,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
@@ -209,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:
@@ -339,13 +343,30 @@ 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", "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 or i == 3:
+            child.expect("C:")
+            child.sendline("net config Workstation")
+            child.expect("Workstation domain")
+            child.expect('[\S]+')
+            domain = child.after
+            i = child.expect(["Workstation Domain DNS Name", "Logon domain"])
+            '''If we get the Logon domain first, we are not in an AD domain'''
+            if i == 1:
+                return False
+            if domain.upper() == self.getvar("WIN_DOMAIN").upper():
+                return True
+
         child.expect('[\S]+')
         hostname = child.after
-        if hostname.upper() == self.getvar("WIN_HOSTNAME").upper:
+        if hostname.upper() == self.getvar("WIN_HOSTNAME").upper():
             return True
 
     def run_tlntadmn(self, child):