lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 27 Feb 2020 16:09:26 -0800
From:   Heidi Fahim <heidifahim@...gle.com>
To:     Brendan Higgins <brendanhiggins@...gle.com>
Cc:     linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
        kunit-dev@...glegroups.com
Subject: Re: [PATCH 1/2] kunit: kunit_parser: making parser more robust

> >
> > -TAP_ENTRIES = re.compile(r'^(TAP|\t?ok|\t?not ok|\t?[0-9]+\.\.[0-9]+|\t?#).*$')
> > +TAP_ENTRIES = re.compile(r'(TAP|\t?ok|\t?not ok|\t?[0-9]+\.\.[0-9]+|\t# .*?:.*?).*$')
>
> Since you now strip off prefixes using length, does the old TAP regex no
> longer work?
>

Using old regex (i.e. match instead of search) still works - do you
prefer this be reverted where possible or be changed to search? Search
is a little more relaxed when it comes to alignment of the TAP output
(i.e. some lines could have extra leading whitespaces), but right now
is not necessary.

> >  def consume_non_diagnositic(lines: List[str]) -> None:
> > -     while lines and not TAP_ENTRIES.match(lines[0]):
> > +     while lines and not TAP_ENTRIES.search(lines[0]):
> >               lines.pop(0)
> >
> >  def save_non_diagnositic(lines: List[str], test_case: TestCase) -> None:
> > -     while lines and not TAP_ENTRIES.match(lines[0]):
> > +     while lines and not TAP_ENTRIES.search(lines[0]):
> >               test_case.log.append(lines[0])
> >               lines.pop(0)
> >
> >  OkNotOkResult = namedtuple('OkNotOkResult', ['is_ok','description', 'text'])
> >
> > -OK_NOT_OK_SUBTEST = re.compile(r'^\t(ok|not ok) [0-9]+ - (.*)$')
> > +OK_NOT_OK_SUBTEST = re.compile(r'\t(ok|not ok) [0-9]+ - (.*)$')
> >
> > -OK_NOT_OK_MODULE = re.compile(r'^(ok|not ok) [0-9]+ - (.*)$')
> > +OK_NOT_OK_MODULE = re.compile(r'(ok|not ok) [0-9]+ - (.*)$')
>
> Same here.
>
> > -def parse_ok_not_ok_test_case(lines: List[str],
> > -                           test_case: TestCase,
> > -                           expecting_test_case: bool) -> bool:
> > +def parse_ok_not_ok_test_case(lines: List[str], test_case: TestCase) -> bool:
> >       save_non_diagnositic(lines, test_case)
> >       if not lines:
> > -             if expecting_test_case:
> > -                     test_case.status = TestStatus.TEST_CRASHED
> > -                     return True
> > -             else:
> > -                     return False
> > +             test_case.status = TestStatus.TEST_CRASHED
> > +             return True
> >       line = lines[0]
> >       match = OK_NOT_OK_SUBTEST.match(line)
> > +     while not match and lines:
> > +             line = lines.pop(0)
> > +             match = OK_NOT_OK_SUBTEST.match(line)
> >       if match:
> >               test_case.log.append(lines.pop(0))
> >               test_case.name = match.group(2)
> > @@ -150,12 +150,12 @@ def parse_diagnostic(lines: List[str], test_case: TestCase) -> bool:
> >       else:
> >               return False
> >
> > -def parse_test_case(lines: List[str], expecting_test_case: bool) -> TestCase:
> > +def parse_test_case(lines: List[str]) -> TestCase:
> >       test_case = TestCase()
> >       save_non_diagnositic(lines, test_case)
> >       while parse_diagnostic(lines, test_case):
> >               pass
> > -     if parse_ok_not_ok_test_case(lines, test_case, expecting_test_case):
> > +     if parse_ok_not_ok_test_case(lines, test_case):
> >               return test_case
> >       else:
> >               return None
> > @@ -202,7 +202,7 @@ def parse_ok_not_ok_test_suite(lines: List[str], test_suite: TestSuite) -> bool:
> >               test_suite.status = TestStatus.TEST_CRASHED
> >               return False
> >       line = lines[0]
> > -     match = OK_NOT_OK_MODULE.match(line)
> > +     match = OK_NOT_OK_MODULE.search(line)
> >       if match:
> >               lines.pop(0)
> >               if match.group(1) == 'ok':
> > @@ -234,11 +234,11 @@ def parse_test_suite(lines: List[str]) -> TestSuite:
> >       expected_test_case_num = parse_subtest_plan(lines)
> >       if not expected_test_case_num:
> >               return None
> > -     test_case = parse_test_case(lines, expected_test_case_num > 0)
> > -     expected_test_case_num -= 1
> > -     while test_case:
> > +     while expected_test_case_num > 0:
> > +             test_case = parse_test_case(lines)
> > +             if not test_case:
> > +                     break
> >               test_suite.cases.append(test_case)
> > -             test_case = parse_test_case(lines, expected_test_case_num > 0)
> >               expected_test_case_num -= 1
>
> Do we use this variable anymore?

Yes, this decides whether we are expecting another test case or if
we've completed the test suite
>
> >       if parse_ok_not_ok_test_suite(lines, test_suite):
> >               test_suite.status = bubble_up_test_case_errors(test_suite)
> > @@ -250,7 +250,7 @@ def parse_test_suite(lines: List[str]) -> TestSuite:
> >               print('failed to parse end of suite' + lines[0])
> >               return None
> >
> > -TAP_HEADER = re.compile(r'^TAP version 14$')
> > +TAP_HEADER = re.compile(r'TAP version 14$')
> >
> >  def parse_tap_header(lines: List[str]) -> bool:
> >       consume_non_diagnositic(lines)
>
> Cheers
>
> --
> You received this message because you are subscribed to the Google Groups "KUnit Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kunit-dev+unsubscribe@...glegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/20200225222221.GA144971%40google.com.

Powered by blists - more mailing lists