xref: /llvm-project/cross-project-tests/debuginfo-tests/dexter/dex/command/commands/DexExpectStepKind.py (revision f98ee40f4b5d7474fc67e82824bf6abbaedb7b1c)
1# DExTer : Debugging Experience Tester
2# ~~~~~~   ~         ~~         ~   ~~
3#
4# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5# See https://llvm.org/LICENSE.txt for license information.
6# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7"""Command for specifying an expected number of steps of a particular kind."""
8
9from dex.command.CommandBase import CommandBase
10from dex.dextIR.StepIR import StepKind
11
12
13class DexExpectStepKind(CommandBase):
14    """Expect to see a particular step `kind` a number of `times` while stepping
15    through the program.
16
17    DexExpectStepKind(kind, times)
18
19    See Commands.md for more info.
20    """
21
22    def __init__(self, *args):
23        if len(args) != 2:
24            raise TypeError("expected two args")
25
26        try:
27            step_kind = StepKind[args[0]]
28        except KeyError:
29            raise TypeError(
30                "expected arg 0 to be one of {}".format(
31                    [kind for kind, _ in StepKind.__members__.items()]
32                )
33            )
34
35        self.name = step_kind
36        self.count = args[1]
37
38        super(DexExpectStepKind, self).__init__()
39
40    @staticmethod
41    def get_name():
42        return __class__.__name__
43
44    def eval(self):
45        # DexExpectStepKind eval() implementation is mixed into
46        # Heuristic.__init__()
47        # [TODO] Fix this ^.
48        pass
49