qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: _[PATCH_v2_3/3]_tests/migration:fix_unreachable_path_in_stress_test


From: Laurent Vivier
Subject: Re: _[PATCH_v2_3/3]_tests/migration:fix_unreachable_path_in_stress_test
Date: Thu, 3 Oct 2019 11:23:33 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0

Le 03/10/2019 à 09:17, maozy a écrit :
> Hi,  Laurent
> 
> On 10/1/19 11:46 PM, Laurent Vivier wrote:
>> Le 11/09/2019 à 05:31, Mao Zhongyi a écrit :
>>> if stress function always return 0, the path
>>> 'if (stress(ramsizeGB, ncpus) < 0)' is nerver unreachable,
>>> so fix it to allow the test failed.
>>>
>>> Cc: address@hidden
>>> Cc: address@hidden
>>> Cc: address@hidden
>>>
>>> Signed-off-by: Mao Zhongyi <address@hidden>
>>> ---
>>>   tests/migration/stress.c | 5 ++---
>>>   1 file changed, 2 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/tests/migration/stress.c b/tests/migration/stress.c
>>> index 19a6eff5fd..35903d90c4 100644
>>> --- a/tests/migration/stress.c
>>> +++ b/tests/migration/stress.c
>>> @@ -224,6 +224,7 @@ static int stressone(unsigned long long ramsizeMB)
>>>               }
>>>           }
>>>       }
>>> +    return 0;
>>>   }
>> before the return, we have an infinite loop "while(1) { }".
>>
>> So this part is dead code.
>>
>> In fact, if the function exits, it's because it fails, otherwise it
>> loops infinitely, so I think we should change its type to void and
>> stress should always return -1.
> Yes, I think it's ok to change stressone typo to void because
> no one cares about its return value, but if make stress always
> return -1, main will always exited in exit_failure, like this:
> 
> ...
>     if (stress(ramsizeGB, ncpus) < 0)
>         exit_failure();
> 
>     exit_success();
> }
> 
> so, perhaps also change stress typo to void may be good. then:
> 
> ...
>     stress(ramsizeGB, ncpus);
> 
>     exit_success();
> }
> 
> Anther way , make stressone return 0 when infinite loop fails to
> exit, then main can handle both success and failure case.
> 
> what do you think?
> 

If stressone() or stress() exits it's because of a failure because the
test runs forever otherwise.

So I think there is no problem to use exit_failure() as the exit
function of main(): it should never be reached if the test runs without
error.

Thanks,
Laurent



reply via email to

[Prev in Thread] Current Thread [Next in Thread]