SquishTests: Remove firewall handling for Windows

Handling the firewall from script is cumbersome and not worth the
effort - remove all related code.
Explicitly state the prerequisite of disabling notifications for the
firewall.

Change-Id: Icbe3075127eeb9a57724c334f0b52a24f8b08f59
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Jukka Nokso <jukka.nokso@qt.io>
This commit is contained in:
Christian Stenger
2024-02-01 13:17:18 +01:00
parent e1f6ee8f76
commit 35b7f868f5
3 changed files with 2 additions and 74 deletions

View File

@@ -63,10 +63,7 @@ started. On Windows, this has the following prerequisites:
Either: Either:
* have no firewall at all enabled (sure that's a bad idea) * have no firewall at all enabled (sure that's a bad idea)
Or: Or:
* run Windows with English UI * have notifications disabled for the firewall when an application tries to access network
* have the Windows Firewall enabled (no other firewalls are handled by the scripts)
* run the Squish tests with administrator privileges
* additionally the UAC should be disabled, too
Otherwise you'll have some trouble with popping up dialogs from the firewall. Otherwise you'll have some trouble with popping up dialogs from the firewall.
If you're using a different firewall - try to figure out and add a rule for this. If you're using a different firewall - try to figure out and add a rule for this.

View File

@@ -266,69 +266,3 @@ def verifyBreakPoint(bpToVerify):
test.fatal("Expected a dict for bpToVerify - got '%s'" % className(bpToVerify)) test.fatal("Expected a dict for bpToVerify - got '%s'" % className(bpToVerify))
return False return False
# helper to check whether win firewall is running or not
# this doesn't check for other firewalls!
def __isWinFirewallRunning__():
if hasattr(__isWinFirewallRunning__, "fireWallState"):
return __isWinFirewallRunning__.fireWallState
if platform.system() not in ('Microsoft' 'Windows'):
__isWinFirewallRunning__.fireWallState = False
return False
result = getOutputFromCmdline(["netsh", "firewall", "show", "state"])
for line in result.splitlines():
if "Operational mode" in line:
__isWinFirewallRunning__.fireWallState = not "Disable" in line
return __isWinFirewallRunning__.fireWallState
return None
# helper that can modify the win firewall to allow a program to communicate through it or delete it
# param addToFW defines whether to add (True) or delete (False) this program to/from the firewall
def __configureFW__(workingDir, projectName, isReleaseBuild, addToFW=True):
if isReleaseBuild == None:
if projectName[-4:] == ".exe":
projectName = projectName[:-4]
path = "%s%s%s" % (workingDir, os.sep, projectName)
elif isReleaseBuild:
path = "%s%s%s%srelease%s%s" % (workingDir, os.sep, projectName, os.sep, os.sep, projectName)
else:
path = "%s%s%s%sdebug%s%s" % (workingDir, os.sep, projectName, os.sep, os.sep, projectName)
if addToFW:
mode = "add"
enable = "ENABLE"
else:
mode = "delete"
enable = ""
projectName = ""
# Needs admin privileges on Windows 7
# Using the deprecated "netsh firewall" because the newer
# "netsh advfirewall" would need admin privileges on Windows Vista, too.
return subprocess.call(["netsh", "firewall", mode, "allowedprogram",
"%s.exe" % path, projectName, enable])
# function to add a program to allow communication through the win firewall
# param workingDir this directory is the parent of the project folder
# param projectName this is the name of the project (the folder inside workingDir as well as the name for the executable)
# param isReleaseBuild should currently always be set to True (will later add debug build testing)
def allowAppThroughWinFW(workingDir, projectName, isReleaseBuild=True):
if not __isWinFirewallRunning__():
return
# WinFirewall seems to run - hopefully no other
result = __configureFW__(workingDir, projectName, isReleaseBuild)
if result == 0:
test.log("Added %s to firewall" % projectName)
else:
test.fatal("Could not add %s as allowed program to win firewall" % projectName)
# function to delete a (former added) program from the win firewall
# param workingDir this directory is the parent of the project folder
# param projectName this is the name of the project (the folder inside workingDir as well as the name for the executable)
# param isReleaseBuild should currently always be set to True (will later add debug build testing)
def deleteAppFromWinFW(workingDir, projectName, isReleaseBuild=True):
if not __isWinFirewallRunning__():
return
# WinFirewall seems to run - hopefully no other
result = __configureFW__(workingDir, projectName, isReleaseBuild, False)
if result == 0:
test.log("Deleted %s from firewall" % projectName)
else:
test.warning("Could not delete %s as allowed program from win firewall" % (projectName))

View File

@@ -36,7 +36,7 @@ def main():
for kit, config in availableConfigs: for kit, config in availableConfigs:
test.log("Selecting '%s' as build config" % config) test.log("Selecting '%s' as build config" % config)
verifyBuildConfig(kit, config, True, True, True) verifyBuildConfig(kit, config, True, True, True)
# explicitly build before start debugging for adding the executable as allowed program to WinFW # explicitly build before start debugging
selectFromLocator("t rebuild", "Rebuild All Projects") selectFromLocator("t rebuild", "Rebuild All Projects")
waitForCompile(300000) waitForCompile(300000)
if not checkCompile(): if not checkCompile():
@@ -52,7 +52,6 @@ def main():
buildDir = os.path.join(str(waitForObject(":Qt Creator_Utils::BuildDirectoryLineEdit").text), buildDir = os.path.join(str(waitForObject(":Qt Creator_Utils::BuildDirectoryLineEdit").text),
"debug") "debug")
switchViewTo(ViewConstants.EDIT) switchViewTo(ViewConstants.EDIT)
allowAppThroughWinFW(buildDir, projectName, None)
if not doSimpleDebugging(kit, config, expectedBreakpointsOrder): if not doSimpleDebugging(kit, config, expectedBreakpointsOrder):
try: try:
stopB = findObject(':Qt Creator.Stop_QToolButton') stopB = findObject(':Qt Creator.Stop_QToolButton')
@@ -60,8 +59,6 @@ def main():
clickButton(stopB) clickButton(stopB)
except: except:
pass pass
if platform.system() in ('Microsoft' 'Windows'):
deleteAppFromWinFW(buildDir, projectName, None)
# close application output window of current run to avoid mixing older output on the next run # close application output window of current run to avoid mixing older output on the next run
ensureChecked(":Qt Creator_AppOutput_Core::Internal::OutputPaneToggleButton") ensureChecked(":Qt Creator_AppOutput_Core::Internal::OutputPaneToggleButton")
clickButton(waitForObject("{type='CloseButton' unnamed='1' visible='1' " clickButton(waitForObject("{type='CloseButton' unnamed='1' visible='1' "