Skip to content
Snippets Groups Projects
Unverified Commit 172f6acd authored by Tomáš Pecka's avatar Tomáš Pecka
Browse files

tests: Fix wrong select timeout handling since glibc=2.33

In recent Arch Linux builds we encountered some timeouts in tests.
Interestingly, the 30s timeouts were encountered not after 30s but
right-away. See the ctest output attached at the end of the message.

I remembered that Arch switched to glibc=2.33 recently. And by stracing
the test process I have noticed that indeed, the select in waitSignalTimeout
function timeouted early.
It seemed that the timeval struct is the problem and indeed it was. It
didn't like setting the 30s timeout as {.tv_sec = 0, .tv_usec = 30 *
1000 * 1000}. However, I can't find in any manpage why this is wrong...

It seems to be fixed by limiting tv_usec to be from [0; 1000*1000)
range and transfer the whole seconds into the tv_sec field.
And the glibc docs [1] says it so explicitely:

> When struct timeval values are produced by GNU C Library functions,
> the value in this field will always be greater than or equal to zero,
> and less than 1,000,000. When struct timeval values are supplied to GNU
> C Library functions, the value in this field must be in the same range.

[1] https://www.gnu.org/software/libc/manual/html_mono/libc.html#Time-Types

 -------------------------------------------------------------------------------
 aql/AutomatonIteration.aql
 -------------------------------------------------------------------------------
 /builds/algorithms-library-toolkit/infrastructure/cd-release/src/algorithms-library-snapshot/build/tests/AutomatonIteration.cpp:17
 ...............................................................................

 /builds/algorithms-library-toolkit/infrastructure/cd-release/src/algorithms-library-snapshot/tests/testing/TimeoutAqlTest.cpp:206: warning:
   AqlTest: timeout (30000000 us) reached
   Trying to execute testfile /builds/algorithms-library-toolkit/infrastructure/cd-release/src/algorithms-library-snapshot/tests/aql/AutomatonIteration.aql

 Seed was: 1053288110
   Child aqlout was: ><
   Child stdout was: ><
   Child stderr was: ><

 /builds/algorithms-library-toolkit/infrastructure/cd-release/src/algorithms-library-snapshot/tests/testing/TimeoutAqlTest.cpp:208: FAILED:

 ===============================================================================
 test cases: 1 | 1 failed
 assertions: 3 | 2 passed | 1 failed
parent 81b01ad3
No related branches found
No related tags found
1 merge request!177tests: Fix wrong select timeout handling since glibc=2.33
Pipeline #125863 passed with warnings