diff options
author | Arkadiusz Hiler <arkadiusz.hiler@intel.com> | 2018-10-18 14:06:42 +0300 |
---|---|---|
committer | Arkadiusz Hiler <arkadiusz.hiler@intel.com> | 2018-10-23 10:55:51 +0300 |
commit | 741bf7064c467df725c14cc0b3b8b50436f9ee09 (patch) | |
tree | 0ad6fb217dca79a8f1175fb289979b574222fefa /tests/i915/gem_close.c | |
parent | 78619fde4008424c472906041edb1d204e014f7c (diff) |
tests: Introduce i915 directory
We can already move all the tests with distinct prefixes: gem_, gen3_
and i915_.
pm_ and drv_ tests will follow in batches, so we can do the
adjustments in the reporting/filtering layer of the CI system.
v2: Fix test-list.txt generation with meson
v3: Fix docs build (Petri)
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Martin Peres <martin.peres@linux.intel.com>
Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Reviewed-by: Petri Latvala <petri.latvala@intel.com>
Tested-by: Petri Latvala <petri.latvala@intel.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/i915/gem_close.c')
-rw-r--r-- | tests/i915/gem_close.c | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/tests/i915/gem_close.c b/tests/i915/gem_close.c new file mode 100644 index 00000000..1d5fa305 --- /dev/null +++ b/tests/i915/gem_close.c @@ -0,0 +1,97 @@ +/* + * Copyright © 2017 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "igt.h" + +static void test_many_handles(int fd) +{ + uint32_t bbe = MI_BATCH_BUFFER_END; + struct drm_i915_gem_execbuffer2 execbuf; + struct drm_i915_gem_exec_object2 obj[2]; + uint32_t clones[1024]; + uint32_t original; + + original = gem_create(fd, 4096); + gem_write(fd, original, 0, &bbe, sizeof(bbe)); + + memset(&execbuf, 0, sizeof(execbuf)); + execbuf.buffers_ptr = to_user_pointer(obj); + execbuf.buffer_count = 1; + + memset(obj, 0, sizeof(obj)); + obj[0].handle = original; + gem_execbuf(fd, &execbuf); + + for (int i = 0; i < ARRAY_SIZE(clones); i++) { + clones[i] = gem_open(fd, gem_flink(fd, original)); + obj[0].handle = clones[i]; + gem_execbuf(fd, &execbuf); + } + + /* We do not allow the sam object to be referenced multiple times + * within an execbuf; hence why this practice of cloning a handle + * is only found within test cases. + */ + execbuf.buffer_count = 2; + obj[0].handle = original; + for (int i = 0; i < ARRAY_SIZE(clones); i++) { + obj[1].handle = clones[i]; + igt_assert_eq(__gem_execbuf(fd, &execbuf), -EINVAL); + } + /* Any other clone pair should also be detected */ + obj[1].handle = clones[0]; /* (last, first) */ + igt_assert_eq(__gem_execbuf(fd, &execbuf), -EINVAL); + execbuf.buffer_count = 1; + + /* Now close the original having used every clone */ + obj[0].handle = original; + gem_close(fd, original); + igt_assert_eq(__gem_execbuf(fd, &execbuf), -ENOENT); + + /* All clones should still be operational */ + for (int i = 0; i < ARRAY_SIZE(clones); i++) { + obj[0].handle = clones[i]; + gem_execbuf(fd, &execbuf); + + /* ... until closed */ + gem_close(fd, clones[i]); + igt_assert_eq(__gem_execbuf(fd, &execbuf), -ENOENT); + } +} + +igt_main +{ + int fd = -1; + + igt_fixture { + /* Create an flink requires DRM_AUTH */ + fd = drm_open_driver_master(DRIVER_INTEL); + igt_require_gem(fd); + } + + igt_subtest("basic") + gem_close(fd, gem_create(fd, 4096)); + + igt_subtest("many-handles-one-vma") + test_many_handles(fd); +} |