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