waf: check for jfs/quota.h
[samba.git] / wintest / wintest.py
index d421369086aa9fc71dc346d3e0cdbad1a4759bef..c239bab5506cc68c1cf25ca28560460bd77e6adb 100644 (file)
@@ -1,10 +1,15 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 '''automated testing library for testing Samba against windows'''
 
-import pexpect, subprocess
+import pexpect
+import subprocess
 import optparse
-import sys, os, time, re
+import sys
+import os
+import time
+import re
+
 
 class wintest():
     '''testing of Samba against windows VMs'''
@@ -44,7 +49,7 @@ class wintest():
 
     def getvar(self, varname):
         '''return a substitution variable'''
-        if not varname in self.vars:
+        if varname not in self.vars:
             return None
         return self.vars[varname]
 
@@ -128,7 +133,7 @@ class wintest():
             if var_end == -1:
                 return text
             var_name = text[var_start + 2:var_end]
-            if not var_name in self.vars:
+            if var_name not in self.vars:
                 raise RuntimeError("Unknown substitution variable ${%s}" % var_name)
             text = text.replace("${%s}" % var_name, self.vars[var_name])
         return text
@@ -182,7 +187,6 @@ class wintest():
         else:
             return subprocess.call(cmd, shell=shell, cwd=dir)
 
-
     def run_child(self, cmd, dir="."):
         '''create a child and return the Popen handle to it'''
         cwd = os.getcwd()
@@ -325,7 +329,7 @@ nameserver %s
         self.write_file('/etc/resolv.conf.wintest', contents, mode='a')
         self.write_file('/etc/resolv.conf.wintest-bak', contents)
         self.run_cmd("mv -f /etc/resolv.conf.wintest /etc/resolv.conf")
-        self.resolv_conf_backup = '/etc/resolv.conf.wintest-bak';
+        self.resolv_conf_backup = '/etc/resolv.conf.wintest-bak'
 
     def configure_bind(self, kerberos_support=False, include=None):
         self.chdir('${PREFIX}')
@@ -408,7 +412,6 @@ zone "%s" IN {
 ''' % (self.getvar('LCREALM'), self.getvar('INTERFACE_IP')),
                    mode='a')
 
-
         # add forwarding for the windows domains
         domains = self.get_domains()
 
@@ -425,7 +428,6 @@ zone "%s" IN {
 ''' % (d, domains[d]),
                      mode='a')
 
-
         self.write_file("etc/rndc.conf", '''
 # Start of rndc.conf
 key "rndc-key" {
@@ -440,7 +442,6 @@ options {
 };
 ''')
 
-
     def stop_bind(self):
         '''Stop our private BIND from listening and operating'''
         self.rndc_cmd("stop", checkfail=False)
@@ -448,7 +449,6 @@ options {
 
         self.run_cmd("rm -rf var/named")
 
-
     def start_bind(self):
         '''restart the test environment version of bind'''
         self.info("Restarting bind9")
@@ -475,7 +475,6 @@ options {
             self.info("restoring /etc/resolv.conf")
             self.run_cmd("mv -f %s /etc/resolv.conf" % self.resolv_conf_backup)
 
-
     def vm_poweroff(self, vmname, checkfail=True):
         '''power off a VM'''
         self.setvar('VMNAME', vmname)
@@ -515,8 +514,8 @@ options {
             child.close()
             i = child.exitstatus
             if wait_for_fail:
-                #wait for timeout or fail
-                if i == None or i > 0:
+                # wait for timeout or fail
+                if i is None or i > 0:
                     return
             else:
                 if i == 0:
@@ -655,7 +654,6 @@ options {
         child.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=5)
         return True
 
-
     def resolve_ip(self, hostname, retries=60, delay=5):
         '''resolve an IP given a hostname, assuming NBT'''
         while retries > 0:
@@ -672,7 +670,6 @@ options {
             self.info("retrying (retries=%u delay=%u)" % (retries, delay))
         raise RuntimeError("Failed to resolve IP of %s" % hostname)
 
-
     def open_telnet(self, hostname, username, password, retries=60, delay=5, set_time=False, set_ip=False,
                     disable_firewall=True, run_tlntadmn=True, set_noexpire=False):
         '''open a telnet connection to a windows server, return the pexpect child'''
@@ -740,7 +737,7 @@ options {
             if set_dns:
                 set_dns = False
                 if self.set_dns(child):
-                    continue;
+                    continue
             if set_route:
                 child.sendline('route add 0.0.0.0 mask 0.0.0.0 ${WIN_DEFAULT_GATEWAY}')
                 child.expect("C:")
@@ -819,7 +816,6 @@ options {
                 ret.append(self.vars[v])
         return ret
 
-
     def run_dcpromo_as_first_dc(self, vm, func_level=None):
         self.setwinvars(vm)
         self.info("Configuring a windows VM ${WIN_VM} at the first DC in the domain using dcpromo")
@@ -882,7 +878,6 @@ RebootOnCompletion=No
 
         self.retry_cmd("host -t SRV _ldap._tcp.${WIN_REALM} ${WIN_IP}", ['has SRV record'], retries=60, delay=5)
 
-
     def start_winvm(self, vm):
         '''start a Windows VM'''
         self.setwinvars(vm)
@@ -899,7 +894,7 @@ RebootOnCompletion=No
             child.sendline("ipconfig /flushdns")
             child.expect("C:")
             child.sendline("netdom join ${WIN_HOSTNAME} /Domain:%s /UserD:%s /PasswordD:%s" % (domain, username, password))
-            i = child.expect(["The command completed successfully", 
+            i = child.expect(["The command completed successfully",
                               "The specified domain either does not exist or could not be contacted."], timeout=120)
             if i == 0:
                 break
@@ -914,7 +909,6 @@ RebootOnCompletion=No
         child.expect("Registration of the DNS resource records for all adapters of this computer has been initiated. Any errors will be reported in the Event Viewer")
         child.expect("C:")
 
-
     def test_remote_smbclient(self, vm, username="${WIN_USER}", password="${WIN_PASS}", args=""):
         '''test smbclient against remote server'''
         self.setwinvars(vm)
@@ -931,7 +925,6 @@ RebootOnCompletion=No
         child.sendline("net use t: \\\\${HOSTNAME}.%s\\test" % realm)
         child.expect("The command completed successfully")
 
-
     def setup(self, testname, subdir):
         '''setup for main tests, parsing command line'''
         self.parser.add_option("--conf", type='string', default='', help='config file')
@@ -946,9 +939,9 @@ RebootOnCompletion=No
         self.parser.add_option("--use-ntvfs", action='store_true', default=False, help='use NTVFS for the fileserver')
         self.parser.add_option("--dns-backend", type="choice",
                                choices=["SAMBA_INTERNAL", "BIND9_FLATFILE", "BIND9_DLZ", "NONE"],
-                               help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), " \
-                               "BIND9_FLATFILE uses bind9 text database to store zone information, " \
-                               "BIND9_DLZ uses samba4 AD to store zone information, " \
+                               help="The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), "
+                               "BIND9_FLATFILE uses bind9 text database to store zone information, "
+                               "BIND9_DLZ uses samba4 AD to store zone information, "
                                "NONE skips the DNS setup entirely (not recommended)",
                                default="SAMBA_INTERNAL")