Tests in the cron repository failing

  1. My goal is: To figure out how Mongoose’s implementation of cron works in order to debug our application which uses it.
  2. My actions are: I forked the mongoose-os-libs/cron repository (here’s the link to my fork) and manually added all the files required so that the Makefile in the test directory compiles.
  3. The result I see is: Here is what happens when I run make test.
NOW: 1504065620 (2017-08-29 22:00:20 UTC-7)
--------------------------------------------------
expr = "* * * * * *"
current = 1504065621 (2017-08-29 22:00:21 UTC-7)
expe[0] = 1504065621 (2017-08-29 22:00:21 UTC-7)
expe[1] = 1504065622 (2017-08-29 22:00:22 UTC-7)
expe[2] = 1504065623 (2017-08-29 22:00:23 UTC-7)
--------------------------------------------------
expr = "*/15 * * * * *"
current = 1504065630 (2017-08-29 22:00:30 UTC-7)
expe[0] = 1504065630 (2017-08-29 22:00:30 UTC-7)
expe[1] = 1504065645 (2017-08-29 22:00:45 UTC-7)
expe[2] = 1504065660 (2017-08-29 22:01:00 UTC-7)
--------------------------------------------------
expr = "0 * * * * *"
current = 1504065660 (2017-08-29 22:01:00 UTC-7)
expe[0] = 1504065660 (2017-08-29 22:01:00 UTC-7)
expe[1] = 1504065720 (2017-08-29 22:02:00 UTC-7)
expe[2] = 1504065780 (2017-08-29 22:03:00 UTC-7)
--------------------------------------------------
expr = "0 * * * * 3"
current = 1504065660 (2017-08-29 22:01:00 UTC-7)
expe[0] = 1504072800 (2017-08-30 00:00:00 UTC-7)
expe[1] = 1504072860 (2017-08-30 00:01:00 UTC-7)
expe[2] = 1504072920 (2017-08-30 00:02:00 UTC-7)      <---- FAIL (difference: -7140)
--------------------------------------------------
expr = "10 * * * * *"
current = 1504065670 (2017-08-29 22:01:10 UTC-7)
expe[0] = 1504065670 (2017-08-29 22:01:10 UTC-7)
expe[1] = 1504065730 (2017-08-29 22:02:10 UTC-7)
expe[2] = 1504065790 (2017-08-29 22:03:10 UTC-7)
--------------------------------------------------
expr = "10 */1 * * * *"
current = 1504065670 (2017-08-29 22:01:10 UTC-7)
expe[0] = 1504065670 (2017-08-29 22:01:10 UTC-7)
expe[1] = 1504065730 (2017-08-29 22:02:10 UTC-7)
expe[2] = 1504065790 (2017-08-29 22:03:10 UTC-7)
--------------------------------------------------
expr = "0 0 * * * *"
current = 1504069200 (2017-08-29 23:00:00 UTC-7)
expe[0] = 1504069200 (2017-08-29 23:00:00 UTC-7)
expe[1] = 1504072800 (2017-08-30 00:00:00 UTC-7)
expe[2] = 1504076400 (2017-08-30 01:00:00 UTC-7)
--------------------------------------------------
expr = "0 0 0 * * *"
current = 1504137600 (2017-08-30 18:00:00 UTC-7)
expe[0] = 1504072800 (2017-08-30 00:00:00 UTC-7)
expe[1] = 1504159200 (2017-08-31 00:00:00 UTC-7)
expe[2] = 1504245600 (2017-09-01 00:00:00 UTC-7)      <---- FAIL (difference: 64800)
--------------------------------------------------
expr = "0 0 0 31 * *"
current = 1504137600 (2017-08-30 18:00:00 UTC-7)
expe[0] = 1504159200 (2017-08-31 00:00:00 UTC-7)
expe[1] = 1509429600 (2017-10-31 00:00:00 UTC-7)
expe[2] = 1514703600 (2017-12-31 00:00:00 UTC-7)      <---- FAIL (difference: -21600)
--------------------------------------------------
expr = "0 0 0 1 * *"
current = 1504224000 (2017-08-31 18:00:00 UTC-7)
expe[0] = 1504245600 (2017-09-01 00:00:00 UTC-7)
expe[1] = 1506837600 (2017-10-01 00:00:00 UTC-7)
expe[2] = 1509516000 (2017-11-01 00:00:00 UTC-7)      <---- FAIL (difference: -21600)
--------------------------------------------------
expr = "0 0 9 1-7 * 1"
current = 1504515600 (2017-09-04 03:00:00 UTC-7)
expe[0] = 1504537200 (2017-09-04 09:00:00 UTC-7)
expe[1] = 1506956400 (2017-10-02 09:00:00 UTC-7)
expe[2] = 1509984000 (2017-11-06 09:00:00 UTC-7)      <---- FAIL (difference: -21600)
--------------------------------------------------
expr = "* * * 5 9 *"
current = 1504569600 (2017-09-04 18:00:00 UTC-7)
expe[0] = 1504591200 (2017-09-05 00:00:00 UTC-7)
expe[1] = 1504591201 (2017-09-05 00:00:01 UTC-7)
expe[2] = 1504591202 (2017-09-05 00:00:02 UTC-7)      <---- FAIL (difference: -21600)
--------------------------------------------------
expr = "0 0 0 * * 3"
current = 1504656000 (2017-09-05 18:00:00 UTC-7)
expe[0] = 1504072800 (2017-08-30 00:00:00 UTC-7)
expe[1] = 1504677600 (2017-09-06 00:00:00 UTC-7)
expe[2] = 1505282400 (2017-09-13 00:00:00 UTC-7)      <---- FAIL (difference: 583200)
--------------------------------------------------
  1. My expectation & question is: I did not modify the code in the repo (except some extra printf code for debugging) so I would expect the tests to pass. I checked the expected printout and each of them conforms to specification, so it really is the current that is wrong. (For example, in the first failing test, 29 Aug 2017 is a Tuesday, so asking for the next Wednesday should return midnight on 30 Aug 2017, but that is not what current equals.) I would be grateful if anyone who is familiar with the Mongoose OS implementation of cron could tell me what I’m doing wrong in my fork, as I assume that these tests pass in the “official” branch of this repo. Thanks!

Add -DCRON_USE_LOCAL_TIME=1 to the build commands and all tests are passing fine.

Hi nliviu,

thanks! This made my tests all pass as well! I’m a bit embarrassed the fix is so simple, but anyway, cheers!

No problem. The solution is in mos.yml.