diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-08-14 22:15:04 +0200 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-08-14 22:19:43 +0200 |
commit | eab7a322edc0a5b0553ff5f4c170096a98f8464f (patch) | |
tree | d12063edd798a8ffcd07e4b03832e4f7f85c8909 /tests/prime_nv_test.c | |
parent | 696c8f6434c7ec8db64f88125d4a7b31afd130bf (diff) |
tests/primve_nv_test: use igt_assert for checking
... and drop the int return argument of the tests.
Also:
- make nv_write_i915_cpu_mmap_read functional again by dropping the
goto.
- add checks to i915_import_pread_pwrite
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 | 219 |
1 files changed, 54 insertions, 165 deletions
diff --git a/tests/prime_nv_test.c b/tests/prime_nv_test.c index 0c307b99..7b40652f 100644 --- a/tests/prime_nv_test.c +++ b/tests/prime_nv_test.c @@ -84,25 +84,22 @@ static int find_and_open_devices(void) * close prime_fd, * unref buffers */ -static int test_i915_nv_sharing(void) +static void test_i915_nv_sharing(void) { - int ret; drm_intel_bo *test_intel_bo; int prime_fd; struct nouveau_bo *nvbo; test_intel_bo = drm_intel_bo_alloc(bufmgr, "test bo", BO_SIZE, 4096); + igt_assert(test_intel_bo); drm_intel_bo_gem_export_to_prime(test_intel_bo, &prime_fd); - ret = nouveau_bo_prime_handle_ref(ndev, prime_fd, &nvbo); + igt_assert(nouveau_bo_prime_handle_ref(ndev, prime_fd, &nvbo) == 0); close(prime_fd); - if (ret < 0) - return ret; nouveau_bo_ref(NULL, &nvbo); drm_intel_bo_unreference(test_intel_bo); - return 0; } /* @@ -113,38 +110,30 @@ static int test_i915_nv_sharing(void) * close prime_fd, * unref buffers */ -static int test_nv_i915_sharing(void) +static void test_nv_i915_sharing(void) { - int ret; drm_intel_bo *test_intel_bo; int prime_fd; struct nouveau_bo *nvbo; - ret = nouveau_bo_new(ndev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, - 0, BO_SIZE, NULL, &nvbo); - if (ret < 0) - return ret; - ret = nouveau_bo_set_prime(nvbo, &prime_fd); - if (ret < 0) - return ret; + igt_assert(nouveau_bo_new(ndev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, + 0, BO_SIZE, NULL, &nvbo) == 0); + igt_assert(nouveau_bo_set_prime(nvbo, &prime_fd) == 0); test_intel_bo = drm_intel_bo_gem_create_from_prime(bufmgr, prime_fd, BO_SIZE); close(prime_fd); - if (!test_intel_bo) - return -1; + igt_assert(test_intel_bo); nouveau_bo_ref(NULL, &nvbo); drm_intel_bo_unreference(test_intel_bo); - return 0; } /* * allocate intel, give to nouveau, map on nouveau * write 0xdeadbeef, non-gtt map on intel, read */ -static int test_nv_write_i915_cpu_mmap_read(void) +static void test_nv_write_i915_cpu_mmap_read(void) { - int ret; drm_intel_bo *test_intel_bo; int prime_fd; struct nouveau_bo *nvbo = NULL; @@ -154,46 +143,28 @@ static int test_nv_write_i915_cpu_mmap_read(void) drm_intel_bo_gem_export_to_prime(test_intel_bo, &prime_fd); - ret = nouveau_bo_prime_handle_ref(ndev, prime_fd, &nvbo); - if (ret < 0) { - fprintf(stderr,"failed to ref prime buffer %d\n", ret); - close(prime_fd); - goto free_intel; - } + igt_assert(nouveau_bo_prime_handle_ref(ndev, prime_fd, &nvbo) == 0); close(prime_fd); - goto free_intel; - - ret = nouveau_bo_map(nvbo, NOUVEAU_BO_RDWR, nclient); - if (ret < 0) { - fprintf(stderr,"failed to map nouveau bo\n"); - goto out; - } + igt_assert(nouveau_bo_map(nvbo, NOUVEAU_BO_RDWR, nclient) == 0); ptr = nvbo->map; *ptr = 0xdeadbeef; drm_intel_bo_map(test_intel_bo, 1); - ptr = test_intel_bo->virtual; + igt_assert(ptr); - if (*ptr != 0xdeadbeef) { - fprintf(stderr,"mapped value doesn't match\n"); - ret = -1; - } -out: + igt_assert(*ptr == 0xdeadbeef); nouveau_bo_ref(NULL, &nvbo); -free_intel: drm_intel_bo_unreference(test_intel_bo); - return ret; } /* * allocate intel, give to nouveau, map on nouveau * write 0xdeadbeef, gtt map on intel, read */ -static int test_nv_write_i915_gtt_mmap_read(void) +static void test_nv_write_i915_gtt_mmap_read(void) { - int ret; drm_intel_bo *test_intel_bo; int prime_fd; struct nouveau_bo *nvbo = NULL; @@ -203,186 +174,118 @@ static int test_nv_write_i915_gtt_mmap_read(void) drm_intel_bo_gem_export_to_prime(test_intel_bo, &prime_fd); - ret = nouveau_bo_prime_handle_ref(ndev, prime_fd, &nvbo); + igt_assert(nouveau_bo_prime_handle_ref(ndev, prime_fd, &nvbo) == 0); close(prime_fd); - if (ret < 0) { - fprintf(stderr,"failed to ref prime buffer\n"); - return ret; - } - - ret = nouveau_bo_map(nvbo, NOUVEAU_BO_RDWR, nclient); - if (ret < 0) { - fprintf(stderr,"failed to map nouveau bo\n"); - goto out; - } - - + igt_assert(nouveau_bo_map(nvbo, NOUVEAU_BO_RDWR, nclient) == 0); ptr = nvbo->map; *ptr = 0xdeadbeef; drm_intel_gem_bo_map_gtt(test_intel_bo); ptr = test_intel_bo->virtual; + igt_assert(ptr); + + igt_assert(*ptr == 0xdeadbeef); - if (*ptr != 0xdeadbeef) { - fprintf(stderr,"mapped value doesn't match\n"); - ret = -1; - } -out: nouveau_bo_ref(NULL, &nvbo); drm_intel_bo_unreference(test_intel_bo); - return ret; } /* test drm_intel_bo_map doesn't work properly, this tries to map the backing shmem fd, which doesn't exist for these objects */ -static int test_i915_import_cpu_mmap(void) +static void test_i915_import_cpu_mmap(void) { - int ret; drm_intel_bo *test_intel_bo; int prime_fd; struct nouveau_bo *nvbo; uint32_t *ptr; - ret = nouveau_bo_new(ndev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, - 0, BO_SIZE, NULL, &nvbo); - if (ret < 0) - return ret; - ret = nouveau_bo_set_prime(nvbo, &prime_fd); - if (ret < 0) - return ret; - + igt_assert(nouveau_bo_new(ndev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, + 0, BO_SIZE, NULL, &nvbo) == 0); + igt_assert(nouveau_bo_set_prime(nvbo, &prime_fd) == 0); test_intel_bo = drm_intel_bo_gem_create_from_prime(bufmgr, prime_fd, BO_SIZE); close(prime_fd); - if (!test_intel_bo) - return -1; + igt_assert(test_intel_bo); - ret = nouveau_bo_map(nvbo, NOUVEAU_BO_RDWR, nclient); - if (ret < 0) { - fprintf(stderr,"failed to map nouveau bo\n"); - goto out; - } + igt_assert(nouveau_bo_map(nvbo, NOUVEAU_BO_RDWR, nclient) == 0); ptr = nvbo->map; *ptr = 0xdeadbeef; - ret = drm_intel_bo_map(test_intel_bo, 0); - if (ret != 0) { - fprintf(stderr,"failed to map imported bo on intel side\n"); - goto out; - } - if (!test_intel_bo->virtual) { - ret = 0; - goto out; - } + igt_assert(drm_intel_bo_map(test_intel_bo, 0) == 0); + igt_assert(test_intel_bo->virtual); ptr = test_intel_bo->virtual; - if (*ptr != 0xdeadbeef) { - fprintf(stderr,"mapped value doesn't match %08x\n", *ptr); - ret = -1; - } - out: + igt_assert(*ptr == 0xdeadbeef); nouveau_bo_ref(NULL, &nvbo); drm_intel_bo_unreference(test_intel_bo); - return ret; } /* test drm_intel_bo_map_gtt works properly, this tries to map the backing shmem fd, which doesn't exist for these objects */ -static int test_i915_import_gtt_mmap(void) +static void test_i915_import_gtt_mmap(void) { - int ret; drm_intel_bo *test_intel_bo; int prime_fd; struct nouveau_bo *nvbo; uint32_t *ptr; - ret = nouveau_bo_new(ndev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, - 0, BO_SIZE, NULL, &nvbo); - if (ret < 0) - return ret; - ret = nouveau_bo_set_prime(nvbo, &prime_fd); - if (ret < 0) - return ret; + igt_assert(nouveau_bo_new(ndev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, + 0, BO_SIZE, NULL, &nvbo) == 0); + igt_assert(nouveau_bo_set_prime(nvbo, &prime_fd) == 0); test_intel_bo = drm_intel_bo_gem_create_from_prime(bufmgr, prime_fd, BO_SIZE); close(prime_fd); - if (!test_intel_bo) - return -1; + igt_assert(test_intel_bo); - ret = nouveau_bo_map(nvbo, NOUVEAU_BO_RDWR, nclient); - if (ret < 0) { - fprintf(stderr,"failed to map nouveau bo\n"); - goto out; - } + igt_assert(nouveau_bo_map(nvbo, NOUVEAU_BO_RDWR, nclient) == 0); ptr = nvbo->map; *ptr = 0xdeadbeef; *(ptr + 1) = 0xa55a55; - ret = drm_intel_gem_bo_map_gtt(test_intel_bo); - if (ret != 0) { - fprintf(stderr,"failed to map bo\n"); - goto out; - } - if (!test_intel_bo->virtual) { - ret = -1; - fprintf(stderr,"failed to map bo\n"); - goto out; - } + igt_assert(drm_intel_gem_bo_map_gtt(test_intel_bo) == 0); + igt_assert(test_intel_bo->virtual); ptr = test_intel_bo->virtual; - if (*ptr != 0xdeadbeef) { - fprintf(stderr,"mapped value doesn't match %08x %08x\n", *ptr, *(ptr + 1)); - ret = -1; - } - out: + igt_assert(*ptr == 0xdeadbeef); nouveau_bo_ref(NULL, &nvbo); drm_intel_bo_unreference(test_intel_bo); - return ret; } /* test 7 - import from nouveau into intel, test pread/pwrite fail */ -static int test_i915_import_pread_pwrite(void) +static void test_i915_import_pread_pwrite(void) { - int ret; drm_intel_bo *test_intel_bo; int prime_fd; struct nouveau_bo *nvbo; uint32_t *ptr; uint32_t buf[64]; - ret = nouveau_bo_new(ndev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, - 0, BO_SIZE, NULL, &nvbo); - if (ret < 0) - return ret; - ret = nouveau_bo_set_prime(nvbo, &prime_fd); - if (ret < 0) - return ret; + igt_assert(nouveau_bo_new(ndev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, + 0, BO_SIZE, NULL, &nvbo) == 0); + igt_assert(nouveau_bo_set_prime(nvbo, &prime_fd) == 0); test_intel_bo = drm_intel_bo_gem_create_from_prime(bufmgr, prime_fd, BO_SIZE); close(prime_fd); - if (!test_intel_bo) - return -1; + igt_assert(test_intel_bo); - ret = nouveau_bo_map(nvbo, NOUVEAU_BO_RDWR, nclient); - if (ret < 0) { - fprintf(stderr,"failed to map nouveau bo\n"); - goto out; - } + igt_assert(nouveau_bo_map(nvbo, NOUVEAU_BO_RDWR, nclient) == 0); ptr = nvbo->map; *ptr = 0xdeadbeef; gem_read(intel_fd, test_intel_bo->handle, 0, buf, 256); + igt_assert(buf[0] == 0xdeadbeef); buf[0] = 0xabcdef55; gem_write(intel_fd, test_intel_bo->handle, 0, buf, 4); - out: + + igt_assert(*ptr == 0xabcdef55); + nouveau_bo_ref(NULL, &nvbo); drm_intel_bo_unreference(test_intel_bo); - return ret; } static void @@ -417,9 +320,8 @@ create_bo(drm_intel_bufmgr *ibufmgr, uint32_t val, int width, int height) /* use intel hw to fill the BO with a blit from another BO, then readback from the nouveau bo, check value is correct */ -static int test_i915_blt_fill_nv_read(void) +static void test_i915_blt_fill_nv_read(void) { - int ret; drm_intel_bo *test_intel_bo, *src_bo; int prime_fd; struct nouveau_bo *nvbo = NULL; @@ -431,32 +333,19 @@ static int test_i915_blt_fill_nv_read(void) drm_intel_bo_gem_export_to_prime(test_intel_bo, &prime_fd); - ret = nouveau_bo_prime_handle_ref(ndev, prime_fd, &nvbo); + igt_assert(nouveau_bo_prime_handle_ref(ndev, prime_fd, &nvbo) == 0); close(prime_fd); - if (ret < 0) { - fprintf(stderr,"failed to ref prime buffer\n"); - return ret; - } intel_copy_bo(intel_batch, test_intel_bo, src_bo, 256, 1); - ret = nouveau_bo_map(nvbo, NOUVEAU_BO_RDWR, nclient); - if (ret < 0) { - fprintf(stderr,"failed to map nouveau bo\n"); - goto out; - } + igt_assert(nouveau_bo_map(nvbo, NOUVEAU_BO_RDWR, nclient) == 0); drm_intel_bo_map(test_intel_bo, 0); ptr = nvbo->map; - if (*ptr != 0xaa55aa55) { - fprintf(stderr,"mapped value doesn't match\n"); - ret = -1; - } -out: + igt_assert(*ptr == 0xaa55aa55); nouveau_bo_ref(NULL, &nvbo); drm_intel_bo_unreference(test_intel_bo); - return ret; } /* test 8 use nouveau to do blit */ @@ -480,8 +369,8 @@ int main(int argc, char **argv) //drm_intel_bufmgr_gem_enable_reuse(bufmgr); /* set up nouveau bufmgr */ - igt_assert(nouveau_device_wrap(nouveau_fd, 0, &ndev) >= 0); - igt_assert(nouveau_client_new(ndev, &nclient) >= 0); + 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); @@ -490,7 +379,7 @@ int main(int argc, char **argv) #define xtest(name) \ igt_subtest(#name) \ - igt_assert(test_##name() == 0); + test_##name(); xtest(i915_nv_sharing); xtest(nv_i915_sharing); |