[riot-notifications] [RIOT-OS/RIOT] unittests/tests-rtc: fail on native (#16184)

Martine Lenders notifications at github.com
Mon Apr 12 16:11:08 CEST 2021


Just for fun, I ran the tests with some output as shown in <details><summary>this patch</summary>

```diff
diff --git a/.github/workflows/release-test.yml b/.github/workflows/release-test.yml
index 8f339914e9..a5c9e7fb96 100644
--- a/.github/workflows/release-test.yml
+++ b/.github/workflows/release-test.yml
@@ -46,8 +46,8 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        pytest_mark:
-          - "iotlab_creds"
+        # pytest_mark:
+        #   - "iotlab_creds"
         include:
           - pytest_mark: "not iotlab_creds"
             sudo: "sudo"
@@ -80,7 +80,7 @@ jobs:
     - name: Checkout RIOT
       uses: actions/checkout at v2
       with:
-        repository: RIOT-OS/RIOT
+        repository: miri64/RIOT
         path: RIOT
         fetch-depth: 1
         ref: ${{ github.event.inputs.riot_version }}
@@ -134,7 +134,7 @@ jobs:
           TTN_DEV_ID="riot_lorawan_1" \
           TTN_DEV_ID_ABP="riot_lorawan_1_abp" \
           RIOTBASE=${RIOTBASE} \
-          $(which tox) -- ${TOX_ARGS} -m "${{ matrix.pytest_mark }}"
+          $(which tox) -- ${TOX_ARGS} -m "${{ matrix.pytest_mark }}" -k 'spec01 and task02'
     - name: junit2html and XML deploy
       if: always()
       run: |
diff --git a/tests/unittests/tests-rtc/tests-rtc.c b/tests/unittests/tests-rtc/tests-rtc.c
index eeac8ea472..68735b812f 100644
--- a/tests/unittests/tests-rtc/tests-rtc.c
+++ b/tests/unittests/tests-rtc/tests-rtc.c
@@ -12,6 +12,7 @@
  * @file
  */
 #include <string.h>
+#include <stdio.h>
 #include <errno.h>
 
 #include "embUnit.h"
@@ -47,7 +48,15 @@ static void test_rtc_compat(void)
 
     struct tm t2 = t1;
 
+    printf("pre t1: sec=%i, min=%i, hour=%i, mday=%i, mon=%i, year=%i, "
+           "wday=%i, yday=%i, isdst=%i\n", t1.tm_sec, t1.tm_min, t1.tm_hour,
+           t1.tm_mday, t1.tm_mon, t1.tm_year, t1.tm_wday, t1.tm_yday,
+           t1.tm_isdst);
     mktime(&t1);
+    printf("post t1: sec=%i, min=%i, hour=%i, mday=%i, mon=%i, year=%i, "
+           "wday=%i, yday=%i, isdst=%i\n", t1.tm_sec, t1.tm_min, t1.tm_hour,
+           t1.tm_mday, t1.tm_mon, t1.tm_year, t1.tm_wday, t1.tm_yday,
+           t1.tm_isdst);
     rtc_tm_normalize(&t2);
     _test_equal_tm(&t1, &t2);
 }
@@ -68,7 +77,15 @@ static void test_rtc_sec_wrap(void)
 
     struct tm t2 = t1;
 
+    printf("pre t1: sec=%i, min=%i, hour=%i, mday=%i, mon=%i, year=%i, "
+           "wday=%i, yday=%i, isdst=%i\n", t1.tm_sec, t1.tm_min, t1.tm_hour,
+           t1.tm_mday, t1.tm_mon, t1.tm_year, t1.tm_wday, t1.tm_yday,
+           t1.tm_isdst);
     mktime(&t1);
+    printf("post t1: sec=%i, min=%i, hour=%i, mday=%i, mon=%i, year=%i, "
+           "wday=%i, yday=%i, isdst=%i\n", t1.tm_sec, t1.tm_min, t1.tm_hour,
+           t1.tm_mday, t1.tm_mon, t1.tm_year, t1.tm_wday, t1.tm_yday,
+           t1.tm_isdst);
     rtc_tm_normalize(&t2);
     _test_equal_tm(&t1, &t2);
 }
```

</details>

`mktime` does [indeed *not* do the normalization](https://github.com/miri64/RIOT/runs/2324467213?check_suite_focus=true#step:12:323) described [in `man 3 mktime`](https://linux.die.net/man/3/mktime):

```
.pre t1: sec=42, min=37, hour=13, mday=23, mon=5, year=84, wday=0, yday=0, isdst=1
post t1: sec=42, min=37, hour=13, mday=23, mon=5, year=84, wday=0, yday=0, isdst=1

rtc_tests.test_rtc_compat (tests/unittests/tests-rtc/tests-rtc.c 30) exp 0 was 6
.pre t1: sec=360, min=58, hour=23, mday=30, mon=5, year=100, wday=0, yday=0, isdst=1
post t1: sec=360, min=58, hour=23, mday=30, mon=5, year=100, wday=0, yday=0, isdst=1
```

<details><summary>(compared to output on my Ubuntu 20.04 machine)</summary>

```
.pre t1: sec=42, min=37, hour=13, mday=23, mon=5, year=84, wday=0, yday=0, isdst=1
post t1: sec=42, min=37, hour=13, mday=23, mon=5, year=84, wday=6, yday=174, isdst=1
.pre t1: sec=360, min=58, hour=23, mday=30, mon=5, year=100, wday=0, yday=0, isdst=1
post t1: sec=0, min=4, hour=0, mday=1, mon=6, year=100, wday=6, yday=182, isdst=1
```

</details>

@benpicco would it make sense to check against a statically initialized `t1` instead?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/issues/16184#issuecomment-817844840
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210412/eaf73e34/attachment.htm>


More information about the notifications mailing list