[igt-dev] [PATCH i-g-t 1/2] lib: Support multiple filters

Petri Latvala petri.latvala at intel.com
Thu Apr 30 08:42:04 UTC 2020


On Wed, Apr 29, 2020 at 06:49:01PM +0300, Arkadiusz Hiler wrote:
> This patch brings back support for multiple filters that was in the
> original series by Zbyszek.
> 
> We can now take multiple, semicolon separated filters. Right now the
> tests are using only the first filter.
> 
> Cc: Petri Latvala <petri.latvala at intel.com>
> Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
> ---
>  lib/drmtest.c          |  8 ++--
>  lib/igt_core.c         | 16 ++++----
>  lib/igt_device_scan.c  | 87 +++++++++++++++++++++++++++++++-----------
>  lib/igt_device_scan.h  |  8 ++--
>  tests/core_hotunplug.c |  3 +-
>  5 files changed, 83 insertions(+), 39 deletions(-)
> 
> diff --git a/lib/drmtest.c b/lib/drmtest.c
> index 1fc39925..7b2fd337 100644
> --- a/lib/drmtest.c
> +++ b/lib/drmtest.c
> @@ -324,8 +324,8 @@ static bool __get_the_first_card(struct igt_device_card *card)
>  {
>  	const char *filter;
>  
> -	if (igt_device_is_filter_set()) {
> -		filter = igt_device_filter_get();
> +	if (igt_device_filter_count() > 0) {
> +		filter = igt_device_filter_get(0);
>  		igt_info("Looking for devices to open using filter: %s\n", filter);
>  
>  		if (igt_device_card_match(filter, card)) {
> @@ -354,7 +354,7 @@ static bool __get_the_first_card(struct igt_device_card *card)
>   */
>  int __drm_open_driver(int chipset)
>  {
> -	if (igt_device_is_filter_set()) {
> +	if (igt_device_filter_count() > 0) {
>  		bool found;
>  		struct igt_device_card card;
>  
> @@ -371,7 +371,7 @@ int __drm_open_driver(int chipset)
>  
>  int __drm_open_driver_render(int chipset)
>  {
> -	if (igt_device_is_filter_set()) {
> +	if (igt_device_filter_count() > 0) {
>  		bool found;
>  		struct igt_device_card card;
>  
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index 3f7b9f68..44705d10 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -249,7 +249,7 @@
>   *	FrameDumpPath=/tmp # The path to dump frames that fail comparison checks
>   *
>   *	# Device selection filter
> - *	Device=pci:vendor=8086,card=0;vgem:
> + *	Device=pci:vendor=8086,card=0;sys:/sys/devices/platform/vgem
>   *
>   *	# The following section is used for configuring the Device Under Test.
>   *	# It is not mandatory and allows overriding default values.
> @@ -685,7 +685,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
>  		   "  --skip-crc-compare\n"
>  		   "  --help-description\n"
>  		   "  --describe\n"
> -		   "  --device filter\n"
> +		   "  --device filters\n"
>  		   "  --version\n"
>  		   "  --help|-h\n");
>  	if (help_str)
> @@ -778,7 +778,7 @@ static void common_init_config(void)
>  		igt_set_autoresume_delay(ret);
>  
>  	/* Adding filters, order .igtrc, IGT_DEVICE, --device filter */
> -	if (igt_device_is_filter_set())
> +	if (igt_device_filter_count() > 0)
>  		igt_debug("Notice: using --device filters:\n");
>  	else {
>  		if (igt_rc_device) {
> @@ -793,14 +793,16 @@ static void common_init_config(void)
>  					  "Common::Device:\n");
>  		}
>  		if (igt_rc_device) {
> -			igt_device_filter_set(igt_rc_device);
> +			igt_device_filter_add(igt_rc_device);
>  			free(igt_rc_device);
>  			igt_rc_device = NULL;
>  		}
>  	}
>  
> -	if (igt_device_is_filter_set())
> -		igt_debug("[%s]\n", igt_device_filter_get());
> +	if (igt_device_filter_count() > 0) {
> +		for (int i = 0; i < igt_device_filter_count(); i++)
> +			igt_debug("[%s]\n", igt_device_filter_get(i));
> +	}

The if check can be dropped here, the for condition already takes care
of it.

Did we have unit tests for filters handling somewhere? I mean the list
stuff, not the application, latter is harder to unit test.


Reviewed-by: Petri Latvala <petri.latvala at intel.com>


More information about the igt-dev mailing list