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/e5433b05 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/e5433b05 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/e5433b05 Branch: refs/heads/develop Commit: e5433b050565a9be2f9b7ba15021933e3d85d034 Parents: 60d6285 Author: Christopher Collins <[email protected]> Authored: Sat Jul 30 17:27:53 2016 -0700 Committer: Christopher Collins <[email protected]> Committed: Sat Jul 30 17:41:40 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/e5433b05/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); + } } }
