libyang icon indicating copy to clipboard operation
libyang copied to clipboard

libyang regression fails due to lysp_check_date()

Open tudorv-gh opened this issue 3 years ago • 2 comments

I've encountered an issue running the libyang regression that causes all tests to fail depending on the build system timezone.

The OS I'm using is Ubuntu 22.04 LTS and the time zone is IST (Irish Standard Time, UTC+1). Building the master branch and running the regression causes all tests to fail, and I've narrowed down the cause of failure to lysp_check_date() in "tree_schema_common.c". There is a mismatch in date/time before and after the call to mktime() that causes date mismatch errors for DST dates:

Non-DST:

tm:  2016-08-05 00:00:00.000
tm_: 2016-08-05 01:00:00.000

DST:

tm:  2017-02-20 00:00:00.000
tm_: 2017-02-19 23:00:00.000

For the DST date, day of the month is modified by mktime() and lysp_check_date() returns LY_EINVAL.

If I change my system's timezone to CEST (UTC+2) I get:

Non-DST:

tm:  2016-08-05 00:00:00.000
tm_: 2016-08-05 01:00:00.000

DST:

tm:  2017-02-20 00:00:00.000
tm_: 2017-02-20 00:00:00.000

No changes to day of the month in this scenario and the regression runs successfully.

I ran the same on the "devel" branch, there are no changes in behaviour compared to the "master" branch.

A simple workaround is to set tm.tm_hour to a non-zero value (e.g. 12) prior to the copy to tm_ and call to mktime().

To reproduce this issue, I believe changing the system time to IST (UTC+1) timezone should be all that's needed to create the regression failures.

tudorv-gh avatar Aug 11 '22 14:08 tudorv-gh

Right, should be fixed.

michalvasko avatar Aug 17 '22 08:08 michalvasko

Thank you, I can confirm the regression completes successfully on my system with the latest devel branch.

tudorv-gh avatar Aug 17 '22 09:08 tudorv-gh