Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/damon/damon_nr_regions: sort collected regiosn before checking with min/max boundaries

damon_nr_regions.py starts DAMON, periodically collect number of regions
in snapshots, and see if it is in the requested range. The check code
assumes the numbers are sorted on the collection list, but there is no
such guarantee. Hence this can result in false positive test success.
Sort the list before doing the check.

Link: https://lkml.kernel.org/r/20250225222333.505646-4-sj@kernel.org
Fixes: 781497347d1b ("selftests/damon: implement test for min/max_nr_regions")
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

SeongJae Park and committed by
Andrew Morton
582ccf78 695469c0

+1
+1
tools/testing/selftests/damon/damon_nr_regions.py
··· 65 65 66 66 test_name = 'nr_regions test with %d/%d/%d real/min/max nr_regions' % ( 67 67 real_nr_regions, min_nr_regions, max_nr_regions) 68 + collected_nr_regions.sort() 68 69 if (collected_nr_regions[0] < min_nr_regions or 69 70 collected_nr_regions[-1] > max_nr_regions): 70 71 print('fail %s' % test_name)