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

Re: [PATCH 2/2] xen/misra: diff-report.py: add report patching feature


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Wed, 17 May 2023 10:31:30 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6znffPVqR9NmWxnKAD9FJRV42x1Y5ng492Dynk2du0c=; b=PiuzufHlJWddZNVn3Yy4h26PKwbWKeczJ/C8KzosYl6KHYYtHntdr1DUkFWGyuYvVaYdGicQyC7g+mHymNUeNpvQmk/YHK4RlLnUZvlDtiB/T5AIf3ktqX8KASbcKhEe3+H2P3KqbXOmupAKjotT4e9oqQbJhDKymrDZIo+aadUpIpD+B53fBjjbsUCr10d3O8l75G58ncBcEVHyQQqOVI5pIlum8AvXhPtU1V5Sg/UUBlwN/uW2DRRZJXBg2+m7x6PNoo9kXujNz6BYFxLEJ+B2YTEFkZ2ubDEtW9bUaukPFPqhQVYaJrNTpkiAMA3CKjjwoGNmUuG9H6DQ8PIX/A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SNxAsaEWRC4wo1eMRxDD+relLPzJhKLn2f5TF5RAsNzT56NFvkVSR3IV0pRepDJFb7zrul14vVQV+lTK5aVEnW6qdHhB+yI9jtbqD4gKJIpatOZRnjqDUap7V/G9avmohPxz+n0ULuQIREhzU/xqC4aXUwnG+3avbjLSVqsfEU0f09Uh/Ek0JXfIRLHGZ3ZeEYzjcDXjMxDOc+ojDCbCR68P55yaapqOk0VZpFDuL5XCeajt8/sH5cG+OnQ1hcNhsVs1kACauNNKNGM5Bu3dVByWavtAUBgKU7gLMr9qeS2nS0POOVoKlVl56aVqiv+TKreu15gQ0r6mJFTuFUgpyw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Wed, 17 May 2023 10:31:54 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHZfpRdAeUKdaL5DEawBEGR+YhUoK9dwh0AgACWKYA=
  • Thread-topic: [PATCH 2/2] xen/misra: diff-report.py: add report patching feature


> On 17 May 2023, at 02:33, Stefano Stabellini <sstabellini@xxxxxxxxxx> wrote:
> 
> On Thu, 4 May 2023, Luca Fancellu wrote:
>> Add a feature to the diff-report.py script that improves the comparison
>> between two analysis report, one from a baseline codebase and the other
>> from the changes applied to the baseline.
>> 
>> The comparison between reports of different codebase is an issue because
>> entries in the baseline could have been moved in position due to addition
>> or deletion of unrelated lines or can disappear because of deletion of
>> the interested line, making the comparison between two revisions of the
>> code harder.
>> 
>> Having a baseline report, a report of the codebase with the changes
>> called "new report" and a git diff format file that describes the
>> changes happened to the code from the baseline, this feature can
>> understand which entries from the baseline report are deleted or shifted
>> in position due to changes to unrelated lines and can modify them as
>> they will appear in the "new report".
>> 
>> Having the "patched baseline" and the "new report", now it's simple
>> to make the diff between them and print only the entry that are new.
>> 
>> Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
> 
> This is an amazing work!! Thanks Luca!
> 
> I am having issues trying the new patch feature. After applying this
> patch I get:
> 
> sstabellini@ubuntu-linux-20-04-desktop:/local/repos/xen-upstream/xen$ 
> ./scripts/diff-report.py
> Traceback (most recent call last):
>  File "./scripts/diff-report.py", line 5, in <module>
>    from xen_analysis.diff_tool.debug import Debug
>  File 
> "/local/repos/xen-upstream/xen/scripts/xen_analysis/diff_tool/debug.py", line 
> 4, in <module>
>    from .report import Report
>  File 
> "/local/repos/xen-upstream/xen/scripts/xen_analysis/diff_tool/report.py", 
> line 4, in <module>
>    from .unified_format_parser import UnifiedFormatParser, ChangeSet
>  File 
> "/local/repos/xen-upstream/xen/scripts/xen_analysis/diff_tool/unified_format_parser.py",
>  line 56, in <module>
>    class UnifiedFormatParser:
>  File 
> "/local/repos/xen-upstream/xen/scripts/xen_analysis/diff_tool/unified_format_parser.py",
>  line 57, in UnifiedFormatParser
>    def __init__(self, args: str | list) -> None:
> TypeError: unsupported operand type(s) for |: 'type' and 'type'
> 
> Also got a similar error elsewhere:
> 
> sstabellini@ubuntu-linux-20-04-desktop:/local/repos/xen-upstream/xen$ 
> ./scripts/diff-report.py --patch ~/p/1 -b /tmp/1 -r /tmp/1
> Traceback (most recent call last):
>  File "./scripts/diff-report.py", line 127, in <module>
>    main(sys.argv[1:])
>  File "./scripts/diff-report.py", line 102, in main
>    diffs = UnifiedFormatParser(diff_source)
>  File 
> "/local/repos/xen-upstream/xen/scripts/xen_analysis/diff_tool/unified_format_parser.py",
>  line 79, in __init__
>    self.__parse()
>  File 
> "/local/repos/xen-upstream/xen/scripts/xen_analysis/diff_tool/unified_format_parser.py",
>  line 94, in __parse
>    def parse_diff_header(line: str) -> ChangeSet | None:
> TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
> 
> My Python is 2.7.18
> 
> 
> Am I understanding correctly that one should run the scan for the
> baseline (saving the result somewhere), then apply the patch, run the
> scan again. Finally, one should call diff-report.py passing -b
> baseline-report -r new-report --patch the-patch-applied?

Hi Stefano,

Yes indeed, that procedure is correct, I think the error you are seeing comes 
from the python version,
I am using python 3, version 3.10.6.

The error seems to come from python annotations, I’m surprised you didn’t hit 
it when testing the first patch,
did you use python2 for that?

Is it a problem if I developed the tool having in mind its usage with python3?

Cheers,
Luca


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.