1"""
2Make sure the !N and !-N commands work properly.
3"""
4
5
6
7import lldb
8import lldbsuite.test.lldbutil as lldbutil
9from lldbsuite.test.lldbtest import *
10
11
12class TestHistoryRecall(TestBase):
13
14    mydir = TestBase.compute_mydir(__file__)
15
16    # If your test case doesn't stress debug info, the
17    # set this to true.  That way it won't be run once for
18    # each debug info format.
19    NO_DEBUG_INFO_TESTCASE = True
20
21    def test_history_recall(self):
22        """Test the !N and !-N functionality of the command interpreter."""
23        self.sample_test()
24
25    def sample_test(self):
26        interp = self.dbg.GetCommandInterpreter()
27        result = lldb.SBCommandReturnObject()
28        interp.HandleCommand("session history", result, True)
29        interp.HandleCommand("platform list", result, True)
30
31        interp.HandleCommand("!0", result, False)
32        self.assertTrue(result.Succeeded(), "!0 command did not work: %s"%(result.GetError()))
33        self.assertIn("session history", result.GetOutput(), "!0 didn't rerun session history")
34
35        interp.HandleCommand("!-1", result, False)
36        self.assertTrue(result.Succeeded(), "!-1 command did not work: %s"%(result.GetError()))
37        self.assertIn("host:", result.GetOutput(), "!-1 didn't rerun platform list.")
38