Skip to content

Commit

Permalink
pmreorder: pass markers to checker
Browse files Browse the repository at this point in the history
  • Loading branch information
igchor authored and nofuturre committed Jul 22, 2022
1 parent 1951226 commit abdf24f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/tools/pmreorder/opscontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,26 @@ def extract_operations(self):
:return: list of subclasses of :class:`memoryoperations.BaseOperation`
"""
enumerated_ops = list(enumerate(self._operations))
markers = list(filter(lambda e: e[1].endswith(".BEGIN")
or e[1].endswith(".END"), enumerated_ops))
operation_ids = list(enumerated_ops)

stop_index = start_index = 0

for i, elem in enumerate(self._operations):
for i, elem in enumerated_ops:
if "START" in elem:
start_index = i
elif "STOP" in elem:
stop_index = i

return list(
operations = list(
map(
OperationFactory.create_operation,
self._operations[start_index + 1: stop_index],
repeat(self.markers),
repeat(self.stack_engines),
)
)

return (operations, operation_ids, markers)
3 changes: 2 additions & 1 deletion src/tools/pmreorder/pmreorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def main():

# init and run the state machine
a = statemachine.StateMachine(statemachine.InitState(context))
if a.run_all(context.extract_operations()) is False:
operations, operation_ids, markers = context.extract_operations()
if a.run_all(operations, operation_ids, markers) is False:
sys.exit(1)


Expand Down
9 changes: 7 additions & 2 deletions src/tools/pmreorder/statemachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import reorderengines
from reorderexceptions import InconsistentFileException
from reorderexceptions import NotSupportedOperationException
import os


class State:
Expand Down Expand Up @@ -371,7 +372,7 @@ def __init__(self, init_state):
"""
self._curr_state = init_state

def run_all(self, operations):
def run_all(self, operations, operation_ids, markers):
"""
Starts the state machine.
Expand All @@ -381,8 +382,12 @@ def run_all(self, operations):
:return: None
"""
all_consistent = True
for ops in operations:
for ops, ops_id in zip(operations, operation_ids):
self._curr_state._context.logger.info(ops)
markers_to_pass = filter(lambda e: e[0] < ops_id[0], markers)
markers_to_pass = map(lambda e: e[1], markers_to_pass)
markers_to_pass = "|".join(list(markers_to_pass))
os.environ["PMREORDER_MARKERS"] = markers_to_pass
self._curr_state = self._curr_state.next(ops)
check = self._curr_state.run(ops)
if check is False:
Expand Down

0 comments on commit abdf24f

Please sign in to comment.