summaryrefslogtreecommitdiff
path: root/include/test_util.h
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-09-26 17:39:40 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-09-27 04:33:33 +0000
commit4de56d4a7f2fb9fb459f31a8e8f1616e54852157 (patch)
tree1b35b453482fe64a0d43a81df0af9a6f7373e413 /include/test_util.h
parent09de4c720d790a7243808e82264e8a1bb122a99d (diff)
downloadchrome-ec-4de56d4a7f2fb9fb459f31a8e8f1616e54852157.tar.gz
Test interface for detaching fake I2C devices
This provides an interface to detach and re-attach fake I2C devices, which can be used to test I2C connection failure. BUG=chrome-os-partner:19235 TEST=Pass sbs_charging test along with the next CL BRANCH=None Change-Id: Ibfee79b13d45e62377d894aa28547e77bef2189e Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/170752 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include/test_util.h')
-rw-r--r--include/test_util.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/test_util.h b/include/test_util.h
index a05165148e..1dc737b986 100644
--- a/include/test_util.h
+++ b/include/test_util.h
@@ -218,4 +218,25 @@ struct test_i2c_write_dev {
__attribute__((section(".rodata.test_i2c.read_string"))) \
= {routine}
+/*
+ * Detach an I2C device. Once detached, any read/write command regarding the
+ * specified port and slave address returns error.
+ *
+ * @param port The port that the detached device is connected to
+ * @param slave_addr The address of the detached device
+ * @return EC_SUCCESS if detached; EC_ERROR_OVERFLOW if too many devices are
+ * detached.
+ */
+int test_detach_i2c(int port, int slave_addr);
+
+/*
+ * Re-attach an I2C device.
+ *
+ * @param port The port that the detached device is connected to
+ * @param slave_addr The address of the detached device
+ * @return EC_SUCCESS if re-attached; EC_ERROR_INVAL if the specified device
+ * is not a detached device.
+ */
+int test_attach_i2c(int port, int slave_addr);
+
#endif /* __CROS_EC_TEST_UTIL_H */