[PATCH v4] string: Add tests for unique strerror and strsignal strings

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Tue Sep 23 12:25:50 GMT 2025



On 23/09/25 09:11, Arjun Shankar wrote:
> Hi Florian, Adhemerval,
> 
>>>> 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.
> 
> I know that it sounds kind of implausible that we might make an
> erroneous change to errlist.h in the future. However, keeping the
> test's behaviour independent of the list can help guard against the
> test silently passing when the list is somehow updated incorrectly.
> Does this sound reasonable? I'm going to think about how I can make
> the test better here, instead of this hardcoded 160.

Right, but my understanding was this testcase aims to check uniqueness
of errors strings and that it should at least check for the number of
different error string glibc can return.

Testing more should be ok, since invalid inputs would return empty/NULL 
string; but checking a number lower than string list makes the test invalid.

Can't you do something like:

const char *const _sys_errlist_internal[] __attribute_maybe_unused__ =
  {
#define _S(n, str)         [ERR_MAP(n)] = str,
#include <errlist.h>
#undef _S
  };
const size_t _sys_errlist_internal_len = array_length (_sys_errlist_internal);

And use _sys_errlist_internal_len? 


More information about the Libc-alpha mailing list