sandbox: Add a way to skip time delays
Some tests are slow due to delays which are unnecessary on sandbox. The
worst offender is USB where we lose two seconds. Add a way to disable time
delays.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 3a7f5a0..196f3e1 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -37,7 +37,10 @@
/* delay x useconds */
void __udelay(unsigned long usec)
{
- os_usleep(usec);
+ struct sandbox_state *state = state_get_current();
+
+ if (!state->skip_delays)
+ os_usleep(usec);
}
int cleanup_before_linux(void)
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index 7e5d03e..d2a7dc9 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -337,6 +337,20 @@
return state;
}
+void state_set_skip_delays(bool skip_delays)
+{
+ struct sandbox_state *state = state_get_current();
+
+ state->skip_delays = skip_delays;
+}
+
+bool state_get_skip_delays(void)
+{
+ struct sandbox_state *state = state_get_current();
+
+ return state->skip_delays;
+}
+
int state_init(void)
{
state = &main_state;