mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-18 13:26:30 +00:00
tests: Use igt macros more
Often just folding together of the common if (cond) printf; abort|igt_skip|igt_fail; pattern. But in a few cases I've ripped out more since the igt macros will already print the condition and errno. A few tests where more work (like ripping out return codes en masse) is needed left as-is. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
e624fa8a2e
commit
0b7ce4ac29
@ -43,19 +43,6 @@ struct local_drm_i915_context_destroy {
|
||||
|
||||
#define CONTEXT_DESTROY_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x2e, struct local_drm_i915_context_destroy)
|
||||
|
||||
static void handle_bad(int ret, int lerrno, int expected, const char *desc)
|
||||
{
|
||||
if (ret != 0 && lerrno != expected) {
|
||||
fprintf(stderr, "%s - errno was %d, but should have been %d\n",
|
||||
desc, lerrno, expected);
|
||||
igt_fail(1);
|
||||
} else if (ret == 0) {
|
||||
fprintf(stderr, "%s - Command succeeded, but should have failed\n",
|
||||
desc);
|
||||
igt_fail(1);
|
||||
}
|
||||
}
|
||||
|
||||
igt_simple_main
|
||||
{
|
||||
struct local_drm_i915_context_destroy destroy;
|
||||
@ -75,17 +62,17 @@ igt_simple_main
|
||||
|
||||
/* try double destroy */
|
||||
ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
|
||||
handle_bad(ret, errno, ENOENT, "double destroy");
|
||||
igt_assert(ret != 0 && errno == ENOENT);
|
||||
|
||||
/* destroy something random */
|
||||
destroy.ctx_id = 2;
|
||||
ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
|
||||
handle_bad(ret, errno, ENOENT, "random destroy");
|
||||
igt_assert(ret != 0 && errno == ENOENT);
|
||||
|
||||
/* Try to destroy the default context */
|
||||
destroy.ctx_id = 0;
|
||||
ret = drmIoctl(fd, CONTEXT_DESTROY_IOCTL, &destroy);
|
||||
handle_bad(ret, errno, ENOENT, "default destroy");
|
||||
igt_assert(ret != 0 && errno == ENOENT);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
@ -52,13 +52,8 @@ igt_simple_main
|
||||
fd = drm_open_any_render();
|
||||
|
||||
ret = drmIoctl(fd, CONTEXT_CREATE_IOCTL, &create);
|
||||
if (ret != 0 && (errno == ENODEV || errno == EINVAL)) {
|
||||
igt_skip("Kernel is too old, or contexts not supported: %s\n",
|
||||
strerror(errno));
|
||||
} else if (ret != 0) {
|
||||
fprintf(stderr, "%s\n", strerror(errno));
|
||||
igt_fail(1);
|
||||
}
|
||||
igt_skip_on(ret != 0 && (errno == ENODEV || errno == EINVAL));
|
||||
igt_assert(ret == 0);
|
||||
igt_assert(create.ctx_id != 0);
|
||||
|
||||
close(fd);
|
||||
|
@ -205,11 +205,8 @@ igt_main
|
||||
{
|
||||
unsigned int target_flink;
|
||||
char buffer_name[32];
|
||||
if (dri_bo_flink(target_buffer, &target_flink)) {
|
||||
igt_info("fail to get flink for target buffer\n");
|
||||
igt_assert_f(0, "fail to create global "
|
||||
"gem_handle for target buffer\n");
|
||||
}
|
||||
igt_assert(dri_bo_flink(target_buffer, &target_flink) == 0);
|
||||
|
||||
for (i = 0; i < NUM_FD; i++) {
|
||||
sprintf(buffer_name, "Target buffer %d\n", i);
|
||||
mfd[i] = drm_open_any();
|
||||
|
@ -72,11 +72,9 @@ int main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "usage: %s <disabled pipe number>\n",
|
||||
argv[0]);
|
||||
igt_fail(-1);
|
||||
}
|
||||
igt_assert_f(argc == 2,
|
||||
"usage: %s <disabled pipe number>\n",
|
||||
argv[0]);
|
||||
|
||||
bad_pipe = atoi(argv[1]);
|
||||
|
||||
|
@ -178,12 +178,10 @@ check_bo(int fd, uint32_t handle, uint32_t val)
|
||||
|
||||
gem_read(fd, handle, 0, linear, sizeof(linear));
|
||||
for (i = 0; i < WIDTH*HEIGHT; i++) {
|
||||
if (linear[i] != val) {
|
||||
fprintf(stderr, "Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, linear[i], i * 4);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(linear[i] == val,
|
||||
"Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, linear[i], i * 4);
|
||||
val++;
|
||||
}
|
||||
}
|
||||
|
@ -169,16 +169,8 @@ static int many_exec(int fd, uint32_t batch, int num_exec, int num_reloc, unsign
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define _fail(x) ((x) == -ENOENT)
|
||||
#define ASSERT(x, y) do { \
|
||||
if (!(x)) { \
|
||||
fprintf(stderr, "%s:%d failed, errno=%d\n", \
|
||||
__FUNCTION__, __LINE__, -y); \
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
#define fail(x) ASSERT(_fail(x), x)
|
||||
#define pass(x) ASSERT(!_fail(x), x)
|
||||
#define fail(x) igt_assert((x) == -ENOENT)
|
||||
#define pass(x) igt_assert((x) == 0)
|
||||
|
||||
igt_simple_main
|
||||
{
|
||||
|
@ -92,11 +92,9 @@ scratch_buf_check(data_t *data, struct igt_buf *buf, int x, int y,
|
||||
gem_read(data->drm_fd, buf->bo->handle, 0,
|
||||
data->linear, sizeof(data->linear));
|
||||
val = data->linear[y * WIDTH + x];
|
||||
if (val != color) {
|
||||
fprintf(stderr, "Expected 0x%02x, found 0x%02x at (%d,%d)\n",
|
||||
color, val, x, y);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(val == color,
|
||||
"Expected 0x%02x, found 0x%02x at (%d,%d)\n",
|
||||
color, val, x, y);
|
||||
}
|
||||
|
||||
igt_simple_main
|
||||
|
@ -59,11 +59,7 @@ create_and_map_bo(int fd)
|
||||
handle = gem_create(fd, OBJECT_SIZE);
|
||||
|
||||
ptr = gem_mmap(fd, handle, OBJECT_SIZE, PROT_READ | PROT_WRITE);
|
||||
|
||||
if (!ptr) {
|
||||
fprintf(stderr, "mmap failed\n");
|
||||
igt_assert(ptr);
|
||||
}
|
||||
igt_assert(ptr);
|
||||
|
||||
/* touch it to force it into the gtt */
|
||||
*ptr = 0;
|
||||
|
@ -125,12 +125,8 @@ igt_simple_main
|
||||
{
|
||||
unsigned int target_flink;
|
||||
char buffer_name[32];
|
||||
if (dri_bo_flink(target_buffer, &target_flink)) {
|
||||
printf("fail to get flink for target buffer\n");
|
||||
igt_assert_f(0, "fail to create global gem handle"
|
||||
" for allocated buffer\n");
|
||||
goto fail_flink;
|
||||
}
|
||||
igt_assert(dri_bo_flink(target_buffer, &target_flink) == 0);
|
||||
|
||||
for (i = 0; i < NUM_FD; i++) {
|
||||
sprintf(buffer_name, "Target buffer %d\n", i);
|
||||
mfd[i] = drm_open_any();
|
||||
@ -164,12 +160,5 @@ igt_simple_main
|
||||
drm_intel_bo_unreference(target_buffer);
|
||||
drm_intel_bufmgr_destroy(bufmgr);
|
||||
|
||||
close(fd);
|
||||
return;
|
||||
|
||||
fail_flink:
|
||||
drm_intel_bo_unreference(target_buffer);
|
||||
drm_intel_bufmgr_destroy(bufmgr);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
@ -88,13 +88,10 @@ verify_large_read(drm_intel_bo *bo, uint32_t val)
|
||||
drm_intel_bo_get_subdata(bo, 0, size, buf);
|
||||
|
||||
for (i = 0; i < size / 4; i++) {
|
||||
if (buf[i] != val) {
|
||||
fprintf(stderr,
|
||||
"Unexpected value 0x%08x instead of "
|
||||
"0x%08x at offset 0x%08x (%p)\n",
|
||||
buf[i], val, i * 4, buf);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(buf[i] == val,
|
||||
"Unexpected value 0x%08x instead of "
|
||||
"0x%08x at offset 0x%08x (%p)\n",
|
||||
buf[i], val, i * 4, buf);
|
||||
val++;
|
||||
}
|
||||
}
|
||||
@ -113,13 +110,10 @@ verify_small_read(drm_intel_bo *bo, uint32_t val)
|
||||
drm_intel_bo_get_subdata(bo, offset, PAGE_SIZE, buf);
|
||||
|
||||
for (i = 0; i < PAGE_SIZE; i += 4) {
|
||||
if (buf[i / 4] != val) {
|
||||
fprintf(stderr,
|
||||
"Unexpected value 0x%08x instead of "
|
||||
"0x%08x at offset 0x%08x\n",
|
||||
buf[i / 4], val, i * 4);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(buf[i / 4] == val,
|
||||
"Unexpected value 0x%08x instead of "
|
||||
"0x%08x at offset 0x%08x\n",
|
||||
buf[i / 4], val, i * 4);
|
||||
val++;
|
||||
}
|
||||
}
|
||||
|
@ -39,19 +39,6 @@ struct local_drm_i915_reg_read {
|
||||
|
||||
#define REG_READ_IOCTL DRM_IOWR(DRM_COMMAND_BASE + 0x31, struct local_drm_i915_reg_read)
|
||||
|
||||
static void handle_bad(int ret, int expected, const char *desc)
|
||||
{
|
||||
if (ret != 0 && errno != expected) {
|
||||
fprintf(stderr, "%s - errno was %d, but should have been %d\n",
|
||||
desc, errno, expected);
|
||||
igt_fail(1);
|
||||
} else if (ret == 0) {
|
||||
fprintf(stderr, "%s - Command succeeded, but should have failed\n",
|
||||
desc);
|
||||
igt_fail(1);
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t timer_query(int fd)
|
||||
{
|
||||
struct local_drm_i915_reg_read reg_read;
|
||||
@ -79,15 +66,14 @@ igt_simple_main
|
||||
|
||||
reg_read.val = timer_query(fd);
|
||||
sleep(1);
|
||||
if (timer_query(fd) == reg_read.val) {
|
||||
fprintf(stderr, "Timer isn't moving, probably busted\n");
|
||||
igt_fail(1);
|
||||
}
|
||||
/* Check that timer is moving and isn't busted. */
|
||||
igt_assert(timer_query(fd) != reg_read.val);
|
||||
|
||||
/* bad reg */
|
||||
reg_read.offset = 0x12345678;
|
||||
handle_bad(drmIoctl(fd, REG_READ_IOCTL, ®_read),
|
||||
EINVAL, "bad register");
|
||||
ret = drmIoctl(fd, REG_READ_IOCTL, ®_read);
|
||||
|
||||
igt_assert(ret != 0 && errno == ENOENT);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
@ -80,10 +80,7 @@ static void scratch_buf_write_to_png(struct igt_buf *buf, const char *filename)
|
||||
igt_buf_height(buf),
|
||||
buf->stride);
|
||||
ret = cairo_surface_write_to_png(surface, filename);
|
||||
if (ret != CAIRO_STATUS_SUCCESS) {
|
||||
fprintf(stderr, "%s: %s\n", __func__,
|
||||
cairo_status_to_string(ret));
|
||||
}
|
||||
igt_assert(ret == CAIRO_STATUS_SUCCESS);
|
||||
cairo_surface_destroy(surface);
|
||||
drm_intel_bo_unmap(buf->bo);
|
||||
}
|
||||
@ -115,11 +112,9 @@ scratch_buf_check(data_t *data, struct igt_buf *buf, int x, int y,
|
||||
gem_read(data->drm_fd, buf->bo->handle, 0,
|
||||
data->linear, sizeof(data->linear));
|
||||
val = data->linear[y * WIDTH + x];
|
||||
if (val != color) {
|
||||
fprintf(stderr, "Expected 0x%08x, found 0x%08x at (%d,%d)\n",
|
||||
color, val, x, y);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(val == color,
|
||||
"Expected 0x%08x, found 0x%08x at (%d,%d)\n",
|
||||
color, val, x, y);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
@ -128,11 +128,9 @@ scratch_buf_check(data_t *data, struct igt_buf *buf, int x, int y,
|
||||
gem_read(data->fd, buf->bo->handle, 0,
|
||||
data->linear, sizeof(data->linear));
|
||||
val = data->linear[y * WIDTH + x];
|
||||
if (val != color) {
|
||||
fprintf(stderr, "Expected 0x%08x, found 0x%08x at (%d,%d)\n",
|
||||
color, val, x, y);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(val == color,
|
||||
"Expected 0x%08x, found 0x%08x at (%d,%d)\n",
|
||||
color, val, x, y);
|
||||
}
|
||||
|
||||
static void copy(data_t *data)
|
||||
|
@ -73,12 +73,10 @@ check_bo(int fd, uint32_t handle, uint32_t val)
|
||||
|
||||
gem_read(fd, handle, 0, linear, sizeof(linear));
|
||||
for (i = 0; i < WIDTH*HEIGHT; i++) {
|
||||
if (linear[i] != val) {
|
||||
fprintf(stderr, "Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, linear[i], i * 4);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(linear[i] == val,
|
||||
"Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, linear[i], i * 4);
|
||||
val++;
|
||||
}
|
||||
}
|
||||
@ -97,10 +95,7 @@ int main(int argc, char **argv)
|
||||
fd = drm_open_any();
|
||||
|
||||
render_copy = igt_get_render_copyfunc(intel_get_drm_devid(fd));
|
||||
if (render_copy == NULL) {
|
||||
printf("no render-copy function, doing nothing\n");
|
||||
return 77;
|
||||
}
|
||||
igt_require(render_copy);
|
||||
|
||||
bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
|
||||
batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
|
||||
|
@ -85,12 +85,10 @@ check_bo(struct intel_batchbuffer *batch, struct igt_buf *buf, uint32_t val)
|
||||
ptr = data;
|
||||
}
|
||||
for (i = 0; i < WIDTH*HEIGHT; i++) {
|
||||
if (ptr[i] != val) {
|
||||
fprintf(stderr, "Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, ptr[i], i * 4);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(ptr[i] == val,
|
||||
"Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, ptr[i], i * 4);
|
||||
val++;
|
||||
}
|
||||
if (ptr != data)
|
||||
@ -115,10 +113,7 @@ int main(int argc, char **argv)
|
||||
devid = intel_get_drm_devid(fd);
|
||||
|
||||
render_copy = igt_get_render_copyfunc(devid);
|
||||
if (render_copy == NULL) {
|
||||
printf("no render-copy function, doing nothing\n");
|
||||
return 77;
|
||||
}
|
||||
igt_require(render_copy);
|
||||
|
||||
snoop = 1;
|
||||
if (IS_GEN2(devid)) /* chipset only handles cached -> uncached */
|
||||
|
@ -134,8 +134,9 @@ static void do_test(uint32_t tiling, unsigned stride,
|
||||
/* note we need a bo bigger than batches, otherwise the buffer reuse
|
||||
* trick will fail. */
|
||||
test_bo = drm_intel_bo_alloc(bufmgr, "busy bo", TEST_SIZE, 4096);
|
||||
if (test_bo_handle != test_bo->handle)
|
||||
fprintf(stderr, "libdrm reuse trick failed\n");
|
||||
/* double check that the reuse trick worked */
|
||||
igt_assert(test_bo_handle == test_bo->handle);
|
||||
|
||||
test_bo_handle = test_bo->handle;
|
||||
/* ensure we have the right tiling before we start. */
|
||||
ret = drm_intel_bo_set_tiling(test_bo, &tiling, stride);
|
||||
@ -176,8 +177,8 @@ static void do_test(uint32_t tiling, unsigned stride,
|
||||
drm_intel_bo_unreference(test_bo);
|
||||
|
||||
test_bo = drm_intel_bo_alloc_for_render(bufmgr, "tiled busy bo", TEST_SIZE, 4096);
|
||||
if (test_bo_handle != test_bo->handle)
|
||||
fprintf(stderr, "libdrm reuse trick failed\n");
|
||||
/* double check that the reuse trick worked */
|
||||
igt_assert(test_bo_handle == test_bo->handle);
|
||||
ret = drm_intel_bo_set_tiling(test_bo, &tiling_after, stride_after);
|
||||
igt_assert(ret == 0);
|
||||
|
||||
|
@ -105,13 +105,11 @@ igt_simple_main
|
||||
+ half*tile_height + ofs;
|
||||
uint32_t val = data[data_i];
|
||||
|
||||
if (ptr[i] != val) {
|
||||
printf("mismatch at %i, row=%i, half=%i, ofs=%i\n",
|
||||
i, row, half, ofs);
|
||||
printf("read: 0x%08x, expected: 0x%08x\n",
|
||||
ptr[i], val);
|
||||
igt_assert(0);
|
||||
}
|
||||
igt_assert_f(ptr[i] == val,
|
||||
"mismatch at %i, row=%i, half=%i, ofs=%i, "
|
||||
"read: 0x%08x, expected: 0x%08x\n",
|
||||
i, row, half, ofs,
|
||||
ptr[i], val);
|
||||
|
||||
}
|
||||
|
||||
|
@ -80,12 +80,7 @@ store_dword_loop(int divider)
|
||||
drm_intel_bo_map(target_buffer, 0);
|
||||
|
||||
buf = target_buffer->virtual;
|
||||
if (buf[0] != val) {
|
||||
fprintf(stderr,
|
||||
"value mismatch: cur 0x%08x, stored 0x%08x\n",
|
||||
buf[0], val);
|
||||
igt_fail(-1);
|
||||
}
|
||||
igt_assert_cmpint (buf[0], ==, val);
|
||||
|
||||
drm_intel_bo_unmap(target_buffer);
|
||||
|
||||
|
@ -105,12 +105,10 @@ check_bo(drm_intel_bo *bo, uint32_t start_val)
|
||||
linear = linear_bo->virtual;
|
||||
|
||||
for (i = 0; i < 1024 * 1024 / 4; i++) {
|
||||
if (linear[i] != start_val) {
|
||||
fprintf(stderr, "Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
start_val, linear[i], i * 4);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(linear[i] == start_val,
|
||||
"Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
start_val, linear[i], i * 4);
|
||||
start_val++;
|
||||
}
|
||||
drm_intel_bo_unmap(linear_bo);
|
||||
|
@ -94,12 +94,10 @@ check_bo(int fd, drm_intel_bo *bo, uint32_t start_val)
|
||||
gem_read(fd, bo->handle, 0, linear, sizeof(linear));
|
||||
|
||||
for (i = 0; i < 1024 * 1024 / 4; i++) {
|
||||
if (linear[i] != start_val) {
|
||||
fprintf(stderr, "Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
start_val, linear[i], i * 4);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(linear[i] == start_val,
|
||||
"Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
start_val, linear[i], i * 4);
|
||||
start_val++;
|
||||
}
|
||||
}
|
||||
|
@ -211,21 +211,17 @@ igt_simple_main
|
||||
swizzle_str = "bit9^10^11";
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Bad swizzle bits; %d\n",
|
||||
swizzle);
|
||||
abort();
|
||||
igt_assert_f(0, "Bad swizzle bits; %d\n",
|
||||
swizzle);
|
||||
}
|
||||
expected_val = calculate_expected(swizzled_offset);
|
||||
found_val = linear[(j - offset) / 4];
|
||||
if (expected_val != found_val) {
|
||||
fprintf(stderr,
|
||||
"Bad read [%d]: %d instead of %d at 0x%08x "
|
||||
"for read from 0x%08x to 0x%08x, swizzle=%s\n",
|
||||
i, found_val, expected_val, j,
|
||||
offset, offset + len,
|
||||
swizzle_str);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(expected_val == found_val,
|
||||
"Bad read [%d]: %d instead of %d at 0x%08x "
|
||||
"for read from 0x%08x to 0x%08x, swizzle=%s\n",
|
||||
i, found_val, expected_val, j,
|
||||
offset, offset + len,
|
||||
swizzle_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -401,12 +401,10 @@ check_cpu(uint32_t *ptr, uint32_t val)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < WIDTH*HEIGHT; i++) {
|
||||
if (ptr[i] != val) {
|
||||
fprintf(stderr, "Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, ptr[i], i * 4);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(ptr[i] == val,
|
||||
"Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, ptr[i], i * 4);
|
||||
val++;
|
||||
}
|
||||
}
|
||||
@ -770,11 +768,7 @@ static int test_coherency(int fd, int count)
|
||||
igt_info("Using 2x%d 1MiB buffers\n", count);
|
||||
|
||||
ret = posix_memalign((void **)&memory, PAGE_SIZE, count*sizeof(linear));
|
||||
if (ret != 0 || memory == NULL) {
|
||||
fprintf(stderr, "Unable to allocate %lld bytes\n",
|
||||
(long long)count*sizeof(linear));
|
||||
return 1;
|
||||
}
|
||||
igt_assert(ret == 0 && memory);
|
||||
|
||||
gpu = malloc(sizeof(uint32_t)*count*4);
|
||||
gpu_val = gpu + count;
|
||||
|
@ -448,12 +448,10 @@ check_bo(int fd, uint32_t handle, uint32_t val)
|
||||
v = gem_mmap(fd, handle, WIDTH*HEIGHT*4, PROT_READ);
|
||||
igt_assert(v);
|
||||
for (i = 0; i < WIDTH*HEIGHT; i++) {
|
||||
if (v[i] != val) {
|
||||
fprintf(stderr, "Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, v[i], i * 4);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(v[i] == val,
|
||||
"Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, v[i], i * 4);
|
||||
val++;
|
||||
}
|
||||
munmap(v, WIDTH*HEIGHT*4);
|
||||
@ -469,10 +467,7 @@ int main(int argc, char **argv)
|
||||
|
||||
fd = drm_open_any();
|
||||
|
||||
if (!IS_GEN3(intel_get_drm_devid(fd))) {
|
||||
printf("gen3-only test, doing nothing\n");
|
||||
return 77;
|
||||
}
|
||||
igt_require(IS_GEN3(intel_get_drm_devid(fd)));
|
||||
|
||||
count = 0;
|
||||
if (argc > 1)
|
||||
|
@ -317,12 +317,10 @@ check_bo(int fd, uint32_t handle, uint32_t val)
|
||||
|
||||
gem_read(fd, handle, 0, linear, sizeof(linear));
|
||||
for (i = 0; i < WIDTH*HEIGHT; i++) {
|
||||
if (linear[i] != val) {
|
||||
fprintf(stderr, "Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, linear[i], i * 4);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(linear[i] == val,
|
||||
"Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, linear[i], i * 4);
|
||||
val++;
|
||||
}
|
||||
}
|
||||
@ -337,10 +335,7 @@ int main(int argc, char **argv)
|
||||
|
||||
fd = drm_open_any();
|
||||
|
||||
if (!IS_GEN3(intel_get_drm_devid(fd))) {
|
||||
printf("gen3-only test, doing nothing\n");
|
||||
return 77;
|
||||
}
|
||||
igt_require(IS_GEN3(intel_get_drm_devid(fd)));
|
||||
|
||||
count = 0;
|
||||
if (argc > 1)
|
||||
|
@ -336,12 +336,10 @@ check_bo(int fd, uint32_t handle, uint32_t val)
|
||||
v = gem_mmap(fd, handle, WIDTH*HEIGHT*4, PROT_READ);
|
||||
igt_assert(v);
|
||||
for (i = 0; i < WIDTH*HEIGHT; i++) {
|
||||
if (v[i] != val) {
|
||||
fprintf(stderr, "Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, v[i], i * 4);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(v[i] == val,
|
||||
"Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, v[i], i * 4);
|
||||
val++;
|
||||
}
|
||||
munmap(v, WIDTH*HEIGHT*4);
|
||||
@ -357,10 +355,7 @@ int main(int argc, char **argv)
|
||||
|
||||
fd = drm_open_any();
|
||||
|
||||
if (!IS_GEN3(intel_get_drm_devid(fd))) {
|
||||
printf("gen3-only test, doing nothing\n");
|
||||
return 77;
|
||||
}
|
||||
igt_require(IS_GEN3(intel_get_drm_devid(fd)));
|
||||
|
||||
count = 0;
|
||||
if (argc > 1)
|
||||
|
@ -323,12 +323,10 @@ check_bo(int fd, uint32_t handle, uint32_t val)
|
||||
v = gem_mmap(fd, handle, WIDTH*HEIGHT*4, PROT_READ);
|
||||
igt_assert(v);
|
||||
for (i = 0; i < WIDTH*HEIGHT; i++) {
|
||||
if (v[i] != val) {
|
||||
fprintf(stderr, "Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, v[i], i * 4);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(v[i] == val,
|
||||
"Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, v[i], i * 4);
|
||||
val++;
|
||||
}
|
||||
munmap(v, WIDTH*HEIGHT*4);
|
||||
@ -344,10 +342,7 @@ int main(int argc, char **argv)
|
||||
|
||||
fd = drm_open_any();
|
||||
|
||||
if (!IS_GEN3(intel_get_drm_devid(fd))) {
|
||||
printf("gen3-only test, doing nothing\n");
|
||||
return 77;
|
||||
}
|
||||
igt_require(IS_GEN3(intel_get_drm_devid(fd)));
|
||||
|
||||
count = 0;
|
||||
if (argc > 1)
|
||||
|
@ -323,12 +323,10 @@ check_bo(int fd, uint32_t handle, uint32_t val)
|
||||
v = gem_mmap(fd, handle, WIDTH*HEIGHT*4, PROT_READ);
|
||||
igt_assert(v);
|
||||
for (i = 0; i < WIDTH*HEIGHT; i++) {
|
||||
if (v[i] != val) {
|
||||
fprintf(stderr, "Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, v[i], i * 4);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(v[i] == val,
|
||||
"Expected 0x%08x, found 0x%08x "
|
||||
"at offset 0x%08x\n",
|
||||
val, v[i], i * 4);
|
||||
val++;
|
||||
}
|
||||
munmap(v, WIDTH*HEIGHT*4);
|
||||
@ -344,10 +342,7 @@ int main(int argc, char **argv)
|
||||
|
||||
fd = drm_open_any();
|
||||
|
||||
if (!IS_GEN3(intel_get_drm_devid(fd))) {
|
||||
printf("gen3-only test, doing nothing\n");
|
||||
return 77;
|
||||
}
|
||||
igt_require(IS_GEN3(intel_get_drm_devid(fd)));
|
||||
|
||||
count = 0;
|
||||
if (argc > 1)
|
||||
|
@ -709,10 +709,8 @@ int main(int argc, char **argv)
|
||||
|
||||
igt_skip_on_simulation();
|
||||
|
||||
if (dry_run && filter_test_id) {
|
||||
fprintf(stderr, "only one of -d and -t is accepted\n");
|
||||
exit(1);
|
||||
}
|
||||
igt_assert_f(!(dry_run && filter_test_id),
|
||||
"only one of -d and -t is accepted\n");
|
||||
|
||||
igt_fixture {
|
||||
drm_fd = drm_open_any();
|
||||
|
@ -38,44 +38,29 @@
|
||||
static int get_perf(const char *path)
|
||||
{
|
||||
int ret, perf;
|
||||
bool sink, source, enabled;
|
||||
FILE *file;
|
||||
char str[4];
|
||||
|
||||
file = fopen(path, "r");
|
||||
if (file == NULL) {
|
||||
fprintf(stderr, "Couldn't open %s (%d)\n", path, errno);
|
||||
abort();
|
||||
}
|
||||
igt_assert(file);
|
||||
|
||||
ret = fscanf(file, "Sink_Support: %s\n", str);
|
||||
if (ret == 0)
|
||||
igt_skip("i915_edp_psr_status format not supported by this test case\n");
|
||||
sink = strcmp(str, "yes") == 0;
|
||||
igt_skip_on_f(ret == 0,
|
||||
"i915_edp_psr_status format not supported by this test case\n");
|
||||
igt_require(strcmp(str, "yes") == 0);
|
||||
ret = fscanf(file, "Source_OK: %s\n", str);
|
||||
igt_assert(ret != 0);
|
||||
source = strcmp(str, "yes") == 0;
|
||||
|
||||
igt_require(strcmp(str, "yes") == 0);
|
||||
|
||||
ret = fscanf(file, "Enabled: %s\n", str);
|
||||
igt_assert(ret != 0);
|
||||
enabled = strcmp(str, "yes") == 0;
|
||||
igt_assert(strcmp(str, "yes") == 0);
|
||||
|
||||
ret = fscanf(file, "Performance_Counter: %i", &perf);
|
||||
igt_assert(ret != 0);
|
||||
|
||||
if (!sink)
|
||||
igt_skip("This panel does not support PSR.\n");
|
||||
|
||||
if (!source)
|
||||
igt_skip("This Hardware does not support or isn't ready for PSR\n");
|
||||
|
||||
if (!enabled) {
|
||||
fprintf(stderr, "PSR should be enabled\n");
|
||||
igt_fail(1);
|
||||
}
|
||||
|
||||
if (perf == 0) {
|
||||
fprintf(stderr, "PSR state never achieved\n");
|
||||
igt_fail(1);
|
||||
}
|
||||
igt_assert(perf);
|
||||
|
||||
fclose(file);
|
||||
return perf;
|
||||
@ -96,8 +81,6 @@ igt_simple_main
|
||||
sleep(SLEEP_DURATION / 1000);
|
||||
perf2 = get_perf(path);
|
||||
|
||||
if (perf1 == perf2) {
|
||||
fprintf(stderr, "Unable to enter PSR state again\n");
|
||||
igt_fail(1);
|
||||
}
|
||||
igt_assert_f(perf1 != perf2,
|
||||
"Unable to enter PSR state again\n");
|
||||
}
|
||||
|
@ -44,10 +44,8 @@ static unsigned int readit(const char *path)
|
||||
|
||||
FILE *file;
|
||||
file = fopen(path, "r");
|
||||
if (file == NULL) {
|
||||
fprintf(stderr, "Couldn't open %s (%d)\n", path, errno);
|
||||
abort();
|
||||
}
|
||||
igt_assert_f(file,
|
||||
"Couldn't open %s (%d)\n", path, errno);
|
||||
scanned = fscanf(file, "%u", &ret);
|
||||
igt_assert(scanned == 1);
|
||||
|
||||
@ -108,14 +106,10 @@ igt_simple_main
|
||||
(value2p - value1p) +
|
||||
(value2 - value1);
|
||||
|
||||
if (diff > (SLEEP_DURATION + RC6_FUDGE)) {
|
||||
fprintf(stderr, "Diff was too high. That is unpossible\n");
|
||||
igt_fail(1);
|
||||
}
|
||||
if (diff < (SLEEP_DURATION - RC6_FUDGE)) {
|
||||
fprintf(stderr, "GPU was not in RC6 long enough. Check that "
|
||||
"the GPU is as idle as possible (ie. no X, "
|
||||
"running and running no other tests)\n");
|
||||
igt_fail(1);
|
||||
}
|
||||
igt_assert_f(diff <= (SLEEP_DURATION + RC6_FUDGE),
|
||||
"Diff was too high. That is unpossible\n");
|
||||
igt_assert_f(diff >= (SLEEP_DURATION - RC6_FUDGE),
|
||||
"GPU was not in RC6 long enough. Check that "
|
||||
"the GPU is as idle as possible (ie. no X, "
|
||||
"running and running no other tests)\n");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user