Add unit tests for _dl_cache_check_flags

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Wed Apr 30 19:59:13 GMT 2025



On 29/04/25 09:32, panzhe0328 wrote:
> Dear:
>   I trust this message reaches you in good health and high spirits.
>   I am reaching out to seek your valuable help regarding unit test in glibc.
> 
>   I would like to ask if there are unit tests regarding the _dl_cache_check_flags macro in glibc? 
>   This macro is used to check the flag of the entries in ld.so.cache.
>   
>   If I want to test this macro, should I create a temporary cache file through ldconfig and 
>   then use it, or is there already a relevant test in glibc?
> 
>   sysdeps/unix/sysv/linux/loongarch/dl-cache.h
>     #define _dl_cache_check_flags(flags)                    \
>     ((flags) == _DL_CACHE_DEFAULT_ID)
> 
> Best wishs to you!

I don't think we have a unit test specific for _dl_cache_check_flags,
although I think a functional test for _dl_load_cache_lookup would
make more sense and check properly that the macro works correctly.

We do have some container tests that check dl-cache.c code:

  tst-ldconfig-bad-aux-cache 
  tst-ldconfig-ld_so_conf-update

So I would suggest you follow their idea since they both invoke
ldconfig to check a cache and add functional check if ld works
correctly.  We will need a container test for ldconfig, since
/etc/ld.so.cache is defined at configure time.


More information about the Libc-help mailing list