From: Tzung-Bi Shih <tzungbi@kernel.org>
To: bleung@chromium.org, groeck@chromium.org
Cc: chrome-platform@lists.linux.dev, tzungbi@kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/7] platform/chrome: cros_ec_proto: add Kunit tests for cmd_xfer_status
Date: Wed, 22 Jun 2022 04:10:34 +0000 [thread overview]
Message-ID: <20220622041040.202737-2-tzungbi@kernel.org> (raw)
In-Reply-To: <20220622041040.202737-1-tzungbi@kernel.org>
cros_ec_cmd_xfer_status() calls cros_ec_cmd_xfer() and cros_ec_map_error().
Given that there are already test cases for cros_ec_cmd_xfer(), only add
basic Kunit tests for cros_ec_cmd_xfer_status().
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
---
drivers/platform/chrome/cros_ec_proto_test.c | 42 ++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/drivers/platform/chrome/cros_ec_proto_test.c b/drivers/platform/chrome/cros_ec_proto_test.c
index 7d45e5022221..6464f6101fd3 100644
--- a/drivers/platform/chrome/cros_ec_proto_test.c
+++ b/drivers/platform/chrome/cros_ec_proto_test.c
@@ -1964,6 +1964,46 @@ static void cros_ec_proto_test_cmd_xfer_in_progress_return0(struct kunit *test)
KUNIT_EXPECT_EQ(test, cros_kunit_ec_pkt_xfer_mock_called, 2);
}
+static void cros_ec_proto_test_cmd_xfer_status_normal(struct kunit *test)
+{
+ struct cros_ec_proto_test_priv *priv = test->priv;
+ struct cros_ec_device *ec_dev = &priv->ec_dev;
+ struct ec_xfer_mock *mock;
+ int ret;
+ struct cros_ec_command msg;
+
+ memset(&msg, 0, sizeof(msg));
+
+ /* For cros_ec_cmd_xfer(). */
+ {
+ mock = cros_kunit_ec_xfer_mock_add(test, 0);
+ KUNIT_ASSERT_PTR_NE(test, mock, NULL);
+ }
+
+ ret = cros_ec_cmd_xfer_status(ec_dev, &msg);
+ KUNIT_EXPECT_EQ(test, ret, 0);
+}
+
+static void cros_ec_proto_test_cmd_xfer_status_xfer_error(struct kunit *test)
+{
+ struct cros_ec_proto_test_priv *priv = test->priv;
+ struct cros_ec_device *ec_dev = &priv->ec_dev;
+ struct ec_xfer_mock *mock;
+ int ret;
+ struct cros_ec_command msg;
+
+ memset(&msg, 0, sizeof(msg));
+
+ /* For cros_ec_cmd_xfer(). */
+ {
+ mock = cros_kunit_ec_xfer_mock_addx(test, -EPROTO, EC_RES_SUCCESS, 0);
+ KUNIT_ASSERT_PTR_NE(test, mock, NULL);
+ }
+
+ ret = cros_ec_cmd_xfer_status(ec_dev, &msg);
+ KUNIT_EXPECT_EQ(test, ret, -EPROTO);
+}
+
static void cros_ec_proto_test_release(struct device *dev)
{
}
@@ -2044,6 +2084,8 @@ static struct kunit_case cros_ec_proto_test_cases[] = {
KUNIT_CASE(cros_ec_proto_test_cmd_xfer_in_progress_xfer_error),
KUNIT_CASE(cros_ec_proto_test_cmd_xfer_in_progress_return_error),
KUNIT_CASE(cros_ec_proto_test_cmd_xfer_in_progress_return0),
+ KUNIT_CASE(cros_ec_proto_test_cmd_xfer_status_normal),
+ KUNIT_CASE(cros_ec_proto_test_cmd_xfer_status_xfer_error),
{}
};
--
2.37.0.rc0.104.g0611611a94-goog
next prev parent reply other threads:[~2022-06-22 4:12 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 ` Tzung-Bi Shih [this message]
2022-06-23 16:36 ` [PATCH 1/7] platform/chrome: cros_ec_proto: add Kunit tests for cmd_xfer_status 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
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=20220622041040.202737-2-tzungbi@kernel.org \
--to=tzungbi@kernel.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=groeck@chromium.org \
--cc=linux-kernel@vger.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