diff mbox

[i-g-t] core_prop_blob ioctl_wrappers: Fix new tests/benchmarks for android

Message ID 1444749378-27655-1-git-send-email-derek.j.morton@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Derek Morton Oct. 13, 2015, 3:16 p.m. UTC
Changes since #1b492e311 have broken the Android build. This patch
fixes the build 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.

gem_blt - included igt.h

Signed-off-by: Derek Morton <derek.j.morton@intel.com>
---
 benchmarks/gem_blt.c   |  4 +---
 lib/ioctl_wrappers.c   | 13 +++++++++++++
 lib/ioctl_wrappers.h   | 22 ++++++++++++++++++++++
 tests/core_prop_blob.c | 37 ++++++++++++++++++-------------------
 4 files changed, 54 insertions(+), 22 deletions(-)

Comments

Daniel Vetter Oct. 13, 2015, 3:35 p.m. UTC | #1
On Tue, Oct 13, 2015 at 04:16:18PM +0100, Derek Morton wrote:
> Changes since #1b492e311 have broken the Android build. This patch
> fixes the build 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.
> 
> gem_blt - included igt.h
> 
> Signed-off-by: Derek Morton <derek.j.morton@intel.com>
> ---
>  benchmarks/gem_blt.c   |  4 +---
>  lib/ioctl_wrappers.c   | 13 +++++++++++++
>  lib/ioctl_wrappers.h   | 22 ++++++++++++++++++++++
>  tests/core_prop_blob.c | 37 ++++++++++++++++++-------------------
>  4 files changed, 54 insertions(+), 22 deletions(-)
> 
> diff --git a/benchmarks/gem_blt.c b/benchmarks/gem_blt.c
> index 181a5f1..8ab5302 100644
> --- a/benchmarks/gem_blt.c
> +++ b/benchmarks/gem_blt.c
> @@ -25,6 +25,7 @@
>   *
>   */
>  
> +#include "igt.h"
>  #include <unistd.h>
>  #include <stdlib.h>
>  #include <stdint.h>
> @@ -39,9 +40,6 @@
>  #include <time.h>
>  
>  #include "drm.h"
> -#include "ioctl_wrappers.h"
> -#include "drmtest.h"
> -#include "intel_chipset.h"
>  
>  #define LOCAL_I915_EXEC_NO_RELOC (1<<11)
>  #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
> diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
> index 80e1ec6..cf34f25 100644
> --- a/lib/ioctl_wrappers.c
> +++ b/lib/ioctl_wrappers.c
> @@ -1219,6 +1219,19 @@ void igt_require_fb_modifiers(int fd)
>  	igt_require(has_modifiers);
>  }
>  
> +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 = &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);
> +}

If you want to do this in the library the usual way is to wrap the ioctls
as functions and put the relevant -ENOTTY check in there as an
igt_require, followed by an igt_assert for anything else that might have
gone wrong.

I'd just keep this in the test as a static function though, since then you
don't have to write api docs ;-)
-Daniel

> +
>  int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t height,
>  		uint32_t stride, uint32_t pixel_format, uint64_t modifier,
>  		uint32_t flags, uint32_t *buf_id)
> diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
> index f4deca6..aeb224c 100644
> --- a/lib/ioctl_wrappers.h
> +++ b/lib/ioctl_wrappers.h
> @@ -149,6 +149,20 @@ struct local_drm_mode_fb_cmd2 {
>  	uint64_t modifier[4];
>  };
>  
> +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_MODE_FB_MODIFIERS	(1<<1)
>  
>  #define LOCAL_DRM_FORMAT_MOD_VENDOR_INTEL	0x01
> @@ -165,9 +179,17 @@ struct local_drm_mode_fb_cmd2 {
>  #define LOCAL_DRM_IOCTL_MODE_ADDFB2	DRM_IOWR(0xB8, \
>  						 struct local_drm_mode_fb_cmd2)
>  
> +#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)
> +
>  #define LOCAL_DRM_CAP_ADDFB2_MODIFIERS	0x10
>  
>  void igt_require_fb_modifiers(int fd);
> +void igt_require_propblob(int fd);
>  
>  /**
>   * __kms_addfb:
> diff --git a/tests/core_prop_blob.c b/tests/core_prop_blob.c
> index d704158..ff56482 100644
> --- a/tests/core_prop_blob.c
> +++ b/tests/core_prop_blob.c
> @@ -25,16 +25,12 @@
>   *   Daniel Stone <daniels@collabora.com>
>   */
>  
> +#include "igt.h"
>  #include <errno.h>
>  #include <stdbool.h>
>  #include <stdio.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.");
>  
>  static const struct drm_mode_modeinfo test_mode_valid = {
> @@ -64,19 +60,19 @@ static const struct drm_mode_modeinfo test_mode_valid = {
>  static int
>  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;
>  
>  	get.blob_id = prop_id;
>  	get.length = 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))
>  		return ENOMEM;
>  
>  	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)
>  		return EINVAL;
> @@ -87,12 +83,12 @@ validate_prop(int fd, uint32_t prop_id)
>  static uint32_t
>  create_prop(int fd)
>  {
> -	struct drm_mode_create_blob create;
> +	struct local_drm_mode_create_blob create;
>  
>  	create.length = sizeof(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);
>  
>  	return create.blob_id;
> @@ -101,10 +97,10 @@ create_prop(int fd)
>  static int
>  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;
> -	ioctl_or_ret_errno(fd, DRM_IOCTL_MODE_DESTROYPROPBLOB, &destroy);
> +	ioctl_or_ret_errno(fd, LOCAL_DRM_IOCTL_MODE_DESTROYPROPBLOB, &destroy);
>  
>  	return 0;
>  }
> @@ -112,8 +108,8 @@ destroy_prop(int fd, uint32_t prop_id)
>  static void
>  test_validate(int fd)
>  {
> -	struct drm_mode_create_blob create;
> -	struct drm_mode_get_blob get;
> +	struct local_drm_mode_create_blob create;
> +	struct local_drm_mode_get_blob get;
>  	char too_small[32];
>  	uint32_t prop_id;
>  
> @@ -122,24 +118,24 @@ test_validate(int fd)
>  	/* Outlandish size. */
>  	create.length = 0x10000;
>  	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. */
>  	create.length = sizeof(test_mode_valid);
>  	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. */
>  	prop_id = create_prop(fd);
>  	get.blob_id = prop_id;
>  	get.length = sizeof(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));
>  
>  	get.blob_id = prop_id;
>  	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
> @@ -211,9 +207,12 @@ igt_main
>  	igt_fixture {
>  		fd = drm_open_driver(DRIVER_ANY);
>  		igt_require(fd >= 0);
> -		test_basic(fd);
> +		igt_require_propblob(fd);
>  	}
>  
> +	igt_subtest("basic")
> +		test_basic(fd);
> +
>  	igt_subtest("blob-prop-core")
>  		test_core(fd);
>  
> -- 
> 1.9.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Stone Oct. 13, 2015, 4:56 p.m. UTC | #2
Hi,

On 13 October 2015 at 16:35, Daniel Vetter <daniel@ffwll.ch> wrote:
>> +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 = &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);
>> +}
>
> If you want to do this in the library the usual way is to wrap the ioctls
> as functions and put the relevant -ENOTTY check in there as an
> igt_require, followed by an igt_assert for anything else that might have
> gone wrong.
>
> I'd just keep this in the test as a static function though, since then you
> don't have to write api docs ;-)

I have no real opinion either way; apologies for breaking the build!
Is Android up-to-date with libdrm, or? If it's not, I suspect
kms_atomic.c should just be excluded from the Android build
altogether.

Cheers,
Daniel
Thomas Wood Oct. 14, 2015, 10:14 a.m. UTC | #3
On 13 October 2015 at 16:35, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Tue, Oct 13, 2015 at 04:16:18PM +0100, Derek Morton wrote:
>> Changes since #1b492e311 have broken the Android build. This patch
>> fixes the build 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.
>>
>> gem_blt - included igt.h
>>
>> Signed-off-by: Derek Morton <derek.j.morton@intel.com>
>> ---
>>  benchmarks/gem_blt.c   |  4 +---
>>  lib/ioctl_wrappers.c   | 13 +++++++++++++
>>  lib/ioctl_wrappers.h   | 22 ++++++++++++++++++++++
>>  tests/core_prop_blob.c | 37 ++++++++++++++++++-------------------
>>  4 files changed, 54 insertions(+), 22 deletions(-)
>>
>> diff --git a/benchmarks/gem_blt.c b/benchmarks/gem_blt.c
>> index 181a5f1..8ab5302 100644
>> --- a/benchmarks/gem_blt.c
>> +++ b/benchmarks/gem_blt.c

The gem_blt changes are unrelated to the rest of the patch, so need to
be applied separately.


>> @@ -25,6 +25,7 @@
>>   *
>>   */
>>
>> +#include "igt.h"
>>  #include <unistd.h>
>>  #include <stdlib.h>
>>  #include <stdint.h>
>> @@ -39,9 +40,6 @@
>>  #include <time.h>
>>
>>  #include "drm.h"
>> -#include "ioctl_wrappers.h"
>> -#include "drmtest.h"
>> -#include "intel_chipset.h"
>>
>>  #define LOCAL_I915_EXEC_NO_RELOC (1<<11)
>>  #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
>> diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
>> index 80e1ec6..cf34f25 100644
>> --- a/lib/ioctl_wrappers.c
>> +++ b/lib/ioctl_wrappers.c
>> @@ -1219,6 +1219,19 @@ void igt_require_fb_modifiers(int fd)
>>       igt_require(has_modifiers);
>>  }
>>
>> +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 = &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);
>> +}
>
> If you want to do this in the library the usual way is to wrap the ioctls
> as functions and put the relevant -ENOTTY check in there as an
> igt_require, followed by an igt_assert for anything else that might have
> gone wrong.
>
> I'd just keep this in the test as a static function though, since then you
> don't have to write api docs ;-)

It's also unlikely to be used elsewhere at the moment, so a local
define and static function in the test is fine.


> -Daniel
>
>> +
>>  int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t height,
>>               uint32_t stride, uint32_t pixel_format, uint64_t modifier,
>>               uint32_t flags, uint32_t *buf_id)
>> diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
>> index f4deca6..aeb224c 100644
>> --- a/lib/ioctl_wrappers.h
>> +++ b/lib/ioctl_wrappers.h
>> @@ -149,6 +149,20 @@ struct local_drm_mode_fb_cmd2 {
>>       uint64_t modifier[4];
>>  };
>>
>> +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_MODE_FB_MODIFIERS  (1<<1)
>>
>>  #define LOCAL_DRM_FORMAT_MOD_VENDOR_INTEL    0x01
>> @@ -165,9 +179,17 @@ struct local_drm_mode_fb_cmd2 {
>>  #define LOCAL_DRM_IOCTL_MODE_ADDFB2  DRM_IOWR(0xB8, \
>>                                                struct local_drm_mode_fb_cmd2)
>>
>> +#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)
>> +
>>  #define LOCAL_DRM_CAP_ADDFB2_MODIFIERS       0x10
>>
>>  void igt_require_fb_modifiers(int fd);
>> +void igt_require_propblob(int fd);
>>
>>  /**
>>   * __kms_addfb:
>> diff --git a/tests/core_prop_blob.c b/tests/core_prop_blob.c
>> index d704158..ff56482 100644
>> --- a/tests/core_prop_blob.c
>> +++ b/tests/core_prop_blob.c
>> @@ -25,16 +25,12 @@
>>   *   Daniel Stone <daniels@collabora.com>
>>   */
>>
>> +#include "igt.h"
>>  #include <errno.h>
>>  #include <stdbool.h>
>>  #include <stdio.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.");
>>
>>  static const struct drm_mode_modeinfo test_mode_valid = {
>> @@ -64,19 +60,19 @@ static const struct drm_mode_modeinfo test_mode_valid = {
>>  static int
>>  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;
>>
>>       get.blob_id = prop_id;
>>       get.length = 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))
>>               return ENOMEM;
>>
>>       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)
>>               return EINVAL;
>> @@ -87,12 +83,12 @@ validate_prop(int fd, uint32_t prop_id)
>>  static uint32_t
>>  create_prop(int fd)
>>  {
>> -     struct drm_mode_create_blob create;
>> +     struct local_drm_mode_create_blob create;
>>
>>       create.length = sizeof(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);
>>
>>       return create.blob_id;
>> @@ -101,10 +97,10 @@ create_prop(int fd)
>>  static int
>>  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;
>> -     ioctl_or_ret_errno(fd, DRM_IOCTL_MODE_DESTROYPROPBLOB, &destroy);
>> +     ioctl_or_ret_errno(fd, LOCAL_DRM_IOCTL_MODE_DESTROYPROPBLOB, &destroy);
>>
>>       return 0;
>>  }
>> @@ -112,8 +108,8 @@ destroy_prop(int fd, uint32_t prop_id)
>>  static void
>>  test_validate(int fd)
>>  {
>> -     struct drm_mode_create_blob create;
>> -     struct drm_mode_get_blob get;
>> +     struct local_drm_mode_create_blob create;
>> +     struct local_drm_mode_get_blob get;
>>       char too_small[32];
>>       uint32_t prop_id;
>>
>> @@ -122,24 +118,24 @@ test_validate(int fd)
>>       /* Outlandish size. */
>>       create.length = 0x10000;
>>       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. */
>>       create.length = sizeof(test_mode_valid);
>>       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. */
>>       prop_id = create_prop(fd);
>>       get.blob_id = prop_id;
>>       get.length = sizeof(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));
>>
>>       get.blob_id = prop_id;
>>       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
>> @@ -211,9 +207,12 @@ igt_main
>>       igt_fixture {
>>               fd = drm_open_driver(DRIVER_ANY);
>>               igt_require(fd >= 0);
>> -             test_basic(fd);
>> +             igt_require_propblob(fd);
>>       }
>>
>> +     igt_subtest("basic")
>> +             test_basic(fd);
>> +
>>       igt_subtest("blob-prop-core")
>>               test_core(fd);
>>
>> --
>> 1.9.1
>>
>> _______________________________________________
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Derek Morton Oct. 14, 2015, 4:42 p.m. UTC | #4
>Hi,

>

>On 13 October 2015 at 16:35, Daniel Vetter <daniel@ffwll.ch> wrote:

>>> +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 = &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); }

>>

>> If you want to do this in the library the usual way is to wrap the 

>> ioctls as functions and put the relevant -ENOTTY check in there as an 

>> igt_require, followed by an igt_assert for anything else that might 

>> have gone wrong.

>>

>> I'd just keep this in the test as a static function though, since then 

>> you don't have to write api docs ;-)

>

>I have no real opinion either way; apologies for breaking the build!

>Is Android up-to-date with libdrm, or? If it's not, I suspect kms_atomic.c should just be excluded from the Android build altogether.


Hi,
The kms_* tests are dependant on cairo which is not in the android build by default. Personally I have never tried getting cairo to run on android so have never built the kms_* tests for android.

The version of libdrm used in android will match the kernel version being used in the particular android project. (So it would not be the latest version that goes with drm-nightly)

You aren't the 1st person to break the android build (and won't be the last either) :-)

//Derek

>

>Cheers,

>Daniel

>
diff mbox

Patch

diff --git a/benchmarks/gem_blt.c b/benchmarks/gem_blt.c
index 181a5f1..8ab5302 100644
--- a/benchmarks/gem_blt.c
+++ b/benchmarks/gem_blt.c
@@ -25,6 +25,7 @@ 
  *
  */
 
+#include "igt.h"
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -39,9 +40,6 @@ 
 #include <time.h>
 
 #include "drm.h"
-#include "ioctl_wrappers.h"
-#include "drmtest.h"
-#include "intel_chipset.h"
 
 #define LOCAL_I915_EXEC_NO_RELOC (1<<11)
 #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 80e1ec6..cf34f25 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1219,6 +1219,19 @@  void igt_require_fb_modifiers(int fd)
 	igt_require(has_modifiers);
 }
 
+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 = &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);
+}
+
 int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t height,
 		uint32_t stride, uint32_t pixel_format, uint64_t modifier,
 		uint32_t flags, uint32_t *buf_id)
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index f4deca6..aeb224c 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -149,6 +149,20 @@  struct local_drm_mode_fb_cmd2 {
 	uint64_t modifier[4];
 };
 
+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_MODE_FB_MODIFIERS	(1<<1)
 
 #define LOCAL_DRM_FORMAT_MOD_VENDOR_INTEL	0x01
@@ -165,9 +179,17 @@  struct local_drm_mode_fb_cmd2 {
 #define LOCAL_DRM_IOCTL_MODE_ADDFB2	DRM_IOWR(0xB8, \
 						 struct local_drm_mode_fb_cmd2)
 
+#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)
+
 #define LOCAL_DRM_CAP_ADDFB2_MODIFIERS	0x10
 
 void igt_require_fb_modifiers(int fd);
+void igt_require_propblob(int fd);
 
 /**
  * __kms_addfb:
diff --git a/tests/core_prop_blob.c b/tests/core_prop_blob.c
index d704158..ff56482 100644
--- a/tests/core_prop_blob.c
+++ b/tests/core_prop_blob.c
@@ -25,16 +25,12 @@ 
  *   Daniel Stone <daniels@collabora.com>
  */
 
+#include "igt.h"
 #include <errno.h>
 #include <stdbool.h>
 #include <stdio.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.");
 
 static const struct drm_mode_modeinfo test_mode_valid = {
@@ -64,19 +60,19 @@  static const struct drm_mode_modeinfo test_mode_valid = {
 static int
 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;
 
 	get.blob_id = prop_id;
 	get.length = 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))
 		return ENOMEM;
 
 	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)
 		return EINVAL;
@@ -87,12 +83,12 @@  validate_prop(int fd, uint32_t prop_id)
 static uint32_t
 create_prop(int fd)
 {
-	struct drm_mode_create_blob create;
+	struct local_drm_mode_create_blob create;
 
 	create.length = sizeof(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);
 
 	return create.blob_id;
@@ -101,10 +97,10 @@  create_prop(int fd)
 static int
 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;
-	ioctl_or_ret_errno(fd, DRM_IOCTL_MODE_DESTROYPROPBLOB, &destroy);
+	ioctl_or_ret_errno(fd, LOCAL_DRM_IOCTL_MODE_DESTROYPROPBLOB, &destroy);
 
 	return 0;
 }
@@ -112,8 +108,8 @@  destroy_prop(int fd, uint32_t prop_id)
 static void
 test_validate(int fd)
 {
-	struct drm_mode_create_blob create;
-	struct drm_mode_get_blob get;
+	struct local_drm_mode_create_blob create;
+	struct local_drm_mode_get_blob get;
 	char too_small[32];
 	uint32_t prop_id;
 
@@ -122,24 +118,24 @@  test_validate(int fd)
 	/* Outlandish size. */
 	create.length = 0x10000;
 	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. */
 	create.length = sizeof(test_mode_valid);
 	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. */
 	prop_id = create_prop(fd);
 	get.blob_id = prop_id;
 	get.length = sizeof(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));
 
 	get.blob_id = prop_id;
 	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
@@ -211,9 +207,12 @@  igt_main
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_ANY);
 		igt_require(fd >= 0);
-		test_basic(fd);
+		igt_require_propblob(fd);
 	}
 
+	igt_subtest("basic")
+		test_basic(fd);
+
 	igt_subtest("blob-prop-core")
 		test_core(fd);