Skip to content

Commit 712e6d8

Browse files
committed
test: skip lj-1470 test for unconfigured timezones
`os.time()` uses `mktime()` to specify time by the given table. `mktime()` produces the call to `tzset()` to determine the system's timezone. If the TZ variable does not appear in the environment, the system timezone is used. The system timezone is configured by copying, or linking, a file in the tzfile(5) format to /etc/localtime. So, if this file is omitted (like in RED OS), the errno is set to a non-zero value. This leads to the nil returned by the `os.time()` for -1 time value. This patch skips the test if this file is missed to be sure that we don't obtain any false positive failures due to system misconfigurations. Reviewed-by: Evgeniy Temirgaleev <e.temirgaleev@tarantool.org> Reviewed-by: Sergey Bronnikov <sergeyb@tarantool.org> Signed-off-by: Sergey Kaplun <skaplun@tarantool.org>
1 parent ec9d188 commit 712e6d8

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

test/tarantool-tests/lj-1470-os-time-epoch-minus-1s.test.lua

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
local tap = require('tap')
22

3+
local function unconfigured_timezone()
4+
-- `os.time()` uses `mktime()` to specify time by the given
5+
-- table. `mktime()` produces the call to `tzset()` to determine
6+
-- the system's timezone.
7+
-- If the TZ variable does not appear in the environment, the
8+
-- system timezone is used. The system timezone is configured by
9+
-- copying, or linking, a file in the tzfile(5) format to
10+
-- /etc/localtime. So, if this file is omitted, the errno is
11+
-- set to a non-zero value. This leads to the nil returned by
12+
-- the `os.time()` for -1 time value. Let's skip the test if
13+
-- this file is missed to be sure that we don't obtain any false
14+
-- positive failures due to system misconfigurations.
15+
local f = io.open('/etc/localtime', 'r')
16+
return not f
17+
end
18+
319
-- The test file demonstrates os.time() fail to return -1 time
420
-- value.
521
-- See also: https://github.com/LuaJIT/LuaJIT/issues/1470.
6-
local test = tap.test('lj-1470-os-time-epoch-minus-1s')
22+
local test = tap.test('lj-1470-os-time-epoch-minus-1s'):skipcond({
23+
['Unconfigured timezone rules'] = unconfigured_timezone(),
24+
})
725

826
test:plan(1)
927

0 commit comments

Comments
 (0)