fix autotest infinite loop
Merge pull request #6092 from heliclei/fix-autotest

Fix autotest infinite loop