diff options
| author | Jiri Kosina <jkosina@suse.com> | 2024-01-08 20:57:04 +0100 |
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.com> | 2024-01-08 20:57:04 +0100 |
| commit | 6b93f350e55f3f2ee071dd41109d936abfba8ebf (patch) | |
| tree | 481336b357ef1c1ac4a3a7517dd20294fe9b1c45 /lib/test_bitmap.c | |
| parent | b0a1fe4610de5761a66de0e43540fc3d59638402 (diff) | |
| parent | 584f35a3647d42980af495fc0bc5c51eb174aa35 (diff) | |
Merge branch 'for-6.8/amd-sfh' into for-linus
- addition of new interfaces to export User presence information and
Ambient light from amd-sfh to other drivers within the kernel (Basavaraj
Natikar)
Diffstat (limited to 'lib/test_bitmap.c')
| -rw-r--r-- | lib/test_bitmap.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index f2ea9f30c7c5..65f22c2578b0 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c @@ -330,6 +330,29 @@ static void __init test_copy(void) expect_eq_pbl("0-108,128-1023", bmap2, 1024); } +static void __init test_bitmap_region(void) +{ + int pos, order; + + DECLARE_BITMAP(bmap, 1000); + + bitmap_zero(bmap, 1000); + + for (order = 0; order < 10; order++) { + pos = bitmap_find_free_region(bmap, 1000, order); + if (order == 0) + expect_eq_uint(pos, 0); + else + expect_eq_uint(pos, order < 9 ? BIT(order) : -ENOMEM); + } + + bitmap_release_region(bmap, 0, 0); + for (order = 1; order < 9; order++) + bitmap_release_region(bmap, BIT(order), order); + + expect_eq_uint(bitmap_weight(bmap, 1000), 0); +} + #define EXP2_IN_BITS (sizeof(exp2) * 8) static void __init test_replace(void) @@ -1227,6 +1250,7 @@ static void __init selftest(void) test_zero_clear(); test_fill_set(); test_copy(); + test_bitmap_region(); test_replace(); test_bitmap_arr32(); test_bitmap_arr64(); |
