sn5s330: Test I2C fail in sn5s330_discharge_vbus()
Ensure we return an error code when an I2C read error occurs in
sn5s330_discharge_vbus()
BRANCH=None
TEST=zmake -D configure --test test-drivers
@@ -557,6 +557,18 @@ ZTEST(ppc_sn5s330, test_set_vbus_source_current_limit_fail)
ret);
}
+ZTEST(ppc_sn5s330, test_sn5s330_discharge_vbus_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_SET3);
+
+ ret = sn5s330_drv.discharge_vbus(SN5S330_PORT, false);
+ 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);
