#include <os.h>
#include <asm/malloc.h>
#include <asm/state.h>
+#include <asm/test.h>
/* Main state record for the sandbox */
static struct sandbox_state main_state;
state->sysreset_allowed[SYSRESET_POWER_OFF] = true;
state->sysreset_allowed[SYSRESET_COLD] = true;
state->allow_memio = false;
+ sandbox_set_eth_enable(true);
memset(&state->wdt, '\0', sizeof(state->wdt));
memset(state->spi, '\0', sizeof(state->spi));
return 0;
}
+void sandbox_set_eth_enable(bool enable)
+{
+ struct sandbox_state *state = state_get_current();
+
+ state->disable_eth = !enable;
+}
+
+bool sandbox_eth_enabled(void)
+{
+ struct sandbox_state *state = state_get_current();
+
+ return !state->disable_eth;
+}
+
int state_init(void)
{
state = &main_state;
const char *select_unittests; /* Unit test to run */
bool handle_signals; /* Handle signals within sandbox */
bool autoboot_keyed; /* Use keyed-autoboot feature */
+ bool disable_eth; /* Disable Ethernet devices */
/* Pointer to information for each SPI bus/cs */
struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]
*/
int sandbox_load_other_fdt(void **fdtp, int *sizep);
+/**
+ * sandbox_set_eth_enable() - Enable / disable Ethernet
+ *
+ * Allows control of whether Ethernet packets are actually send/received
+ *
+ * @enable: true to enable Ethernet, false to disable
+ */
+void sandbox_set_eth_enable(bool enable);
+
+/**
+ * sandbox_eth_enabled() - Check if Ethernet is enabled
+ *
+ * Returns: true if Ethernet is enabled on sandbox, False if not
+ */
+bool sandbox_eth_enabled(void);
+
#endif
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 */
#endif
#include <watchdog.h>
#include <linux/compiler.h>
+#include <test/test.h>
#include "arp.h"
#include "bootp.h"
#include "cdp.h"
debug_cond(DEBUG_INT_STATE, "--- net_loop Init\n");
net_init_loop();
+ if (!test_eth_enabled())
+ return 0;
+
switch (net_check_prereq(protocol)) {
case 1:
/* network not configured */