If access_memory exits immediately, wss_collected is empty and the percentile check at the end crashes with: IndexError: list index out of range Check proc.poll() after the loop and fail with the child's return code instead. Signed-off-by: Enze Li --- .../sysfs_update_schemes_tried_regions_wss_estimation.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py index 36e7ae5f826d..4d81d4245b0c 100755 --- a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py +++ b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py @@ -39,6 +39,14 @@ def pass_wss_estimation(sz_region): wss_collected.append( kdamonds.kdamonds[0].contexts[0].schemes[0].tried_bytes) + + if proc.poll() is not None: + print('access_memory terminated early: %d' % proc.returncode) + err = kdamonds.kdamonds[0].stop() + if err is not None: + print('kdamond stop failed: %s' % err) + exit(1) + proc.terminate() err = kdamonds.stop() if err is not None: -- 2.53.0