mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-07-23 18:06:18 +00:00
tests/core_prop_blob: Fix core_prop_blob for android
core_prop_blob was using ioctls not in the android kernel. Added a igt_require_propblob() function and local defines/structures so the test will compile and skip on kernels where the feature is unsupported. v2: moved igt_require_propblob() to core_prop_blob.c (Daniel Vetter) Moved gem_blt.c to a seperate patch (Thomas Wood) Signed-off-by: Derek Morton <derek.j.morton@intel.com> [Thomas: fix compiler warning] Signed-off-by: Thomas Wood <thomas.wood@intel.com>
This commit is contained in:
parent
061a38fca0
commit
f050dc663d
@ -25,18 +25,35 @@
|
|||||||
* Daniel Stone <daniels@collabora.com>
|
* Daniel Stone <daniels@collabora.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "igt.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "drmtest.h"
|
|
||||||
#include "igt_debugfs.h"
|
|
||||||
#include "igt_kms.h"
|
|
||||||
#include "igt_aux.h"
|
|
||||||
|
|
||||||
IGT_TEST_DESCRIPTION("Tests behaviour of mass-data 'blob' properties.");
|
IGT_TEST_DESCRIPTION("Tests behaviour of mass-data 'blob' properties.");
|
||||||
|
|
||||||
|
struct local_drm_mode_get_blob {
|
||||||
|
uint32_t blob_id;
|
||||||
|
uint32_t length;
|
||||||
|
uint64_t data;
|
||||||
|
};
|
||||||
|
struct local_drm_mode_create_blob {
|
||||||
|
uint64_t data;
|
||||||
|
uint32_t length;
|
||||||
|
uint32_t blob_id;
|
||||||
|
};
|
||||||
|
struct local_drm_mode_destroy_blob {
|
||||||
|
uint32_t blob_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define LOCAL_DRM_IOCTL_MODE_GETPROPBLOB DRM_IOWR(0xAC, \
|
||||||
|
struct local_drm_mode_get_blob)
|
||||||
|
#define LOCAL_DRM_IOCTL_MODE_CREATEPROPBLOB DRM_IOWR(0xBD, \
|
||||||
|
struct local_drm_mode_create_blob)
|
||||||
|
#define LOCAL_DRM_IOCTL_MODE_DESTROYPROPBLOB DRM_IOWR(0xBE, \
|
||||||
|
struct local_drm_mode_destroy_blob)
|
||||||
|
|
||||||
static const struct drm_mode_modeinfo test_mode_valid = {
|
static const struct drm_mode_modeinfo test_mode_valid = {
|
||||||
.clock = 1234,
|
.clock = 1234,
|
||||||
.hdisplay = 640,
|
.hdisplay = 640,
|
||||||
@ -61,22 +78,35 @@ static const struct drm_mode_modeinfo test_mode_valid = {
|
|||||||
return errno; \
|
return errno; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void igt_require_propblob(int fd)
|
||||||
|
{
|
||||||
|
struct local_drm_mode_create_blob c;
|
||||||
|
struct local_drm_mode_destroy_blob d;
|
||||||
|
uint32_t blob_data;
|
||||||
|
c.data = (uintptr_t) &blob_data;
|
||||||
|
c.length = sizeof(blob_data);
|
||||||
|
|
||||||
|
igt_require(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_CREATEPROPBLOB, &c) == 0);
|
||||||
|
d.blob_id = c.blob_id;
|
||||||
|
igt_require(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_DESTROYPROPBLOB, &d) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
validate_prop(int fd, uint32_t prop_id)
|
validate_prop(int fd, uint32_t prop_id)
|
||||||
{
|
{
|
||||||
struct drm_mode_get_blob get;
|
struct local_drm_mode_get_blob get;
|
||||||
struct drm_mode_modeinfo ret_mode;
|
struct drm_mode_modeinfo ret_mode;
|
||||||
|
|
||||||
get.blob_id = prop_id;
|
get.blob_id = prop_id;
|
||||||
get.length = 0;
|
get.length = 0;
|
||||||
get.data = (uintptr_t) 0;
|
get.data = (uintptr_t) 0;
|
||||||
ioctl_or_ret_errno(fd, DRM_IOCTL_MODE_GETPROPBLOB, &get);
|
ioctl_or_ret_errno(fd, LOCAL_DRM_IOCTL_MODE_GETPROPBLOB, &get);
|
||||||
|
|
||||||
if (get.length != sizeof(test_mode_valid))
|
if (get.length != sizeof(test_mode_valid))
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
|
||||||
get.data = (uintptr_t) &ret_mode;
|
get.data = (uintptr_t) &ret_mode;
|
||||||
ioctl_or_ret_errno(fd, DRM_IOCTL_MODE_GETPROPBLOB, &get);
|
ioctl_or_ret_errno(fd, LOCAL_DRM_IOCTL_MODE_GETPROPBLOB, &get);
|
||||||
|
|
||||||
if (memcmp(&ret_mode, &test_mode_valid, sizeof(test_mode_valid)) != 0)
|
if (memcmp(&ret_mode, &test_mode_valid, sizeof(test_mode_valid)) != 0)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
@ -87,12 +117,12 @@ validate_prop(int fd, uint32_t prop_id)
|
|||||||
static uint32_t
|
static uint32_t
|
||||||
create_prop(int fd)
|
create_prop(int fd)
|
||||||
{
|
{
|
||||||
struct drm_mode_create_blob create;
|
struct local_drm_mode_create_blob create;
|
||||||
|
|
||||||
create.length = sizeof(test_mode_valid);
|
create.length = sizeof(test_mode_valid);
|
||||||
create.data = (uintptr_t) &test_mode_valid;
|
create.data = (uintptr_t) &test_mode_valid;
|
||||||
|
|
||||||
do_ioctl(fd, DRM_IOCTL_MODE_CREATEPROPBLOB, &create);
|
do_ioctl(fd, LOCAL_DRM_IOCTL_MODE_CREATEPROPBLOB, &create);
|
||||||
igt_assert_neq_u32(create.blob_id, 0);
|
igt_assert_neq_u32(create.blob_id, 0);
|
||||||
|
|
||||||
return create.blob_id;
|
return create.blob_id;
|
||||||
@ -101,10 +131,10 @@ create_prop(int fd)
|
|||||||
static int
|
static int
|
||||||
destroy_prop(int fd, uint32_t prop_id)
|
destroy_prop(int fd, uint32_t prop_id)
|
||||||
{
|
{
|
||||||
struct drm_mode_destroy_blob destroy;
|
struct local_drm_mode_destroy_blob destroy;
|
||||||
|
|
||||||
destroy.blob_id = prop_id;
|
destroy.blob_id = prop_id;
|
||||||
ioctl_or_ret_errno(fd, DRM_IOCTL_MODE_DESTROYPROPBLOB, &destroy);
|
ioctl_or_ret_errno(fd, LOCAL_DRM_IOCTL_MODE_DESTROYPROPBLOB, &destroy);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -112,8 +142,8 @@ destroy_prop(int fd, uint32_t prop_id)
|
|||||||
static void
|
static void
|
||||||
test_validate(int fd)
|
test_validate(int fd)
|
||||||
{
|
{
|
||||||
struct drm_mode_create_blob create;
|
struct local_drm_mode_create_blob create;
|
||||||
struct drm_mode_get_blob get;
|
struct local_drm_mode_get_blob get;
|
||||||
char too_small[32];
|
char too_small[32];
|
||||||
uint32_t prop_id;
|
uint32_t prop_id;
|
||||||
|
|
||||||
@ -122,24 +152,24 @@ test_validate(int fd)
|
|||||||
/* Outlandish size. */
|
/* Outlandish size. */
|
||||||
create.length = 0x10000;
|
create.length = 0x10000;
|
||||||
create.data = (uintptr_t) &too_small;
|
create.data = (uintptr_t) &too_small;
|
||||||
do_ioctl_err(fd, DRM_IOCTL_MODE_CREATEPROPBLOB, &create, EFAULT);
|
do_ioctl_err(fd, LOCAL_DRM_IOCTL_MODE_CREATEPROPBLOB, &create, EFAULT);
|
||||||
|
|
||||||
/* Outlandish address. */
|
/* Outlandish address. */
|
||||||
create.length = sizeof(test_mode_valid);
|
create.length = sizeof(test_mode_valid);
|
||||||
create.data = (uintptr_t) 0xdeadbeee;
|
create.data = (uintptr_t) 0xdeadbeee;
|
||||||
do_ioctl_err(fd, DRM_IOCTL_MODE_CREATEPROPBLOB, &create, EFAULT);
|
do_ioctl_err(fd, LOCAL_DRM_IOCTL_MODE_CREATEPROPBLOB, &create, EFAULT);
|
||||||
|
|
||||||
/* When we pass an incorrect size, the kernel should correct us. */
|
/* When we pass an incorrect size, the kernel should correct us. */
|
||||||
prop_id = create_prop(fd);
|
prop_id = create_prop(fd);
|
||||||
get.blob_id = prop_id;
|
get.blob_id = prop_id;
|
||||||
get.length = sizeof(too_small);
|
get.length = sizeof(too_small);
|
||||||
get.data = (uintptr_t) too_small;
|
get.data = (uintptr_t) too_small;
|
||||||
do_ioctl(fd, DRM_IOCTL_MODE_GETPROPBLOB, &get);
|
do_ioctl(fd, LOCAL_DRM_IOCTL_MODE_GETPROPBLOB, &get);
|
||||||
igt_assert_eq_u32(get.length, sizeof(test_mode_valid));
|
igt_assert_eq_u32(get.length, sizeof(test_mode_valid));
|
||||||
|
|
||||||
get.blob_id = prop_id;
|
get.blob_id = prop_id;
|
||||||
get.data = (uintptr_t) 0xdeadbeee;
|
get.data = (uintptr_t) 0xdeadbeee;
|
||||||
do_ioctl_err(fd, DRM_IOCTL_MODE_CREATEPROPBLOB, &create, EFAULT);
|
do_ioctl_err(fd, LOCAL_DRM_IOCTL_MODE_CREATEPROPBLOB, &create, EFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -211,9 +241,12 @@ igt_main
|
|||||||
igt_fixture {
|
igt_fixture {
|
||||||
fd = drm_open_driver(DRIVER_ANY);
|
fd = drm_open_driver(DRIVER_ANY);
|
||||||
igt_require(fd >= 0);
|
igt_require(fd >= 0);
|
||||||
test_basic(fd);
|
igt_require_propblob(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
igt_subtest("basic")
|
||||||
|
test_basic(fd);
|
||||||
|
|
||||||
igt_subtest("blob-prop-core")
|
igt_subtest("blob-prop-core")
|
||||||
test_core(fd);
|
test_core(fd);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user