mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <groeck@google.com>
To: Tzung-Bi Shih <tzungbi@kernel.org>
Cc: Benson Leung <bleung@chromium.org>,
	Guenter Roeck <groeck@chromium.org>,
	"open list:CHROME HARDWARE PLATFORM SUPPORT" 
	<chrome-platform@lists.linux.dev>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/7] platform/chrome: cros_ec_proto: add Kunit tests for get_host_event
Date: Thu, 23 Jun 2022 09:38:10 -0700	[thread overview]
Message-ID: <CABXOdTfuiVan-Rascq1X-hrvf-68FPu636G1T-v6fA-kUhMArg@mail.gmail.com> (raw)
In-Reply-To: <20220622041040.202737-5-tzungbi@kernel.org>

On Tue, Jun 21, 2022 at 9:11 PM Tzung-Bi Shih <tzungbi@kernel.org> wrote:
>
> cros_ec_get_host_event() performs some sanity checks, parses
> `ec_dev->event_data.data.host_event`, and returns bitmap of
> EC_HOST_EVENT_*.
>
> Add Kunit tests for cros_ec_get_host_event().
>
> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>

Reviewed-by: Guenter Roeck <groeck@chromium.org>

> ---
>  drivers/platform/chrome/cros_ec_proto_test.c | 59 ++++++++++++++++++++
>  1 file changed, 59 insertions(+)
>
> diff --git a/drivers/platform/chrome/cros_ec_proto_test.c b/drivers/platform/chrome/cros_ec_proto_test.c
> index 64c4b79f7a0c..dce9fa3b9c8d 100644
> --- a/drivers/platform/chrome/cros_ec_proto_test.c
> +++ b/drivers/platform/chrome/cros_ec_proto_test.c
> @@ -2312,6 +2312,61 @@ static void cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked(struc
>         }
>  }
>
> +static void cros_ec_proto_test_get_host_event_no_mkbp_event(struct kunit *test)
> +{
> +       struct cros_ec_proto_test_priv *priv = test->priv;
> +       struct cros_ec_device *ec_dev = &priv->ec_dev;
> +       int ret;
> +
> +       ec_dev->mkbp_event_supported = 0;
> +
> +       ret = cros_ec_get_host_event(ec_dev);
> +       KUNIT_EXPECT_EQ(test, ret, 0);
> +}
> +
> +static void cros_ec_proto_test_get_host_event_not_host_event(struct kunit *test)
> +{
> +       struct cros_ec_proto_test_priv *priv = test->priv;
> +       struct cros_ec_device *ec_dev = &priv->ec_dev;
> +       int ret;
> +
> +       ec_dev->mkbp_event_supported = 1;
> +       ec_dev->event_data.event_type = EC_MKBP_EVENT_FINGERPRINT;
> +
> +       ret = cros_ec_get_host_event(ec_dev);
> +       KUNIT_EXPECT_EQ(test, ret, 0);
> +}
> +
> +static void cros_ec_proto_test_get_host_event_wrong_event_size(struct kunit *test)
> +{
> +       struct cros_ec_proto_test_priv *priv = test->priv;
> +       struct cros_ec_device *ec_dev = &priv->ec_dev;
> +       int ret;
> +
> +       ec_dev->mkbp_event_supported = 1;
> +       ec_dev->event_data.event_type = EC_MKBP_EVENT_HOST_EVENT;
> +       ec_dev->event_size = 0xff;
> +
> +       ret = cros_ec_get_host_event(ec_dev);
> +       KUNIT_EXPECT_EQ(test, ret, 0);
> +}
> +
> +static void cros_ec_proto_test_get_host_event_normal(struct kunit *test)
> +{
> +       struct cros_ec_proto_test_priv *priv = test->priv;
> +       struct cros_ec_device *ec_dev = &priv->ec_dev;
> +       int ret;
> +
> +       ec_dev->mkbp_event_supported = 1;
> +       ec_dev->event_data.event_type = EC_MKBP_EVENT_HOST_EVENT;
> +       ec_dev->event_size = sizeof(ec_dev->event_data.data.host_event);
> +       put_unaligned_le32(EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC),
> +                          &ec_dev->event_data.data.host_event);
> +
> +       ret = cros_ec_get_host_event(ec_dev);
> +       KUNIT_EXPECT_EQ(test, ret, EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC));
> +}
> +
>  static void cros_ec_proto_test_release(struct device *dev)
>  {
>  }
> @@ -2401,6 +2456,10 @@ static struct kunit_case cros_ec_proto_test_cases[] = {
>         KUNIT_CASE(cros_ec_proto_test_get_next_event_mkbp_event_version2),
>         KUNIT_CASE(cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc),
>         KUNIT_CASE(cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked),
> +       KUNIT_CASE(cros_ec_proto_test_get_host_event_no_mkbp_event),
> +       KUNIT_CASE(cros_ec_proto_test_get_host_event_not_host_event),
> +       KUNIT_CASE(cros_ec_proto_test_get_host_event_wrong_event_size),
> +       KUNIT_CASE(cros_ec_proto_test_get_host_event_normal),
>         {}
>  };
>
> --
> 2.37.0.rc0.104.g0611611a94-goog
>

  reply	other threads:[~2022-06-23 16:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-22  4:10 [PATCH 0/7] platform/chrome: cros_ec_proto: add Kunit tests Tzung-Bi Shih
2022-06-22  4:10 ` [PATCH 1/7] platform/chrome: cros_ec_proto: add Kunit tests for cmd_xfer_status Tzung-Bi Shih
2022-06-23 16:36   ` Guenter Roeck
2022-06-22  4:10 ` [PATCH 2/7] platform/chrome: cros_ec_proto: add Kunit test for cros_ec_map_error() Tzung-Bi Shih
2022-06-23 16:36   ` Guenter Roeck
2022-06-22  4:10 ` [PATCH 3/7] platform/chrome: cros_ec_proto: add Kunit tests for get_next_event Tzung-Bi Shih
2022-06-23 16:37   ` Guenter Roeck
2022-06-22  4:10 ` [PATCH 4/7] platform/chrome: cros_ec_proto: add Kunit tests for get_host_event Tzung-Bi Shih
2022-06-23 16:38   ` Guenter Roeck [this message]
2022-06-22  4:10 ` [PATCH 5/7] platform/chrome: cros_ec_proto: add Kunit tests for check_features Tzung-Bi Shih
2022-06-23 16:38   ` Guenter Roeck
2022-06-22  4:10 ` [PATCH 6/7] platform/chrome: cros_ec_proto: add Kunit tests for get_sensor_count Tzung-Bi Shih
2022-06-23 16:39   ` Guenter Roeck
2022-06-22  4:10 ` [PATCH 7/7] platform/chrome: cros_ec_proto: add Kunit test for cros_ec_cmd() Tzung-Bi Shih
2022-06-23 16:40   ` Guenter Roeck
2022-07-20  1:30 ` [PATCH 0/7] platform/chrome: cros_ec_proto: add Kunit tests patchwork-bot+chrome-platform
2022-07-21  8:50 ` patchwork-bot+chrome-platform

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=CABXOdTfuiVan-Rascq1X-hrvf-68FPu636G1T-v6fA-kUhMArg@mail.gmail.com \
    --to=groeck@google.com \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=groeck@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tzungbi@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®