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

Florian Weimer fweimer@redhat.com
Mon Sep 22 16:33:44 GMT 2025


* 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?

Maybe this could be in a follow-up patch?

Thanks,
Florian



More information about the Libc-alpha mailing list