]> git.ipfire.org Git - thirdparty/util-linux.git/commit
tests: (col) avoid hardcoding of errno string
authorPatrick Steinhardt <ps@pks.im>
Fri, 23 Aug 2019 13:32:57 +0000 (15:32 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 27 Aug 2019 07:37:01 +0000 (09:37 +0200)
commiteebc9e4dc2d3c0de174511823eca74a4cd645bff
tree950ec0f07e1eb5bec7aa2f7d0ed114442adbffc8
parent6ef9a9e18471b9a57d2b28fd76b4b8e3840d3ffa
tests: (col) avoid hardcoding of errno string

The col/multibyte test has a hardcoded error string as part of its
expected output that is returned by glibc's strerror(3P) function. Even
though many of these strings are the same across libc implementations,
they are not standardiced and some are certainly different. One example
is the string for EILSEQ on musl libc.

To fix this, we introduce a new test helper "test_strerror". The helper
can be invoked with an error code like "EILSEQ", which will cause it to
print out the the respective error message for that code. Note that
"test_strerror" cannot act on the error's value (e.g. 84 for EILSEQ), as
these aren't standardized either. Instead, we thus need to have an array
of the error's string representation ("EILSEQ") to its respective error
code (the define EILSEQ). The array can trivially be extended as
required, thus it is only sparsely populated with EILSEQ right now.

To fix the col/multibyte test, we introduce a call to sed(1) to replace
the strerror(3P) message from EILSEQ with "EILSEQ". Furthermore, as
we're running tests with the POSIX locale by default which treats all
bytes as valid multibyte sequences, we have to change to the C.UTF-8
locale instead to actually get an error.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
tests/commands.sh
tests/expected/col/multibyte
tests/helpers/Makemodule.am
tests/helpers/test_strerror.c [new file with mode: 0644]
tests/ts/col/multibyte