* [U-Boot] [PATCH 0/3] test: Speed up test timeouts by advancing time
@ 2015-04-21 18:57 Joe Hershberger
2015-04-21 18:57 ` [U-Boot] [PATCH 1/3] sandbox: Add test function to advance time Joe Hershberger
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Joe Hershberger @ 2015-04-21 18:57 UTC (permalink / raw)
To: u-boot
Add support for advancing time in sandbox and make use of the new API to
speed up the existing dm/eth tests that wait for timeouts.
This series is based on u-boot-dm/test-working
Joe Hershberger (3):
sandbox: Add test function to advance time
sandbox: eth: Add a function to skip ping timeouts
test: dm: eth: Skip timeouts on ping tests
arch/sandbox/cpu/cpu.c | 5 -----
arch/sandbox/include/asm/eth.h | 2 ++
arch/sandbox/include/asm/test.h | 8 ++++++++
board/sandbox/sandbox.c | 11 ++++++++++-
drivers/net/sandbox.c | 17 +++++++++++++++++
test/dm/eth.c | 2 ++
6 files changed, 39 insertions(+), 6 deletions(-)
--
1.7.11.5
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 1/3] sandbox: Add test function to advance time
2015-04-21 18:57 [U-Boot] [PATCH 0/3] test: Speed up test timeouts by advancing time Joe Hershberger
@ 2015-04-21 18:57 ` Joe Hershberger
2015-04-24 4:13 ` Simon Glass
2015-04-21 18:57 ` [U-Boot] [PATCH 2/3] sandbox: eth: Add a function to skip ping timeouts Joe Hershberger
2015-04-21 18:57 ` [U-Boot] [PATCH 3/3] test: dm: eth: Skip timeouts on ping tests Joe Hershberger
2 siblings, 1 reply; 10+ messages in thread
From: Joe Hershberger @ 2015-04-21 18:57 UTC (permalink / raw)
To: u-boot
Add a function that maintains an offset to include in the system timer
values returned from the lib/time.c APIs.
This will allow timeouts to be skipped instantly in tests
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---
arch/sandbox/cpu/cpu.c | 5 -----
arch/sandbox/include/asm/test.h | 8 ++++++++
board/sandbox/sandbox.c | 11 ++++++++++-
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 007ae86..6c3f4b4 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -44,11 +44,6 @@ void __udelay(unsigned long usec)
os_usleep(usec);
}
-unsigned long __attribute__((no_instrument_function)) timer_get_us(void)
-{
- return os_get_nsec() / 1000;
-}
-
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
{
if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h
index 8e490e9..296589c 100644
--- a/arch/sandbox/include/asm/test.h
+++ b/arch/sandbox/include/asm/test.h
@@ -28,4 +28,12 @@ void sandbox_i2c_eeprom_set_test_mode(struct udevice *dev,
void sandbox_i2c_eeprom_set_offset_len(struct udevice *dev, int offset_len);
+/*
+ * sandbox_timer_add_offset()
+ *
+ * Allow tests to add to the time reported through lib/time.c functions
+ * offset: number of milliseconds to advance the system time
+ */
+void sandbox_timer_add_offset(unsigned long offset);
+
#endif
diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index 2227f1c..80eaa63 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -7,6 +7,7 @@
#include <cros_ec.h>
#include <dm.h>
#include <os.h>
+#include <asm/test.h>
#include <asm/u-boot-sandbox.h>
/*
@@ -25,9 +26,17 @@ void flush_cache(unsigned long start, unsigned long size)
{
}
+/* system timer offset in ms */
+static unsigned long sandbox_timer_offset;
+
+void sandbox_timer_add_offset(unsigned long offset)
+{
+ sandbox_timer_offset += offset;
+}
+
unsigned long timer_read_counter(void)
{
- return os_get_nsec() / 1000;
+ return os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
}
int dram_init(void)
--
1.7.11.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 2/3] sandbox: eth: Add a function to skip ping timeouts
2015-04-21 18:57 [U-Boot] [PATCH 0/3] test: Speed up test timeouts by advancing time Joe Hershberger
2015-04-21 18:57 ` [U-Boot] [PATCH 1/3] sandbox: Add test function to advance time Joe Hershberger
@ 2015-04-21 18:57 ` Joe Hershberger
2015-04-24 4:13 ` Simon Glass
2015-04-21 18:57 ` [U-Boot] [PATCH 3/3] test: dm: eth: Skip timeouts on ping tests Joe Hershberger
2 siblings, 1 reply; 10+ messages in thread
From: Joe Hershberger @ 2015-04-21 18:57 UTC (permalink / raw)
To: u-boot
When called, the next call to receive will trigger a 10-second leap
forward in time to avoid waiting for time to pass when tests are
evaluating timeout behavior.
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---
arch/sandbox/include/asm/eth.h | 2 ++
drivers/net/sandbox.c | 17 +++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/arch/sandbox/include/asm/eth.h b/arch/sandbox/include/asm/eth.h
index 4b79ede..88804fb 100644
--- a/arch/sandbox/include/asm/eth.h
+++ b/arch/sandbox/include/asm/eth.h
@@ -12,4 +12,6 @@
void sandbox_eth_disable_response(int index, bool disable);
+void sandbox_eth_skip_timeout(void);
+
#endif /* __ETH_H */
diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c
index e239ff4..4e083d3 100644
--- a/drivers/net/sandbox.c
+++ b/drivers/net/sandbox.c
@@ -11,6 +11,7 @@
#include <dm.h>
#include <malloc.h>
#include <net.h>
+#include <asm/test.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -30,6 +31,7 @@ struct eth_sandbox_priv {
};
static bool disabled[8] = {false};
+static bool skip_timeout;
/*
* sandbox_eth_disable_response()
@@ -42,6 +44,16 @@ void sandbox_eth_disable_response(int index, bool disable)
disabled[index] = disable;
}
+/*
+ * sandbox_eth_skip_timeout()
+ *
+ * When the first packet read is attempted, fast-forward time
+ */
+void sandbox_eth_skip_timeout(void)
+{
+ skip_timeout = true;
+}
+
static int sb_eth_start(struct udevice *dev)
{
struct eth_sandbox_priv *priv = dev_get_priv(dev);
@@ -144,6 +156,11 @@ static int sb_eth_recv(struct udevice *dev, uchar **packetp)
{
struct eth_sandbox_priv *priv = dev_get_priv(dev);
+ if (skip_timeout) {
+ sandbox_timer_add_offset(10000UL);
+ skip_timeout = false;
+ }
+
if (priv->recv_packet_length) {
int lcl_recv_packet_length = priv->recv_packet_length;
--
1.7.11.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 3/3] test: dm: eth: Skip timeouts on ping tests
2015-04-21 18:57 [U-Boot] [PATCH 0/3] test: Speed up test timeouts by advancing time Joe Hershberger
2015-04-21 18:57 ` [U-Boot] [PATCH 1/3] sandbox: Add test function to advance time Joe Hershberger
2015-04-21 18:57 ` [U-Boot] [PATCH 2/3] sandbox: eth: Add a function to skip ping timeouts Joe Hershberger
@ 2015-04-21 18:57 ` Joe Hershberger
2015-04-24 4:14 ` Simon Glass
2 siblings, 1 reply; 10+ messages in thread
From: Joe Hershberger @ 2015-04-21 18:57 UTC (permalink / raw)
To: u-boot
Indicate to the emulated sandbox Ethernet driver when we expect a
timeout and tell it to leap forward.
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---
test/dm/eth.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/test/dm/eth.c b/test/dm/eth.c
index 4891f3a..196eba8 100644
--- a/test/dm/eth.c
+++ b/test/dm/eth.c
@@ -135,6 +135,7 @@ static int dm_test_net_retry(struct dm_test_state *dms)
sandbox_eth_disable_response(1, true);
setenv("ethact", "eth at 10004000");
setenv("netretry", "yes");
+ sandbox_eth_skip_timeout();
ut_assertok(net_loop(PING));
ut_asserteq_str("eth at 10002000", getenv("ethact"));
@@ -144,6 +145,7 @@ static int dm_test_net_retry(struct dm_test_state *dms)
*/
setenv("ethact", "eth at 10004000");
setenv("netretry", "no");
+ sandbox_eth_skip_timeout();
ut_asserteq(-ETIMEDOUT, net_loop(PING));
ut_asserteq_str("eth at 10004000", getenv("ethact"));
--
1.7.11.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 1/3] sandbox: Add test function to advance time
2015-04-21 18:57 ` [U-Boot] [PATCH 1/3] sandbox: Add test function to advance time Joe Hershberger
@ 2015-04-24 4:13 ` Simon Glass
2015-05-02 14:42 ` Simon Glass
0 siblings, 1 reply; 10+ messages in thread
From: Simon Glass @ 2015-04-24 4:13 UTC (permalink / raw)
To: u-boot
On 21 April 2015 at 12:57, Joe Hershberger <joe.hershberger@ni.com> wrote:
> Add a function that maintains an offset to include in the system timer
> values returned from the lib/time.c APIs.
>
> This will allow timeouts to be skipped instantly in tests
>
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
> ---
>
> arch/sandbox/cpu/cpu.c | 5 -----
> arch/sandbox/include/asm/test.h | 8 ++++++++
> board/sandbox/sandbox.c | 11 ++++++++++-
> 3 files changed, 18 insertions(+), 6 deletions(-)
Acked-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 2/3] sandbox: eth: Add a function to skip ping timeouts
2015-04-21 18:57 ` [U-Boot] [PATCH 2/3] sandbox: eth: Add a function to skip ping timeouts Joe Hershberger
@ 2015-04-24 4:13 ` Simon Glass
2015-05-02 14:42 ` Simon Glass
0 siblings, 1 reply; 10+ messages in thread
From: Simon Glass @ 2015-04-24 4:13 UTC (permalink / raw)
To: u-boot
On 21 April 2015 at 12:57, Joe Hershberger <joe.hershberger@ni.com> wrote:
> When called, the next call to receive will trigger a 10-second leap
> forward in time to avoid waiting for time to pass when tests are
> evaluating timeout behavior.
>
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
> ---
>
> arch/sandbox/include/asm/eth.h | 2 ++
> drivers/net/sandbox.c | 17 +++++++++++++++++
> 2 files changed, 19 insertions(+)
Acked-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 3/3] test: dm: eth: Skip timeouts on ping tests
2015-04-21 18:57 ` [U-Boot] [PATCH 3/3] test: dm: eth: Skip timeouts on ping tests Joe Hershberger
@ 2015-04-24 4:14 ` Simon Glass
2015-05-02 14:42 ` Simon Glass
0 siblings, 1 reply; 10+ messages in thread
From: Simon Glass @ 2015-04-24 4:14 UTC (permalink / raw)
To: u-boot
On 21 April 2015 at 12:57, Joe Hershberger <joe.hershberger@ni.com> wrote:
> Indicate to the emulated sandbox Ethernet driver when we expect a
> timeout and tell it to leap forward.
>
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
> ---
>
> test/dm/eth.c | 2 ++
> 1 file changed, 2 insertions(+)
Acked-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 1/3] sandbox: Add test function to advance time
2015-04-24 4:13 ` Simon Glass
@ 2015-05-02 14:42 ` Simon Glass
0 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2015-05-02 14:42 UTC (permalink / raw)
To: u-boot
On 23 April 2015 at 22:13, Simon Glass <sjg@chromium.org> wrote:
> On 21 April 2015 at 12:57, Joe Hershberger <joe.hershberger@ni.com> wrote:
>> Add a function that maintains an offset to include in the system timer
>> values returned from the lib/time.c APIs.
>>
>> This will allow timeouts to be skipped instantly in tests
>>
>> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
>> ---
>>
>> arch/sandbox/cpu/cpu.c | 5 -----
>> arch/sandbox/include/asm/test.h | 8 ++++++++
>> board/sandbox/sandbox.c | 11 ++++++++++-
>> 3 files changed, 18 insertions(+), 6 deletions(-)
>
> Acked-by: Simon Glass <sjg@chromium.org>
Applied to u-boot-dm, thanks!
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 2/3] sandbox: eth: Add a function to skip ping timeouts
2015-04-24 4:13 ` Simon Glass
@ 2015-05-02 14:42 ` Simon Glass
0 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2015-05-02 14:42 UTC (permalink / raw)
To: u-boot
On 23 April 2015 at 22:13, Simon Glass <sjg@chromium.org> wrote:
> On 21 April 2015 at 12:57, Joe Hershberger <joe.hershberger@ni.com> wrote:
>> When called, the next call to receive will trigger a 10-second leap
>> forward in time to avoid waiting for time to pass when tests are
>> evaluating timeout behavior.
>>
>> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
>> ---
>>
>> arch/sandbox/include/asm/eth.h | 2 ++
>> drivers/net/sandbox.c | 17 +++++++++++++++++
>> 2 files changed, 19 insertions(+)
>
> Acked-by: Simon Glass <sjg@chromium.org>
Applied to u-boot-dm, thanks!
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH 3/3] test: dm: eth: Skip timeouts on ping tests
2015-04-24 4:14 ` Simon Glass
@ 2015-05-02 14:42 ` Simon Glass
0 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2015-05-02 14:42 UTC (permalink / raw)
To: u-boot
On 23 April 2015 at 22:14, Simon Glass <sjg@chromium.org> wrote:
> On 21 April 2015 at 12:57, Joe Hershberger <joe.hershberger@ni.com> wrote:
>> Indicate to the emulated sandbox Ethernet driver when we expect a
>> timeout and tell it to leap forward.
>>
>> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
>> ---
>>
>> test/dm/eth.c | 2 ++
>> 1 file changed, 2 insertions(+)
>
> Acked-by: Simon Glass <sjg@chromium.org>
Applied to u-boot-dm, thanks!
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-05-02 14:42 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-21 18:57 [U-Boot] [PATCH 0/3] test: Speed up test timeouts by advancing time Joe Hershberger
2015-04-21 18:57 ` [U-Boot] [PATCH 1/3] sandbox: Add test function to advance time Joe Hershberger
2015-04-24 4:13 ` Simon Glass
2015-05-02 14:42 ` Simon Glass
2015-04-21 18:57 ` [U-Boot] [PATCH 2/3] sandbox: eth: Add a function to skip ping timeouts Joe Hershberger
2015-04-24 4:13 ` Simon Glass
2015-05-02 14:42 ` Simon Glass
2015-04-21 18:57 ` [U-Boot] [PATCH 3/3] test: dm: eth: Skip timeouts on ping tests Joe Hershberger
2015-04-24 4:14 ` Simon Glass
2015-05-02 14:42 ` Simon Glass
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.