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

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Mon Sep 22 16:23:06 GMT 2025



On 22/09/25 11:35, Florian Weimer wrote:
> * Arjun Shankar:
> 
>> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
>> index 2c5bf42236..973dcc3822 100644
>> --- a/sysdeps/unix/sysv/linux/Makefile
>> +++ b/sysdeps/unix/sysv/linux/Makefile
>> @@ -716,3 +716,17 @@ tests-static += \
>>    tst-rseq-nptl-static \
>>    # tests-static
>>  endif
>> +
>> +ifeq ($(subdir),string)
>> +modules-names += tst-xsi-strerror_r-mod
>> +tests += \
>> +  tst-sigabbrev_np-strings \
>> +  tst-strerror-strings \
>> +  tst-strerror_l-strings \
>> +  tst-strerror_r-strings \
>> +  tst-strerrordesc_np-strings \
>> +  tst-strsignal-strings \
>> +  tst-xsi-strerror_r-strings \
>> +  # tests
>> +$(objpfx)tst-xsi-strerror_r-strings: $(objpfx)tst-xsi-strerror_r-mod.so
>> +endif
> 
> I would put a blank line before the linking recipe.
> 
> endif # $(subdir) == string
> 
>> +#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);
> 
> Whast 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?


More information about the Libc-alpha mailing list