diff options
author | Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> | 2022-02-24 08:54:15 +0100 |
---|---|---|
committer | Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> | 2022-02-25 13:56:46 +0100 |
commit | f814ccc7ace5cf482be646374a45814185d4f2ec (patch) | |
tree | 5113e4282dd0540169a6245473a23a19db7c052b /tests/i915/api_intel_allocator.c | |
parent | 92972b3fa35dcaa752a6220582ce2a277eb4c7c1 (diff) |
tests/api_intel_allocator: Add default-alignment test
Test verifies that intel-allocator uses caller default-alignment setting
during open() instead of choosing safe alignment instead. Also check
does alloc() can overwrite default setting used by the allocator.
v2: rename allocator -> default-allocator test name
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Diffstat (limited to 'tests/i915/api_intel_allocator.c')
-rw-r--r-- | tests/i915/api_intel_allocator.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/i915/api_intel_allocator.c b/tests/i915/api_intel_allocator.c index 0cd96c8b..a652caf4 100644 --- a/tests/i915/api_intel_allocator.c +++ b/tests/i915/api_intel_allocator.c @@ -120,6 +120,34 @@ static void reserve(int fd, uint8_t type) igt_assert_eq(intel_allocator_close(ahnd), true); } +static void default_alignment(int fd) +{ + struct test_obj obj[3]; + uint64_t ahnd, default_alignment = 0x4000; + + ahnd = intel_allocator_open_full(fd, 0, 0, 0, INTEL_ALLOCATOR_SIMPLE, + ALLOC_STRATEGY_LOW_TO_HIGH, + default_alignment); + + for (int i = 0; i < ARRAY_SIZE(obj); i++) { + obj[i].handle = gem_handle_gen(); + obj[i].offset = intel_allocator_alloc(ahnd, obj[i].handle, 4096, + i == 2 ? 4096 : 0); + igt_debug("obj[%d].offset: %llx, handle: %u\n", i, + (long long) obj[i].offset, obj[i].handle); + } + + igt_assert_eq(obj[1].offset - obj[0].offset, default_alignment); + /* obj[2] should be between obj[0] and obj[1] */ + igt_assert(obj[0].offset < obj[2].offset); + igt_assert(obj[2].offset < obj[1].offset); + + for (int i = 0; i < ARRAY_SIZE(obj); i++) + intel_allocator_free(ahnd, obj[i].handle); + + igt_assert_eq(intel_allocator_close(ahnd), true); +} + static bool overlaps(struct test_obj *buf1, struct test_obj *buf2) { uint64_t begin1 = buf1->offset; @@ -697,6 +725,11 @@ igt_main igt_subtest_f("reserve") reserve(fd, INTEL_ALLOCATOR_SIMPLE); + igt_describe("For simple allocator check does default alignment is " + "properly handled in open and alloc functions"); + igt_subtest_f("default-alignment") + default_alignment(fd); + for (a = als; a->name; a++) { igt_subtest_with_dynamic_f("%s-allocator", a->name) { igt_dynamic("basic") |