[PATCH v4] string: Add tests for unique strerror and strsignal strings
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Mon Sep 22 16:36:24 GMT 2025
On 22/09/25 13:33, Florian Weimer wrote:
> * Adhemerval Zanella Netto:
>
>>>> +#include <support/test-driver.c>
>>>> diff --git a/sysdeps/unix/sysv/linux/tst-strerror-strings.c b/sysdeps/unix/sysv/linux/tst-strerror-strings.c
>>>> new file mode 100644
>>>> index 0000000000..4bd0e4b0a8
>>>> --- /dev/null
>>>> +++ b/sysdeps/unix/sysv/linux/tst-strerror-strings.c
>>>
>>>> + /* Negative as well as large positive errnums are unused. 160 allows
>>>> + us to define more errors without needing to update this test. */
>>>> + int is_unknown_error
>>>> + = (strstr (err_str[i], "Unknown error ") == err_str[i]);
>>>> + TEST_VERIFY_EXIT ((i >= 0 && i < 160) || is_unknown_error);
>>>
>>> What do others think about the hard-coded 160 here? I don't see a
>>> good way around it.
>>
>> Maybe derive from errlist.h by extending scripts/gen-as-const.py to
>> build a TU similar to stdio-common/errlist-data-gen.c?
>
> Ah, so basically look at
>
> echo '#include <linux/errno.h>'| gcc -E - -dM | grep '^#define E'
>
> and cross-check against the strerror functions?
I think it can work, although I was think about using errlist.h to get the
expected list built in libc.so.
>
> Maybe this could be in a follow-up patch?
>
> Thanks,
> Florian
>
More information about the Libc-alpha
mailing list