Skip to content

Commit

Permalink
ApplicationTest : More forgiving process name change test
Browse files Browse the repository at this point in the history
This ensures the process has had time to change its own name.
  • Loading branch information
ivanimanishi authored and johnhaddon committed Jan 8, 2025
1 parent c81b87b commit 9160952
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Fixes
- Fixed bug where the value dragged from the visualiser would be slightly different from the initial value on button press. (#6191)
- Fixed error when trying to visualise data unsupported data.
- TweakPlug : Fixed preservation of geometric interpretation when tweaking V3f values.
- ApplicationTest : Extended grace period when testing process name on slower hosts.

API
---
Expand Down
28 changes: 22 additions & 6 deletions python/GafferTest/ApplicationTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,29 @@ def testWrapperDoesntDuplicatePaths( self ) :
def testProcessName( self ) :

process = subprocess.Popen( [ str( Gaffer.executablePath() ), "env", "sleep", "100" ] )
time.sleep( 1 )
command = subprocess.check_output( [ "ps", "-p", str( process.pid ), "-o", "command=" ], universal_newlines = True ).strip()
name = subprocess.check_output( [ "ps", "-p", str( process.pid ), "-o", "comm=" ], universal_newlines = True ).strip()
process.kill()
try :
startTime = time.time()
while True :
time.sleep( 0.1 )
command = subprocess.check_output( [ "ps", "-p", str( process.pid ), "-o", "command=" ], universal_newlines = True ).strip()
name = subprocess.check_output( [ "ps", "-p", str( process.pid ), "-o", "comm=" ], universal_newlines = True ).strip()
try :
self.assertEqual( command, "gaffer env sleep 100" )
self.assertEqual( name, "gaffer" )

except self.failureException :
# It can take some time for gaffer to change its own process name, which varies
# based on the host's performance.
# For that reason, we check until 3 seconds have passed before giving up.
if time.time() - startTime > 3.0 :
raise

else :
break

finally :
process.kill()

self.assertEqual( command, "gaffer env sleep 100" )
self.assertEqual( name, "gaffer" )

if __name__ == "__main__":
unittest.main()

0 comments on commit 9160952

Please sign in to comment.