Beispiel #1
0
    def test_disassemble(self):
        """Test processor.command.disassemble.run()"""
        d, cp = dbg_setup()
        command = Mdis.DisassembleCommand(cp)

        self.setup_io(command)
        command.run(['disassemble'])
        self.assertTrue(len(self.errmsgs) > 0)
        self.assertEqual(len(self.msgs), 0)
        me = self.test_disassemble  # NOQA
        cp.curframe = inspect.currentframe()
        # All of these should work
        for args in (['disassemble'], ['disassemble', 'cp.errmsg'
                                       ], ['disassemble',
                                           'unittest'], ['disassemble', '1'],
                     ['disassemble', '10',
                      '100'], ['disassemble', '@10',
                               '@30'], ['disassemble', '+',
                                        '1'], ['disassemble', '-', '1'],
                     ['disassemble', '+1', '2'], ['disassemble', '-1',
                                                  '2'], ['disassemble', 'me']):
            self.clear_output()
            try:
                command.run(args)
            except NotImplementedError:
                return

            self.assertTrue(
                len(self.msgs) > 0, "msgs for: %s" % ' '.join(args))
            self.assertEqual(
                len(self.errmsgs), 0, "errmsgs for: %s %s" %
                (' '.join(args), "\n".join(self.errmsgs)))
            pass
        return
    def test_disassemble(self):
        """Test processor.command.disassemble.run()"""
        d, cp = dbg_setup()
        command = Mdis.DisassembleCommand(cp)

        self.setup_io(command)
        command.run(['disassemble'])
        self.assertTrue(len(self.errmsgs) > 0)
        self.assertEqual(len(self.msgs), 0)
        me = self.test_disassemble  # NOQA
        cp.curframe = inspect.currentframe()
        # All of these should work
        for args in (['disassemble'],
                     ['disassemble', 'cp.errmsg'],
                     ['disassemble', 'unittest'],
                     ['disassemble', '1'],
                     ['disassemble', '10', '100'],
                     ['disassemble', '+', '1'],
                     ['disassemble', '-', '1'],
                     ['disassemble', '+1', '2'],
                     ['disassemble', '-1', '2'],
                     ['disassemble', 'me']):
            self.clear_output()
            command.run(args)
            self.assertTrue(len(self.msgs) > 0,
                            "msgs for: %s" % ' '.join(args))
            self.assertEqual(len(self.errmsgs), 0,
                             "errmsgs for: %s %s" % (' '.join(args),
                                                     "\n".join(self.errmsgs)))
            pass
        return
Beispiel #3
0
 def test_run(self):
     """Test processor.command.run.RunCommand.run()"""
     print("reinstate test_run")
     return
     d, cp = dbg_setup()
     command = Mrun.RunCommand(cp)
     self.assertRaises(Mexcept.DebuggerRestart, command.run, ['run'])
     return
Beispiel #4
0
 def test_run(self):
     """Test processor.command.run.RunCommand.run()"""
     print("reinstate test_run")
     return
     d, cp = dbg_setup()
     command = Mrun.RunCommand(cp)
     self.assertRaises(Mexcept.DebuggerRestart, command.run, ['run'])
     return
Beispiel #5
0
 def test_quit(self):
     """Test processor.command.quit.QuitCommand.run()"""
     d, cp = dbg_setup()
     command = Mquit.QuitCommand(cp)
     try:
         command.run(['quit'])
     except:
         self.assertTrue(True)
     else:
         self.assertTrue(False)
     return
Beispiel #6
0
 def test_quit(self):
     """Test processor.command.quit.QuitCommand.run()"""
     d, cp = dbg_setup()
     command = Mquit.QuitCommand(cp)
     try:
         command.run(['quit'])
     except:
         self.assertTrue(True)
     else:
         self.assertTrue(False)
     return
Beispiel #7
0
 def test_finish(self):
     """Test processor.command.finish.FinishCommand.run()"""
     d, cp = dbg_setup()
     command = Mfinish.FinishCommand(cp)
     for c in ((['finish', '5'], True,),
               (['finish', '0*5+1'], True)):
         command.continue_running = False
         command.proc.stack = [(sys._getframe(0), 14,)]
         result = command.run(c[0])
         self.assertEqual(c[1], result)
         pass
     return
Beispiel #8
0
 def test_kill(self):
     """Test processor.command.kill.KillCommand.run()"""
     signal.signal(28, self.handle)
     d, cp = dbg_setup()
     command = Mkill.KillCommand(cp)
     result = command.run(['kill', 'wrong', 'number', 'of', 'args'])
     self.assertFalse(result)
     self.assertFalse(self.signal_caught)
     result = command.run(['kill', '28'])
     self.assertFalse(result)
     self.assertTrue(self.signal_caught)
     return
Beispiel #9
0
 def test_kill(self):
     """Test processor.command.kill.KillCommand.run()"""
     signal.signal(28, self.handle)
     d, cp = dbg_setup()
     command = Mkill.KillCommand(cp)
     result = command.run(['kill', 'wrong', 'number', 'of', 'args'])
     self.assertFalse(result)
     self.assertFalse(self.signal_caught)
     result = command.run(['kill', '28'])
     self.assertFalse(result)
     self.assertTrue(self.signal_caught)
     return
Beispiel #10
0
 def test_finish(self):
     """Test processor.command.finish.FinishCommand.run()"""
     d, cp = dbg_setup()
     command = Mfinish.FinishCommand(cp)
     for c in ((['finish', '5'], True,),
               (['finish', '0*5+1'], True)):
         command.continue_running = False
         command.proc.stack = [(sys._getframe(0), 14,)]
         result = command.run(c[0])
         self.assertEqual(c[1], result)
         pass
     return
Beispiel #11
0
 def test_confirm(self):
     """Test interface.user.UserInterface.confirm()"""
     d, cp = dbg_setup()
     u = Muser.UserInterface()
     for s in ['y', 'Y', 'Yes', '  YES  ']:
         u.input.readline = lambda prompt=None: self.readline(s)
         self.assertTrue(u.confirm('Testing', True))
         pass
     for s in ['n', 'N', 'No', '  NO  ']:
         u.input.readline = lambda prompt=None: self.readline(s)
         self.assertFalse(u.confirm('Testing', True))
         pass
     # FIXME: Add checking default values. Checking looping
     # values
     return
Beispiel #12
0
 def test_confirm(self):
     """Test interface.user.UserInterface.confirm()"""
     d, cp = dbg_setup()
     u = Muser.UserInterface()
     for s in ['y', 'Y', 'Yes', '  YES  ']:
         u.input.readline = lambda prompt=None: self.readline(s)
         self.assertTrue(u.confirm('Testing', True))
         pass
     for s in ['n', 'N', 'No', '  NO  ']:
         u.input.readline = lambda prompt=None: self.readline(s)
         self.assertFalse(u.confirm('Testing', True))
         pass
     # FIXME: Add checking default values. Checking looping
     # values
     return
Beispiel #13
0
 def test_step(self):
     """Test processor.command.step.StepCommand.run()"""
     d, cp = dbg_setup()
     command = Mstep.StepCommand(cp)
     result = command.run(['step', 'wrong', 'number', 'of', 'args'])
     self.assertFalse(result)
     result = command.run(['step', '5'])
     self.assertTrue(result)
     self.assertEqual(4, cp.debugger.core.step_ignore)
     result = command.run(['step'])
     self.assertTrue(result)
     self.assertEqual(0, cp.debugger.core.step_ignore)
     result = command.run(['step', '1+(2*3)'])
     self.assertTrue(result)
     self.assertEqual(6, cp.debugger.core.step_ignore)
     return
    def test_info_file(self):
        d = Mdebugger.Debugger()
        d, cp = dbg_setup(d)
        command = Minfo.InfoCommand(cp, 'info')

        sub = MinfoFile.InfoFiles(command)
        self.setup_io(sub)
        sub.run([])
        self.assertEqual([], self.msgs)
        cp.curframe = inspect.currentframe()
        for width in (80, 200):
            # sub.settings['width'] = width
            sub.run(['test-info-file.py', 'lines'])
            sub.run([])
            pass
        pass
Beispiel #15
0
    def test_info_file(self):
        d = Mdebugger.Trepan()
        d, cp = dbg_setup(d)
        command = Minfo.InfoCommand(cp, 'info')

        sub = MinfoFile.InfoFiles(command)
        self.setup_io(sub)
        sub.run([])
        self.assertEqual([], self.msgs)
        cp.curframe = inspect.currentframe()
        for width in (80, 200):
            # sub.settings['width'] = width
            sub.run(['test-info-file.py', 'lines'])
            sub.run([])
            pass
        pass
Beispiel #16
0
 def test_step(self):
     """Test processor.command.step.StepCommand.run()"""
     d, cp = dbg_setup()
     command = Mstep.StepCommand(cp)
     result = command.run(['step', 'wrong', 'number', 'of', 'args'])
     self.assertFalse(result)
     result = command.run(['step', '5'])
     self.assertTrue(result)
     self.assertEqual(4, cp.debugger.core.step_ignore)
     result = command.run(['step'])
     self.assertTrue(result)
     self.assertEqual(0, cp.debugger.core.step_ignore)
     result = command.run(['step', '1+(2*3)'])
     self.assertTrue(result)
     self.assertEqual(6, cp.debugger.core.step_ignore)
     return
Beispiel #17
0
    def test_disassemble(self):
        """Test processor.command.disassemble.run()"""

        print("Skipping until disassembly revamp complete")
        assert True
        return
        d, cp = dbg_setup()
        command = Mdis.DisassembleCommand(cp)

        self.setup_io(command)
        command.run(['disassemble'])
        self.assertTrue(len(self.errmsgs) > 0)
        self.assertEqual(len(self.msgs), 0)
        me = self.test_disassemble  # NOQA
        cp.curframe = inspect.currentframe()
        proc = command.proc
        # All of these should work
        for args in (['disassemble'], ['disassemble', 'cp.errmsg'],
                     ['disassemble',
                      'unittest'], ['disassemble',
                                    '1'], ['disassemble', '10', '100'],
                     ['disassemble', '*10',
                      '*30'], ['disassemble', '+',
                               '1'], ['disassemble', '-',
                                      '1'], ['disassemble', '1',
                                             '2'], ['disassemble', 'me']):
            self.clear_output()
            proc.current_command = ' '.join(args)
            command.run(args)
            self.assertTrue(
                len(self.msgs) > 0, "msgs for: %s" % ' '.join(args))
            self.assertEqual(
                len(self.errmsgs), 0, "errmsgs for: %s %s" %
                (' '.join(args), "\n".join(self.errmsgs)))
            pass
        return
Beispiel #18
0
 def setUp(self):
     self.d, self.cp = dbg_setup()
 def setUp(self):
     self.d, self.cp = dbg_setup()