Commit 5e25fcc2 authored by Daniel Vetter's avatar Daniel Vetter

tests: use igt_fail instead of exit(param != 0)

Mostly a sed job with too manual fixups:
- one case of using _exit instead of exit
- and one case which under some conditions use 77, so convert that
  check to an igt_skip.
Signed-off-by: Daniel Vetter's avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent b30d95f3
......@@ -161,7 +161,7 @@ int main(int argc, char **argv)
if (cpu_ptr[j] != val0) {
printf("mismatch at %i, got: %i, expected: %i\n",
j, cpu_ptr[j], val0);
exit(1);
igt_fail(1);
}
}
drm_intel_bo_unmap(scratch_bo);
......@@ -199,21 +199,21 @@ int main(int argc, char **argv)
if (gtt_ptr[j] != val0) {
printf("mismatch at %i, partial=[%d+%d] got: %i, expected: %i\n",
j, start, len, gtt_ptr[j], val0);
exit(1);
igt_fail(1);
}
}
for (; j < start + len; j++) {
if (gtt_ptr[j] != val1) {
printf("mismatch at %i, partial=[%d+%d] got: %i, expected: %i\n",
j, start, len, gtt_ptr[j], val1);
exit(1);
igt_fail(1);
}
}
for (; j < BO_SIZE; j++) {
if (gtt_ptr[j] != val0) {
printf("mismatch at %i, partial=[%d+%d] got: %i, expected: %i\n",
j, start, len, gtt_ptr[j], val0);
exit(1);
igt_fail(1);
}
}
drm_intel_gem_bo_unmap_gtt(staging_bo);
......@@ -244,7 +244,7 @@ int main(int argc, char **argv)
if (cpu_ptr[j] != val0) {
printf("mismatch in read at %i, got: %i, expected: %i\n",
j, cpu_ptr[j], val0);
exit(1);
igt_fail(1);
}
}
drm_intel_bo_unmap(scratch_bo);
......@@ -271,21 +271,21 @@ int main(int argc, char **argv)
if (gtt_ptr[j] != val1) {
printf("mismatch at %i, partial=[%d+%d] got: %i, expected: %i\n",
j, start, len, gtt_ptr[j], val1);
exit(1);
igt_fail(1);
}
}
for (; j < start + len; j++) {
if (gtt_ptr[j] != val2) {
printf("mismatch at %i, partial=[%d+%d] got: %i, expected: %i\n",
j, start, len, gtt_ptr[j], val2);
exit(1);
igt_fail(1);
}
}
for (; j < BO_SIZE; j++) {
if (gtt_ptr[j] != val1) {
printf("mismatch at %i, partial=[%d+%d] got: %i, expected: %i\n",
j, start, len, gtt_ptr[j], val1);
exit(1);
igt_fail(1);
}
}
drm_intel_gem_bo_unmap_gtt(staging_bo);
......
......@@ -102,7 +102,7 @@ int main(int argc, char **argv)
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
if (!bufmgr) {
fprintf(stderr, "failed to init libdrm\n");
exit(-1);
igt_fail(-1);
}
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
......
......@@ -125,7 +125,7 @@ static void run_on_ring(int fd, unsigned ring_id, const char *ring_name)
}
if (exec(fd, handle_new, split, &gtt_offset_new, 0))
exit(1);
igt_fail(1);
if (split > 0) {
/* Check that we've managed to collide in the tlb. */
......
......@@ -162,7 +162,7 @@ int main(int argc, char *argv[])
ret = pthread_join(threads[i], &retval);
thread_status = *(int *)retval;
if (!ret && thread_status)
exit(thread_status);
igt_fail(thread_status);
}
free(returns);
......
......@@ -101,7 +101,7 @@ int main(int argc, char **argv)
if (argc != 1) {
fprintf(stderr, "usage: %s\n", argv[0]);
exit(-1);
igt_fail(-1);
}
fd = drm_open_any();
......@@ -114,26 +114,26 @@ int main(int argc, char **argv)
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
if (!bufmgr) {
fprintf(stderr, "failed to init libdrm\n");
exit(-1);
igt_fail(-1);
}
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
batch = intel_batchbuffer_alloc(bufmgr, devid);
if (!batch) {
fprintf(stderr, "failed to create batch buffer\n");
exit(-1);
igt_fail(-1);
}
target_buffer = drm_intel_bo_alloc(bufmgr, "target bo", 4096, 4096);
if (!target_buffer) {
fprintf(stderr, "failed to alloc target buffer\n");
exit(-1);
igt_fail(-1);
}
blt_bo = drm_intel_bo_alloc(bufmgr, "target bo", 4*4096*4096, 4096);
if (!blt_bo) {
fprintf(stderr, "failed to alloc blt buffer\n");
exit(-1);
igt_fail(-1);
}
dummy_reloc_loop();
......
......@@ -143,20 +143,20 @@ int main(int argc, char **argv)
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
if (!bufmgr) {
fprintf(stderr, "failed to init libdrm\n");
exit(-1);
igt_fail(-1);
}
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
batch = intel_batchbuffer_alloc(bufmgr, devid);
if (!batch) {
fprintf(stderr, "failed to create batch buffer\n");
exit(-1);
igt_fail(-1);
}
target_buffer = drm_intel_bo_alloc(bufmgr, "target bo", 4096, 4096);
if (!target_buffer) {
fprintf(stderr, "failed to alloc target buffer\n");
exit(-1);
igt_fail(-1);
}
igt_subtest("render") {
......
......@@ -146,7 +146,7 @@ static void multi_write_domain(int fd)
if (ret == 0 || errno != EINVAL) {
fprintf(stderr, "multiple write domains not rejected\n");
exit(1);
igt_fail(1);
}
}
......@@ -173,7 +173,7 @@ int main(int argc, char **argv)
ret = run_batch();
if (ret != -EINVAL) {
fprintf(stderr, "(cpu, 0) reloc not rejected\n");
exit(1);
igt_fail(1);
}
BEGIN_BATCH(2);
......@@ -183,7 +183,7 @@ int main(int argc, char **argv)
ret = run_batch();
if (ret != -EINVAL) {
fprintf(stderr, "(cpu, cpu) reloc not rejected\n");
exit(1);
igt_fail(1);
}
}
......@@ -195,7 +195,7 @@ int main(int argc, char **argv)
ret = run_batch();
if (ret != -EINVAL) {
fprintf(stderr, "(gtt, 0) reloc not rejected\n");
exit(1);
igt_fail(1);
}
BEGIN_BATCH(2);
......@@ -205,7 +205,7 @@ int main(int argc, char **argv)
ret = run_batch();
if (ret != -EINVAL) {
fprintf(stderr, "(gtt, gtt) reloc not rejected\n");
exit(1);
igt_fail(1);
}
}
......@@ -223,7 +223,7 @@ int main(int argc, char **argv)
ret = run_batch();
if (ret != -EINVAL) {
fprintf(stderr, "conflicting write domains not rejected\n");
exit(1);
igt_fail(1);
}
}
#endif
......@@ -240,7 +240,7 @@ int main(int argc, char **argv)
ret = run_batch();
if (ret != -EINVAL) {
fprintf(stderr, "invalid gpu read domains not rejected\n");
exit(1);
igt_fail(1);
}
BEGIN_BATCH(2);
......@@ -251,7 +251,7 @@ int main(int argc, char **argv)
ret = run_batch();
if (ret != -EINVAL) {
fprintf(stderr, "invalid gpu domain not rejected\n");
exit(1);
igt_fail(1);
}
}
......
......@@ -116,7 +116,7 @@ int main(int argc, char **argv)
for (reloc_ofs = 4096; reloc_ofs < batch_size; reloc_ofs += 4096)
if (exec(fd, handle, reloc_ofs))
exit(1);
igt_fail(1);
}
gem_close(fd, handle);
......
......@@ -231,7 +231,7 @@ static void run(int object_size)
gettimeofday(&start, NULL);
if (gem_exec(fd, &execbuf, count))
exit(1);
igt_fail(1);
gem_sync(fd, handle);
gettimeofday(&end, NULL);
printf("Time to blt %d bytes x %6d: %7.3fµs, %s\n",
......
......@@ -97,7 +97,7 @@ static void loop(int fd, uint32_t handle, unsigned ring_id, const char *ring_nam
gettimeofday(&start, NULL);
if (exec(fd, handle, count, ring_id))
exit(1);
igt_fail(1);
gettimeofday(&end, NULL);
printf("Time to exec x %d: %7.3fµs (ring=%s)\n",
count, elapsed(&start, &end, count), ring_name);
......
......@@ -132,7 +132,7 @@ _bo_write_verify(struct test *t)
if (v != i) {
printf("tiling %s: write failed at %d (%x)\n",
tile_str[t->tiling], i, v);
_exit(-1);
igt_fail(-1);
}
}
......@@ -141,7 +141,7 @@ _bo_write_verify(struct test *t)
if (v != i) {
printf("tiling %s: verify failed at %d (%x)\n",
tile_str[t->tiling], i, v);
exit(-2);
igt_fail(-2);
}
}
}
......
......@@ -74,7 +74,7 @@ int main(int argc, char **argv)
if (argc != 2) {
fprintf(stderr, "usage: %s <disabled pipe number>\n",
argv[0]);
exit(-1);
igt_fail(-1);
}
bad_pipe = atoi(argv[1]);
......
......@@ -66,7 +66,7 @@ test_large_object(int fd)
if (ret) {
fprintf(stderr, "object creation failed: %s\n",
strerror(errno));
exit(ret);
igt_fail(ret);
}
pin.handle = create.handle;
......@@ -74,7 +74,7 @@ test_large_object(int fd)
if (ret) {
fprintf(stderr, "pin failed: %s\n",
strerror(errno));
exit(ret);
igt_fail(ret);
}
gem_write(fd, create.handle, 0, data, obj_size);
......
......@@ -83,7 +83,7 @@ int main(int argc, char **argv)
if (argc != 1) {
fprintf(stderr, "usage: %s\n", argv[0]);
exit(-1);
igt_fail(-1);
}
fd = drm_open_any();
......@@ -101,14 +101,14 @@ int main(int argc, char **argv)
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
if (!bufmgr) {
fprintf(stderr, "failed to init libdrm\n");
exit(-1);
igt_fail(-1);
}
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
batch = intel_batchbuffer_alloc(bufmgr, devid);
if (!batch) {
fprintf(stderr, "failed to create batch buffer\n");
exit(-1);
igt_fail(-1);
}
mi_lri_loop();
......
......@@ -123,7 +123,7 @@ static void test_partial_reads(void)
if (tmp[j] != val) {
printf("mismatch at %i, got: %i, expected: %i\n",
j, tmp[j], val);
exit(1);
igt_fail(1);
}
}
......@@ -159,21 +159,21 @@ static void test_partial_writes(void)
if (gtt_ptr[j] != val) {
printf("mismatch at %i, got: %i, expected: %i\n",
j, tmp[j], val);
exit(1);
igt_fail(1);
}
}
for (; j < start + len; j++) {
if (gtt_ptr[j] != tmp[0]) {
printf("mismatch at %i, got: %i, expected: %i\n",
j, tmp[j], i);
exit(1);
igt_fail(1);
}
}
for (; j < BO_SIZE; j++) {
if (gtt_ptr[j] != val) {
printf("mismatch at %i, got: %i, expected: %i\n",
j, tmp[j], val);
exit(1);
igt_fail(1);
}
}
drm_intel_gem_bo_unmap_gtt(staging_bo);
......@@ -204,7 +204,7 @@ static void test_partial_read_writes(void)
if (tmp[j] != val) {
printf("mismatch in read at %i, got: %i, expected: %i\n",
j, tmp[j], val);
exit(1);
igt_fail(1);
}
}
......@@ -229,21 +229,21 @@ static void test_partial_read_writes(void)
if (gtt_ptr[j] != val) {
printf("mismatch at %i, got: %i, expected: %i\n",
j, tmp[j], val);
exit(1);
igt_fail(1);
}
}
for (; j < start + len; j++) {
if (gtt_ptr[j] != tmp[0]) {
printf("mismatch at %i, got: %i, expected: %i\n",
j, tmp[j], tmp[0]);
exit(1);
igt_fail(1);
}
}
for (; j < BO_SIZE; j++) {
if (gtt_ptr[j] != val) {
printf("mismatch at %i, got: %i, expected: %i\n",
j, tmp[j], val);
exit(1);
igt_fail(1);
}
}
drm_intel_gem_bo_unmap_gtt(staging_bo);
......
......@@ -75,7 +75,7 @@ store_pipe_control_loop(void)
target_bo = drm_intel_bo_alloc(bufmgr, "target bo", 4096, 4096);
if (!target_bo) {
fprintf(stderr, "failed to alloc target buffer\n");
exit(-1);
igt_fail(-1);
}
/* gem_storedw_batches_loop.c is a bit overenthusiastic with
......@@ -122,7 +122,7 @@ store_pipe_control_loop(void)
fprintf(stderr,
"value mismatch: cur 0x%08x, stored 0x%08x\n",
buf[0], val);
exit(-1);
igt_fail(-1);
}
buf[0] = 0; /* let batch write it again */
drm_intel_bo_unmap(target_bo);
......@@ -141,7 +141,7 @@ int main(int argc, char **argv)
if (argc != 1) {
fprintf(stderr, "usage: %s\n", argv[0]);
exit(-1);
igt_fail(-1);
}
fd = drm_open_any();
......@@ -150,7 +150,7 @@ int main(int argc, char **argv)
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
if (!bufmgr) {
fprintf(stderr, "failed to init libdrm\n");
exit(-1);
igt_fail(-1);
}
if (IS_GEN2(devid) || IS_GEN3(devid)) {
......@@ -169,7 +169,7 @@ int main(int argc, char **argv)
batch = intel_batchbuffer_alloc(bufmgr, devid);
if (!batch) {
fprintf(stderr, "failed to create batch buffer\n");
exit(-1);
igt_fail(-1);
}
store_pipe_control_loop();
......
......@@ -71,8 +71,11 @@ int main(int argc, char *argv[])
fd = drm_open_any();
reg_read.offset = 0x2358;
if (drmIoctl(fd, REG_READ_IOCTL, &reg_read))
exit(errno == EINVAL ? 77 : EXIT_FAILURE);
if (drmIoctl(fd, REG_READ_IOCTL, &reg_read)) {
if (errno == EINVAL)
igt_skip();
igt_fail(1);
}
reg_read.val = timer_query(fd);
sleep(1);
......
......@@ -190,7 +190,7 @@ int main(int argc, char **argv)
drm_intel_bo_get_subdata(pc_target_bo[i], 0, 4, &test);
if (test != 0xdeadbeef) {
fprintf(stderr, "mismatch in buffer %i: 0x%08x instead of 0xdeadbeef\n", i, test);
exit(1);
igt_fail(1);
}
drm_intel_bo_unreference(pc_target_bo[i]);
}
......
......@@ -97,7 +97,7 @@ int main(int argc, char **argv)
if (argc != 1) {
fprintf(stderr, "usage: %s\n", argv[0]);
exit(-1);
igt_fail(-1);
}
fd = drm_open_any();
......@@ -111,20 +111,20 @@ int main(int argc, char **argv)
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
if (!bufmgr) {
fprintf(stderr, "failed to init libdrm\n");
exit(-1);
igt_fail(-1);
}
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
batch = intel_batchbuffer_alloc(bufmgr, devid);
if (!batch) {
fprintf(stderr, "failed to create batch buffer\n");
exit(-1);
igt_fail(-1);
}
target_buffer = drm_intel_bo_alloc(bufmgr, "target bo", 4096, 4096);
if (!target_buffer) {
fprintf(stderr, "failed to alloc target buffer\n");
exit(-1);
igt_fail(-1);
}
store_dword_loop(fd);
......
......@@ -556,7 +556,7 @@ static void print_usage(const char *s)
printf(" -p --prewrap=n set seqno to WRAP - n for each testrun\n");
printf(" -r --norandom dont randomize prewrap space\n");
printf(" -i --buffers number of buffers to copy\n");
exit(-1);
igt_fail(-1);
}
static void parse_options(int argc, char **argv)
......
......@@ -63,7 +63,7 @@ store_dword_loop(int divider)
cmd_bo = drm_intel_bo_alloc(bufmgr, "cmd bo", 4096, 4096);
if (!cmd_bo) {
fprintf(stderr, "failed to alloc cmd bo\n");
exit(-1);
igt_fail(-1);
}
drm_intel_bo_map(cmd_bo, 1);
......@@ -77,7 +77,7 @@ store_dword_loop(int divider)
ret = drm_intel_bo_references(cmd_bo, target_bo);
if (ret) {
fprintf(stderr, "failed to link cmd & target bos\n");
exit(-1);
igt_fail(-1);
}
ret = drm_intel_bo_emit_reloc(cmd_bo, 8, target_bo, 0,
......@@ -85,7 +85,7 @@ store_dword_loop(int divider)
I915_GEM_DOMAIN_INSTRUCTION);
if (ret) {
fprintf(stderr, "failed to emit reloc\n");
exit(-1);
igt_fail(-1);
}
buf[4] = MI_BATCH_BUFFER_END;
......@@ -96,13 +96,13 @@ store_dword_loop(int divider)
ret = drm_intel_bo_references(cmd_bo, target_bo);
if (ret != 1) {
fprintf(stderr, "bad bo reference count: %d\n", ret);
exit(-1);
igt_fail(-1);
}
ret = drm_intel_bo_exec(cmd_bo, 6 * 4, NULL, 0, 0);
if (ret) {
fprintf(stderr, "bo exec failed: %d\n", ret);
exit(-1);
igt_fail(-1);
}
if (i % divider != 0)
......@@ -117,7 +117,7 @@ store_dword_loop(int divider)
fprintf(stderr,
"value mismatch: cur 0x%08x, stored 0x%08x\n",
buf[0], 0x42000000 | val);
exit(-1);
igt_fail(-1);
}
buf[0] = 0; /* let batch write it again */
drm_intel_bo_unmap(target_bo);
......@@ -140,7 +140,7 @@ int main(int argc, char **argv)
if (argc != 1) {
fprintf(stderr, "usage: %s\n", argv[0]);
exit(-1);
igt_fail(-1);
}
fd = drm_open_any();
......@@ -159,14 +159,14 @@ int main(int argc, char **argv)
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
if (!bufmgr) {
fprintf(stderr, "failed to init libdrm\n");
exit(-1);
igt_fail(-1);
}
// drm_intel_bufmgr_gem_enable_reuse(bufmgr);
target_bo = drm_intel_bo_alloc(bufmgr, "target bo", 4096, 4096);
if (!target_bo) {
fprintf(stderr, "failed to alloc target buffer\n");
exit(-1);
igt_fail(-1);
}
store_dword_loop(1);
......
......@@ -83,7 +83,7 @@ store_dword_loop(int divider)
fprintf(stderr,
"value mismatch: cur 0x%08x, stored 0x%08x\n",
buf[0], val);
exit(-1);
igt_fail(-1);
}
drm_intel_bo_unmap(target_buffer);
......@@ -107,7 +107,7 @@ int main(int argc, char **argv)
if (argc != 1) {
fprintf(stderr, "usage: %s\n", argv[0]);
exit(-1);
igt_fail(-1);
}
fd = drm_open_any();
......@@ -131,20 +131,20 @@ int main(int argc, char **argv)
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
if (!bufmgr) {
fprintf(stderr, "failed to init libdrm\n");
exit(-1);
igt_fail(-1);
}
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
batch = intel_batchbuffer_alloc(bufmgr, devid);
if (!batch) {
fprintf(stderr, "failed to create batch buffer\n");
exit(-1);
igt_fail(-1);
}
target_buffer = drm_intel_bo_alloc(bufmgr, "target bo", 4096, 4096);
if (!target_buffer) {
fprintf(stderr, "failed to alloc target buffer\n");
exit(-1);
igt_fail(-1);
}
store_dword_loop(1);
......
......@@ -83,7 +83,7 @@ store_dword_loop(int divider)
fprintf(stderr,
"value mismatch: cur 0x%08x, stored 0x%08x\n",
buf[0], val);
exit(-1);
igt_fail(-1);
}
drm_intel_bo_unmap(target_buffer);
......@@ -107,7 +107,7 @@ int main(int argc, char **argv)
if (argc != 1) {
fprintf(stderr, "usage: %s\n", argv[0]);
exit(-1);
igt_fail(-1);
}
fd = drm_open_any();
......@@ -137,20 +137,20 @@ int main(int argc, char **argv)
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
if (!bufmgr) {
fprintf(stderr, "failed to init libdrm\n");
exit(-1);
igt_fail(-1);
}
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
batch = intel_batchbuffer_alloc(bufmgr, devid);
if (!batch) {
fprintf(stderr, "failed to create batch buffer\n");
exit(-1);
igt_fail(-1);
}
target_buffer = drm_intel_bo_alloc(bufmgr, "target bo", 4096, 4096);
if (!target_buffer) {
fprintf(stderr, "failed to alloc target buffer\n");
exit(-1);
igt_fail(-1);
}
store_dword_loop(1);
......
......@@ -83,7 +83,7 @@ store_dword_loop(int divider)
fprintf(stderr,
"value mismatch: cur 0x%08x, stored 0x%08x\n",
buf[0], val);
exit(-1);
igt_fail(-1);
}
drm_intel_bo_unmap(target_buffer);
......@@ -107,7 +107,7 @@ int main(int argc, char **argv)
if (argc != 1) {
fprintf(stderr, "usage: %s\n", argv[0]);
exit(-1);
igt_fail(-1);
}
fd = drm_open_any();
......@@ -125,20 +125,20 @@ int main(int argc, char **argv)
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
if (!bufmgr) {
fprintf(stderr, "failed to init libdrm\n");
exit(-1);
igt_fail(-1);
}
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
batch = intel_batchbuffer_alloc(bufmgr, devid);
if (!batch) {
fprintf(stderr, "failed to create batch buffer\n");
exit(-1);
igt_fail(-1);
}
target_buffer = drm_intel_bo_alloc(bufmgr, "target bo", 4096, 4096);
if (!target_buffer) {
fprintf(stderr, "failed to alloc target buffer\n");
exit(-1);
igt_fail(-1);
}
store_dword_loop(1);
......
......@@ -79,7 +79,7 @@ store_dword_loop(int divider)
fprintf(stderr,
"value mismatch: cur 0x%08x, stored 0x%08x\n",
buf[0], val);
exit(-1);
igt_fail(-1);
}
drm_intel_bo_unmap(target_buffer);
......@@ -109,20 +109,20 @@ int main(int argc, char **argv)
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
if (!bufmgr) {
fprintf(stderr, "failed to init libdrm\n");
exit(-1);
igt_fail(-1);
}
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
if (!batch) {
fprintf(stderr, "failed to create batch buffer\n");