[Patch][LNT] fix python error in compile.py when runN failed

Duncan P. N. Exon Smith dexonsmith at apple.com
Tue Jun 24 10:02:03 PDT 2014


> On 2014-Jun-24, at 09:34, Steven Wu <stevenwu at apple.com> wrote:
> 
> Sorry I forgot to attach the patch in the previous email. Now attached. 
> <runN_failed.patch>
>> On Jun 23, 2014, at 6:06 PM, Steven Wu <stevenwu at apple.com> wrote:
>> 
>> LNT currently throws python errors when runN failed in compile.py. It throws error messages about it cannot parse stdout, stderr is not empty and runN does not return 0. 
>> Ideally, the check after runN should performed in the opposite order. stdout shouldn’t be parsed if runN does not return 0. Since it is expected that runN can fail during the test, g_log.error should be used to print the error instead of throw python error messages.
>> 
>> Please commit for me after review.
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

I know Chris has some infrastructure for LNT unit tests now, but I'm not
sure how far he's gotten.  Is it possible to add a testcase for this?

> diff --git a/lnt/tests/compile.py b/lnt/tests/compile.py
> index 0e40ffb..e0d0ff9 100644
> --- a/lnt/tests/compile.py
> +++ b/lnt/tests/compile.py
> @@ -62,21 +62,20 @@ def runN(args, N, cwd, preprocess_cmd=None, env=None, sample_mem=False,
>                           env=env,
>                           cwd=cwd)
>      stdout,stderr = p.communicate()
> -    res = p.wait()
> +    res = p.returncode
>  
>      data = None
> -    try:
> -        data = eval(stdout)
> -    except:
> -        error("failed to parse output: %s\n" % stdout)
> -
> -    if not ignore_stderr and stderr.strip():
> -        error("stderr isn't empty: %s\n" % stderr)
> -        data = None
> -
>      if res:
> -        error("res != 0: %s\n" % res)
> -        data = None
> +        g_log.error(stderr)

This seems inconsistent with the other error output.  Why use
'g_log.error' here and 'error' elsewhere?  Also, I think the value of
'res' is valuable -- please include it in the output somehow.

> +    else:
> +        try:
> +            data = eval(stdout)
> +        except:
> +            error("failed to parse output: %s\n" % stdout)
> +
> +        if not ignore_stderr and stderr.strip():
> +            error("stderr isn't empty: %s\n" % stderr)
> +            data = None
>  
>      return data
>  
> 





More information about the llvm-commits mailing list