All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petri Latvala <petri.latvala@intel.com>
To: Kunal Joshi <kunal1.joshi@intel.com>
Cc: ville.syrjala@intel.com, igt-dev@lists.freedesktop.org,
	daniel.vetter@intel.com
Subject: Re: [igt-dev] [PATCH i-g-t v3 1/3] lib/igt_chamelium Added chamelium_frame_match_or_dump which returns bool that the captured frame matches
Date: Tue, 21 Jan 2020 15:29:48 +0200	[thread overview]
Message-ID: <20200121132948.GC25209@platvala-desk.ger.corp.intel.com> (raw)
In-Reply-To: <1579586055-27583-2-git-send-email-kunal1.joshi@intel.com>

On Tue, Jan 21, 2020 at 11:24:13AM +0530, Kunal Joshi wrote:
> Added chamelium_frame_match_or_dump which returns bool that the captured
> frame matches with reference framebuffer.
> 
> (v2)
>         Removed previously added function chamelium_assert_frame_dump_eq.
> 
> (v3)
> 	No change.
> 
> Signed-off-by: Kunal Joshi <kunal1.joshi@intel.com>
> Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
> Suggested-by: Uma Shankar <uma.shankar@intel.com>
> ---
>  lib/igt_chamelium.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/igt_chamelium.h |  5 +++++
>  2 files changed, 70 insertions(+)
> 
> diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
> index 9971f51..db1f2b6 100644
> --- a/lib/igt_chamelium.c
> +++ b/lib/igt_chamelium.c
> @@ -1632,6 +1632,71 @@ void chamelium_assert_frame_match_or_dump(struct chamelium *chamelium,
>  }
>  
>  /**
> + * chamelium_assert_frame_match_or_dump:
> + * @chamelium: The chamelium instance the frame dump belongs to
> + * @frame: The chamelium frame dump to match
> + * @fb: pointer to an #igt_fb structure
> + * @check: the type of frame matching check to use
> + *
> + * Returns bool that the provided captured frame matches the reference
> + * frame from the framebuffer. If they do not, this saves the reference
> + * and captured frames to a png file.
> + */
> +bool chamelium_frame_match_or_dump(struct chamelium *chamelium,
> +				   struct chamelium_port *port,
> +				   const struct chamelium_frame_dump *frame,
> +				   struct igt_fb *fb,
> +				   enum chamelium_check check)
> +{
> +	cairo_surface_t *reference;
> +	cairo_surface_t *capture;
> +	igt_crc_t *reference_crc;
> +	igt_crc_t *capture_crc;
> +	bool match;
> +
> +	/* Grab the reference frame from framebuffer */
> +	reference = igt_get_cairo_surface(chamelium->drm_fd, fb);
> +
> +	/* Grab the captured frame from chamelium */
> +	capture = convert_frame_dump_argb32(frame);
> +
> +	switch (check) {
> +	case CHAMELIUM_CHECK_ANALOG:
> +		match = igt_check_analog_frame_match(reference, capture);
> +		break;
> +	case CHAMELIUM_CHECK_CHECKERBOARD:
> +		match = igt_check_checkerboard_frame_match(reference, capture);
> +		break;
> +	default:
> +		igt_assert(false);
> +	}
> +
> +	if (!match && igt_frame_dump_is_enabled()) {
> +		reference_crc = malloc(sizeof(igt_crc_t));
> +		igt_assert(reference_crc);
> +
> +		/* Calculate the reference frame CRC. */
> +		chamelium_do_calculate_fb_crc(reference, reference_crc);
> +
> +		/* Get the captured frame CRC from the Chamelium. */
> +		capture_crc = chamelium_get_crc_for_area(chamelium, port, 0, 0,
> +							 0, 0);
> +		igt_assert(capture_crc);
> +
> +		compared_frames_dump(reference, capture, reference_crc,
> +				     capture_crc);
> +
> +		free(reference_crc);
> +		free(capture_crc);
> +	}
> +
> +	cairo_surface_destroy(reference);
> +	cairo_surface_destroy(capture);
> +
> +	return match;
> +}

This copy of chamelium_assert_frame_match_or_dump is
unnecessary. The typical structure is that we have a bool-returning
function for code that wants to do its own checks afterwards, and
another one that 1) calls the bool-returning function 2) asserts
success. Like so:


void chamelium_assert_frame_match_or_dump(struct chamelium *chamelium,
  					  const struct chamelium_frame_dump *frame,
  					  struct igt_fb *fb,
  					  enum chamelium_check check)
{
  igt_assert(chamelium_frame_match_or_dump(chamelium, frame, fb, check));
}




-- 
Petri Latvala
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2020-01-21 13:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-21  5:54 [igt-dev] [PATCH i-g-t v3 0/3] validate color tests using chamelium Kunal Joshi
2020-01-21  5:54 ` [igt-dev] [PATCH i-g-t v3 1/3] lib/igt_chamelium Added chamelium_frame_match_or_dump which returns bool that the captured frame matches Kunal Joshi
2020-01-21 13:29   ` Petri Latvala [this message]
2020-01-22  3:01     ` Kunal Joshi
2020-01-22 10:34       ` Petri Latvala
2020-01-21  5:54 ` [igt-dev] [PATCH i-g-t v3 3/3] tests/kms_color_chamelium: add subtests to validate color Kunal Joshi
2020-01-21 13:51   ` Petri Latvala
2020-01-23  7:00     ` Kunal Joshi
     [not found] ` <1579586055-27583-3-git-send-email-kunal1.joshi@intel.com>
2020-01-21 13:42   ` [igt-dev] [PATCH i-g-t v3 2/3] lib/igt_color Moved kms_color functions to lib/igt_color to git avoid code duplication Petri Latvala
2020-01-21 13:43 ` [igt-dev] ✓ Fi.CI.BAT: success for validate color tests using chamelium. (rev3) Patchwork
2020-01-22 12:10 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200121132948.GC25209@platvala-desk.ger.corp.intel.com \
    --to=petri.latvala@intel.com \
    --cc=daniel.vetter@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kunal1.joshi@intel.com \
    --cc=ville.syrjala@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.