test for absence of infinite loop
cs at cskk.id.au
Tue Jul 17 07:16:30 EDT 2018
On 17Jul2018 10:10, Robin Becker <robin at reportlab.com> wrote:
>A user reported an infinite loop in reportlab. I determined a possible
>cause and fix and would like to test for absence of the loop. Is there
>any way to check for presence/absence of an infinite loop in python? I
>imagine we could do something like call an external process and see if it
>takes too long, but that seems a bit flaky.
While others have kindly pointed you at the halting problem (unsolvable in the
general case) you can usually verify that the specific problem you fixed is
fixed. Can you figure out how long the task should run with your fix in a test
case? Not as time, but in loop iterations? Put a counter in the loop and check
that its value doesn't exceed that.
Cameron Simpson <cs at cskk.id.au>
More information about the Python-list