From: Laurent Vivier <laurent@vivier.eu>
To: maozy <maozhongyi@cmss.chinamobile.com>, qemu-devel@nongnu.org
Cc: tony.nguyen@bt.com, alex.bennee@linaro.org, armbru@redhat.com
Subject: Re: _[PATCH_v2_3/3]_tests/migration:fix_unreachable_path_in_stress_test
Date: Thu, 3 Oct 2019 11:23:33 +0200 [thread overview]
Message-ID: <b39ace2c-5826-69c0-f238-7db82e901c20@vivier.eu> (raw)
In-Reply-To: <0cac9381-6bc4-9431-5cdb-c2353857d476@cmss.chinamobile.com>
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: armbru@redhat.com
>>> Cc: laurent@vivier.eu
>>> Cc: tony.nguyen@bt.com
>>>
>>> Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
>>> ---
>>> 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
next prev parent reply other threads:[~2019-10-03 9:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-11 3:31 [Qemu-devel] [PATCH v2 0/3] some fix in tests/migration Mao Zhongyi
2019-09-11 3:31 ` [Qemu-devel] [PATCH v2 1/3] tests/migration: mem leak fix Mao Zhongyi
2019-09-11 8:21 ` Alex Bennée
2019-10-01 15:31 ` Laurent Vivier
2019-10-03 5:34 ` maozy
2019-09-11 3:31 ` [Qemu-devel] [PATCH v2 2/3] tests/migration: fix a typo in comment Mao Zhongyi
2019-10-01 15:31 ` Laurent Vivier
2019-10-04 14:23 ` [Qemu-devel] " Philippe Mathieu-Daudé
2019-09-11 3:31 ` [Qemu-devel] [PATCH v2 3/3] tests/migration:fix unreachable path in stress test Mao Zhongyi
2019-10-01 15:22 ` maozy
2019-10-01 15:46 ` Laurent Vivier
2019-10-03 7:17 ` _[PATCH_v2_3/3]_tests/migration:fix_unreachable_path_in_stress_test maozy
2019-10-03 9:23 ` Laurent Vivier [this message]
2019-10-04 1:59 ` _[PATCH_v2_3/3]_tests/migration:fix_unreachable_path_in_stress_test maozy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b39ace2c-5826-69c0-f238-7db82e901c20@vivier.eu \
--to=laurent@vivier.eu \
--cc=alex.bennee@linaro.org \
--cc=armbru@redhat.com \
--cc=maozhongyi@cmss.chinamobile.com \
--cc=qemu-devel@nongnu.org \
--cc=tony.nguyen@bt.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).