Skip to content

Commit

Permalink
[to-delete] add test script for cse
Browse files Browse the repository at this point in the history
  • Loading branch information
Stevengre committed Dec 17, 2024
1 parent e34a2c1 commit 1a46565
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/tests/integration/test-data/show/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#! /usr/bin/env python3

# input: path to a kcfg file
# output: cse steps

import re
import sys

if __name__ == "__main__":
kcfg_path = sys.argv[1]

with open(kcfg_path, "r") as f:
prev_node_id = None
curr_node_id = None
is_calling = False
is_callee = False
counter = 0
for line in f:
# after the ┌─, ├─, └─ is the node id
for match in re.finditer(r"[┌└├]─ (\d+)", line):
prev_node_id = curr_node_id
curr_node_id = match.group(1)
if is_callee:
print(f'{prev_node_id} -> {curr_node_id}')
is_callee = False
counter += 1
# if the line has "k: #execute ~> #return", then it tries to call a function
if "k: #execute ~> #return" in line:
is_calling = True
# if is_calling and the line has "(\d+ step)"
if is_calling and re.search(r"\d+ step", line):
is_calling = False
steps = int(re.search(r"(\d+) step", line).group(1))
if steps == 1:
is_callee = True
print(f"Total CSE Steps: {counter}")

0 comments on commit 1a46565

Please sign in to comment.