summaryrefslogtreecommitdiff
path: root/tests/gem_tiled_partial_pwrite_pread.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-08-14 18:02:46 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-08-14 18:02:46 +0200
commitb3880d3a969656b78fe246e5ca4dd5a4a2c70ef5 (patch)
tree471f1d9f81ec5299615cf59cb1787afac09a5367 /tests/gem_tiled_partial_pwrite_pread.c
parentc3dd8a8c85b3e1a4329282cbe82fd7f387cd2643 (diff)
tests: roll out igt_fixture
Also sprinkle igt_assert and igt_require over the setup code to clean up code while at it. To avoid gcc getting upset about unitialized variables just move them out of main as global data (where they always get initialized to 0) - gcc can't see through our igt_fixture and igt_subtest maze properly. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tests/gem_tiled_partial_pwrite_pread.c')
-rw-r--r--tests/gem_tiled_partial_pwrite_pread.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/tests/gem_tiled_partial_pwrite_pread.c b/tests/gem_tiled_partial_pwrite_pread.c
index 3d70924f..da52f7a1 100644
--- a/tests/gem_tiled_partial_pwrite_pread.c
+++ b/tests/gem_tiled_partial_pwrite_pread.c
@@ -280,27 +280,29 @@ int main(int argc, char **argv)
srandom(0xdeadbeef);
- fd = drm_open_any();
-
- bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
- //drm_intel_bufmgr_gem_enable_reuse(bufmgr);
- devid = intel_get_drm_devid(fd);
- batch = intel_batchbuffer_alloc(bufmgr, devid);
-
- /* overallocate the buffers we're actually using because */
- scratch_bo = drm_intel_bo_alloc_tiled(bufmgr, "scratch bo", 1024,
- BO_SIZE/4096, 4,
- &tiling_mode, &scratch_pitch, 0);
- igt_assert(tiling_mode == I915_TILING_X);
- igt_assert(scratch_pitch == 4096);
- staging_bo = drm_intel_bo_alloc(bufmgr, "staging bo", BO_SIZE, 4096);
- tiled_staging_bo = drm_intel_bo_alloc_tiled(bufmgr, "scratch bo", 1024,
- BO_SIZE/4096, 4,
- &tiling_mode,
- &scratch_pitch, 0);
-
- igt_init_aperture_trashers(bufmgr);
- mappable_gtt_limit = gem_mappable_aperture_size();
+ igt_fixture {
+ fd = drm_open_any();
+
+ bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
+ //drm_intel_bufmgr_gem_enable_reuse(bufmgr);
+ devid = intel_get_drm_devid(fd);
+ batch = intel_batchbuffer_alloc(bufmgr, devid);
+
+ /* overallocate the buffers we're actually using because */
+ scratch_bo = drm_intel_bo_alloc_tiled(bufmgr, "scratch bo", 1024,
+ BO_SIZE/4096, 4,
+ &tiling_mode, &scratch_pitch, 0);
+ igt_assert(tiling_mode == I915_TILING_X);
+ igt_assert(scratch_pitch == 4096);
+ staging_bo = drm_intel_bo_alloc(bufmgr, "staging bo", BO_SIZE, 4096);
+ tiled_staging_bo = drm_intel_bo_alloc_tiled(bufmgr, "scratch bo", 1024,
+ BO_SIZE/4096, 4,
+ &tiling_mode,
+ &scratch_pitch, 0);
+
+ igt_init_aperture_trashers(bufmgr);
+ mappable_gtt_limit = gem_mappable_aperture_size();
+ }
igt_subtest("reads")
test_partial_reads();
@@ -311,10 +313,12 @@ int main(int argc, char **argv)
igt_subtest("writes-after-reads")
test_partial_read_writes();
- igt_cleanup_aperture_trashers();
- drm_intel_bufmgr_destroy(bufmgr);
+ igt_fixture {
+ igt_cleanup_aperture_trashers();
+ drm_intel_bufmgr_destroy(bufmgr);
- close(fd);
+ close(fd);
+ }
igt_exit();
}