Skip to content

Commit

Permalink
(litmus/linter) modifications to lint for toml-translator format
Browse files Browse the repository at this point in the history
  • Loading branch information
bensimner committed May 19, 2024
1 parent 5985d74 commit 46f1d02
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions litmus/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
r"litmus_test_t\s+(?P<cname>.+?)\s*=\s*\{"
r"\s*\"(?P<human_name>.+?)\"\s*,"
r'\s*MAKE_THREADS\((?P<no_threads>\d+)\)\s*?,'
r'\s*MAKE_VARS\(VARS\)\s*?,'
r'\s*MAKE_VARS\(VARS(\s*,\s*pa\d+)*\)\s*?,'
r'\s*MAKE_REGS\(REGS\)\s*?,'
r'(?P<fields>[\s\S]*?)'
r'\s*\}\s*;'
Expand Down Expand Up @@ -58,7 +58,7 @@
C_FUN_PAT = (
r"void (?P<fname>.+)\(.+\)\s*\{"
r"(?P<body>[\s\S]*?)"
r"\s*\}"
r"^}"
)

C_INIT_ST = (
Expand All @@ -73,7 +73,7 @@
def get_reg_names(asm):
if not asm:
return []
return ['x{}'.format(i) for i in re.findall(r'(?<=(?<!\%\[)[xw])\d+', asm['code'])]
return ['x{}'.format(i) for i in re.findall(r'(?<=(?<!.0|\%\[)[xwXW])\d+', asm['code'])]

def parse_litmus_code(path, c_code):
match = re.search(LITMUS_TEST_T_PAT_NEW, c_code, re.MULTILINE)
Expand Down Expand Up @@ -155,7 +155,13 @@ def check_uniq_names(litmuses):

def check_human_match_path(l):
p = pathlib.Path(l['path']).stem
if l['human_name'] != str(p):

# for toml-translator generated names, strip the .toml.c
if p.endswith(".litmus.toml"):
p = p[:-len(".litmus.toml")]
pass

if l['human_name'] != p:
warn(l, "File name and Litmus name mismatch.")


Expand Down

0 comments on commit 46f1d02

Please sign in to comment.