From 39507ae44ee07eabaee9b0c22c13f245c66d6518 Mon Sep 17 00:00:00 2001 From: Alan Stokes Date: Fri, 31 May 2024 12:14:30 +0100 Subject: [PATCH] Improve CIL parsing treble_sepolicy_tests gets very confused by parentheses in comments. Fix the search for the opening parenthesis of a statement to skip comments. And then update a comment that was intended to use parentheses to actually do so. (Without the parser change, this fails horribly.) Test: Build Change-Id: I1e36136e97dd9b8190add29b7f2155a08ea87d80 --- private/compat/202404/202404.cil | 4 ++-- tests/mini_parser.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/private/compat/202404/202404.cil b/private/compat/202404/202404.cil index b93b56a80..869deb668 100644 --- a/private/compat/202404/202404.cil +++ b/private/compat/202404/202404.cil @@ -1,5 +1,5 @@ -;; This type may or may not already exist in vendor policy. Re-define it here - duplicate -;; definitions in CIL will be ignored - so we can reference it in 202404.cil. +;; This type may or may not already exist in vendor policy. Re-define it here (duplicate +;; definitions in CIL will be ignored) - so we can reference it in 202404.cil. (type vendor_hidraw_device) (typeattributeset dev_type (vendor_hidraw_device)) diff --git a/tests/mini_parser.py b/tests/mini_parser.py index 25018a76d..88a1998ac 100644 --- a/tests/mini_parser.py +++ b/tests/mini_parser.py @@ -71,7 +71,13 @@ class MiniCilParser: s = "" c = infile.read(1) # get to first statement - while c and c != "(": + while c: + if c == ';': + # comment, get rid of rest of the line + while c != '\n': + c = infile.read(1) + elif c == '(': + break c = infile.read(1) parens += 1