aboutsummaryrefslogtreecommitdiff
path: root/include/test
diff options
context:
space:
mode:
authorSimon Glass2023-01-17 10:47:27 -0700
committerTom Rini2023-01-23 18:11:39 -0500
commitf43b2df3e068cc7be1aa5656c0c3223e270bba63 (patch)
tree9c29daf5a2cd8180687b3ee4887bca40923bb658 /include/test
parentb85fc8dbabd7c027ad7ad6133578a0d679dbe2ba (diff)
sandbox: Allow ethernet to be disabled at runtime
For bootstd tests it is seldom useful to have ethernet enabled. Add a way to disable it, so that ethernet operations like tftpboot do nothing. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/test')
-rw-r--r--include/test/test.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/test/test.h b/include/test/test.h
index 4ad74614afc..76ec4d739a3 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -169,4 +169,29 @@ static inline int test_load_other_fdt(struct unit_test_state *uts)
return ret;
}
+/**
+ * test_set_eth_enable() - Enable / disable Ethernet
+ *
+ * Allows control of whether Ethernet packets are actually send/received
+ *
+ * @enable: true to enable Ethernet, false to disable
+ */
+static inline void test_set_eth_enable(bool enable)
+{
+#ifdef CONFIG_SANDBOX
+ sandbox_set_eth_enable(enable);
+#endif
+}
+
+/* Allow ethernet to be disabled for testing purposes */
+static inline bool test_eth_enabled(void)
+{
+ bool enabled = true;
+
+#ifdef CONFIG_SANDBOX
+ enabled = sandbox_eth_enabled();
+#endif
+ return enabled;
+}
+
#endif /* __TEST_TEST_H */