Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.
Squish/Hooking into Subprocesses
Sometimes when writing Squish tests the application being tested launches a subprocess. In this short tip we'll see how to robustly connect to an externally launched subprocess on Windows.
As the froglogic Squish manual (section 17.7.1) explains, hooking into an AUT's subprocess when on windows is slightly more complex, as Squish is not able to use LD_PRELOAD (or DYLD_INSERT_LIBRARIES on OS X) to insert the squish library hook into the launching executable. Two options to get around this are clear—the AUT sourcecode can be modified to optionally insert "dllpreload.exe" into the subprocess launch (as the squish manual explains), or the AUT can be modified to call an external shell script that does the optional prepending of 'dllpreload.exe'.
In any case, once the AUT has been modified to properly launch the subprocess, the squish test still needs to attach to the launching subprocess. If the AUT uses QProcess to launch the subprocess, it is enough to do:
subprocess = waitForApplicationLaunch()
However, if the squish IDE is set up to attach to the AUT manually, the desired call would be:
subprocess = attachToApplication( "APPNAME" )
However, the attachToApplication() call will throw an exception if the subprocess is not ready. So, a more robust way to give the subprocess time to launch properly is to try again in a loop for a predetermined amount of time:
subprocess = 0
count = 0
while True:
if count > 30:
raise RuntimeError( "Attaching to AUT subprocess failed!" )
try:
subprocess = attachToApplication("APPNAME")
break
except:
snooze(1)
count += 1