[Tarantool-patches] [PATCHv2 1/2] core: add setting error injections via env
Artem
artemreyt at tarantool.org
Wed Feb 24 12:38:43 MSK 2021
Hi,
20.02.2021 17:27, Sergey Bronnikov пишет:
> Hi,
>
> On 20.02.2021 14:21, Artem wrote:
>> Hello,
>>
>> thanks for the review!
>>
>>>> +
>>>> +void errinj_set_with_environment_vars() {
>>>> + for (enum errinj_id i = 0; i < errinj_id_MAX; i++) {
>>>> + struct errinj *inj = &errinjs[i];
>>>> + const char *env_value = getenv(inj->name);
>>>> + if (!env_value || *env_value == '\0')
>>>> + continue;
>>>> +
>>>> + if (inj->type == ERRINJ_INT) {
>>>> + char *end;
>>>> + int64_t int_value = strtoll(env_value, &end, 10);
>>>> + if (*end == '\0')
>>>> + inj->iparam = int_value;
>>>> + } else if (inj->type == ERRINJ_BOOL) {
>>>> + if (strcmp(env_value, "false") == 0 ||
>>>> strcmp(env_value, "FALSE") == 0)
>>>
>>> 1. What happen if someone set boolean value to "False"?
>>>
>>> May be it's worth to convert env_value to lowercase and then
>>> compare? The same question for "true".
>>
>> 1. Done. Case-insensetive value can be set to env variable now.
>
> Thanks!
>
> It's worth to add different values for 'true'/'false' to test
>
> for documentation and regression purposes.
Done, added tests for "true", "True", "TRUE" (same for false) and tests
for numeric injections with plus and minus signs.
Updates you can see on the branch.
More information about the Tarantool-patches
mailing list