diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-08-14 18:02:46 +0200 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-08-14 18:02:46 +0200 |
commit | b3880d3a969656b78fe246e5ca4dd5a4a2c70ef5 (patch) | |
tree | 471f1d9f81ec5299615cf59cb1787afac09a5367 /tests/prime_nv_test.c | |
parent | c3dd8a8c85b3e1a4329282cbe82fd7f387cd2643 (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/prime_nv_test.c')
-rw-r--r-- | tests/prime_nv_test.c | 59 |
1 files changed, 23 insertions, 36 deletions
diff --git a/tests/prime_nv_test.c b/tests/prime_nv_test.c index 59fd9671..0c307b99 100644 --- a/tests/prime_nv_test.c +++ b/tests/prime_nv_test.c @@ -465,43 +465,28 @@ out: int main(int argc, char **argv) { - int ret = 0; - - ret = find_and_open_devices(); - if (ret < 0) - return ret; - igt_subtest_init(argc, argv); - if (nouveau_fd == -1 || intel_fd == -1) { - fprintf(stderr,"failed to find intel and nouveau GPU\n"); - if (!igt_only_list_subtests()) - return 77; - } + igt_fixture { + igt_assert(find_and_open_devices() == 0); - /* set up intel bufmgr */ - bufmgr = drm_intel_bufmgr_gem_init(intel_fd, 4096); - if (!bufmgr) - return -1; - /* Do not enable reuse, we share (almost) all buffers. */ - //drm_intel_bufmgr_gem_enable_reuse(bufmgr); + igt_require(nouveau_fd != -1); + igt_require(intel_fd != -1); - /* set up nouveau bufmgr */ - ret = nouveau_device_wrap(nouveau_fd, 0, &ndev); - if (ret < 0) { - fprintf(stderr,"failed to wrap nouveau device\n"); - return 77; - } + /* set up intel bufmgr */ + bufmgr = drm_intel_bufmgr_gem_init(intel_fd, 4096); + igt_assert(bufmgr); + /* Do not enable reuse, we share (almost) all buffers. */ + //drm_intel_bufmgr_gem_enable_reuse(bufmgr); - ret = nouveau_client_new(ndev, &nclient); - if (ret < 0) { - fprintf(stderr,"failed to setup nouveau client\n"); - return -1; - } + /* set up nouveau bufmgr */ + igt_assert(nouveau_device_wrap(nouveau_fd, 0, &ndev) >= 0); + igt_assert(nouveau_client_new(ndev, &nclient) >= 0); - /* set up an intel batch buffer */ - devid = intel_get_drm_devid(intel_fd); - intel_batch = intel_batchbuffer_alloc(bufmgr, devid); + /* set up an intel batch buffer */ + devid = intel_get_drm_devid(intel_fd); + intel_batch = intel_batchbuffer_alloc(bufmgr, devid); + } #define xtest(name) \ igt_subtest(#name) \ @@ -516,13 +501,15 @@ int main(int argc, char **argv) xtest(i915_import_pread_pwrite); xtest(i915_blt_fill_nv_read); - intel_batchbuffer_free(intel_batch); + igt_fixture { + intel_batchbuffer_free(intel_batch); - nouveau_device_del(&ndev); - drm_intel_bufmgr_destroy(bufmgr); + nouveau_device_del(&ndev); + drm_intel_bufmgr_destroy(bufmgr); - close(intel_fd); - close(nouveau_fd); + close(intel_fd); + close(nouveau_fd); + } igt_exit(); } |