os: allow os_time_advance() when OS not started. This is useful in unit tests when we need to make time pass (e.g., to test timeouts).
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/b7315558 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b7315558 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b7315558 Branch: refs/heads/sterly_refactor Commit: b73155586fd35f6592e5b554ad3d123000e3fc4e Parents: 5a7c0a1 Author: Christopher Collins <[email protected]> Authored: Sat Jul 30 17:27:53 2016 -0700 Committer: Sterling Hughes <[email protected]> Committed: Sun Jul 31 21:58:57 2016 -0700 ---------------------------------------------------------------------- libs/os/src/os_time.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b7315558/libs/os/src/os_time.c ---------------------------------------------------------------------- diff --git a/libs/os/src/os_time.c b/libs/os/src/os_time.c index 2ce379e..4ef439f 100644 --- a/libs/os/src/os_time.c +++ b/libs/os/src/os_time.c @@ -97,10 +97,14 @@ os_time_advance(int ticks) assert(ticks >= 0); if (ticks > 0) { - os_time_tick(ticks); - os_callout_tick(); - os_sched_os_timer_exp(); - os_sched(NULL); + if (!os_started()) { + g_os_time += ticks; + } else { + os_time_tick(ticks); + os_callout_tick(); + os_sched_os_timer_exp(); + os_sched(NULL); + } } }
