[SSSD] [PATCH] TESTS: Add test for mmap cache client crash

Michal Židek mzidek at redhat.com
Thu Nov 27 20:02:22 UTC 2014


On 11/25/2014 02:13 PM, Lukas Slebodnik wrote:
> On (20/11/14 11:25), Lukas Slebodnik wrote:
>> ehlo,
>>
>> I was not able to mock functions with linker flang -wrap when
>> they was called indirectly by another function from dynamic library.
>> (It works with dirrect invocation of function)
>>
>> mc_client_tests_LDFLAGS = \
>>     -Wl,-wrap,sss_nss_check_header \
>>     -Wl,-wrap,sss_open_cloexec \
>>     $(NULL)
>>
>> This is a reason why I wrote mocked function in unit test
>> e.g.
>> __real_sss_open_cloexec
>> __wrap_sss_open_cloexec
>> sss_open_cloexec
>>
>> If you know better way how to mock functions I will be glad to change test.
>>
>> LS
>
> Attached are patches which fix warning caused by change in structure
> "struct sss_cli_mc_ctx"
>
> src/tests/cmocka/test_mc_client.c:49:41: error: missing initializer for field ‘active_threads’ of ‘struct sss_cli_mc_ctx’ [-Werror=missing-field-initializers]
>                                           0 };
>                                           ^
> In file included from ../sssd/src/tests/cmocka/test_mc_client.c:36:0:
> src/sss_client/nss_mc.h:58:14: note: ‘active_threads’ declared here
>       uint32_t active_threads; /* count of threads which use memory cache */
>                ^
> cc1: all warnings being treated as errors
>

I reintroduced the race condition in mmap cache
and the test failed. With fixed mmap cache the
test passes.

Nitpick:
Please add some comments to the function
test_client_reinit_race_condition. I know this
is just a test, but the code looks a little messy
to me without comments.

Also please remove this comment:
/* Even though normally the tests should clean up after themselves
  * they might not after a failed run. Remove the old db to be sure */

because we do not remove any old db there.

Otherwise it looks good to me.

Michal



More information about the sssd-devel mailing list