summaryrefslogtreecommitdiff
path: root/zephyr/test
diff options
context:
space:
mode:
authorTristan Honscheid <honscheid@google.com>2022-03-18 23:04:09 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-03-28 17:38:36 +0000
commit59d9c1bed783ed2b2e32187c370dc98dc69cbbec (patch)
tree5ca5177fe4a925653379be089552b80bd21b4779 /zephyr/test
parentac99ea61c8d0584f5476c607432320ea92e57809 (diff)
downloadchrome-ec-59d9c1bed783ed2b2e32187c370dc98dc69cbbec.tar.gz
sn5s330: Test set_vbus_source_current_limit() I2C read fail
Add a test for the set_vbus_source_current_limit() function for when the I2C read operation fails. BRANCH=None BUG=b:225245353 TEST=zmake -D configure --test test-drivers Signed-off-by: Tristan Honscheid <honscheid@google.com> Change-Id: Ib5a0787dc4c93df859c577f3b8239e932be5fda1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3546939 Reviewed-by: Sam Hurst <shurst@google.com>
Diffstat (limited to 'zephyr/test')
-rw-r--r--zephyr/test/drivers/src/ppc_sn5s330.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/zephyr/test/drivers/src/ppc_sn5s330.c b/zephyr/test/drivers/src/ppc_sn5s330.c
index 78218ccae1..00e64950f6 100644
--- a/zephyr/test/drivers/src/ppc_sn5s330.c
+++ b/zephyr/test/drivers/src/ppc_sn5s330.c
@@ -544,6 +544,19 @@ ZTEST(ppc_sn5s330, test_set_polarity)
"Polarity flags should be cleared.");
}
+ZTEST(ppc_sn5s330, test_set_vbus_source_current_limit_fail)
+{
+ struct i2c_emul *i2c_emul = sn5s330_emul_to_i2c_emul(EMUL);
+ int ret;
+
+ i2c_common_emul_set_read_fail_reg(i2c_emul, SN5S330_FUNC_SET1);
+
+ ret = sn5s330_drv.set_vbus_source_current_limit(SN5S330_PORT,
+ TYPEC_RP_3A0);
+ zassert_equal(EC_ERROR_INVAL, ret, "Expected EC_ERROR_INVAL but got %d",
+ ret);
+}
+
static inline void reset_sn5s330_state(void)
{
struct i2c_emul *i2c_emul = sn5s330_emul_to_i2c_emul(EMUL);