Ejemplo n.º 1
0
    def __init__(self):
        iv = InterfaceValidator(self)
        iv.expect_staticmethod("supports_multiple_processes()")
        iv.expect_method("shutdown(self, force=False)")
        iv.expect_get_property(
            "debugger_pid")  # the pid of the gdb/etc process or none
        iv.expect_get_property("status")
        iv.expect_get_property("status_changed")
        iv.expect_get_property("ptys")
        iv.expect_get_property("processes")
        iv.expect_get_property("threads")
        iv.expect_get_property("main_thread")
        iv.expect_get_property("thread_that_stopped")

        iv.expect_method("begin_launch_suspended(self, cmdline)")
        iv.expect_method("begin_attach_to_pid(self, pid, was_launched_hint)")

        iv.expect_method("kill_process(self, proc)")
        iv.expect_method("detach_process(self, proc)")

        iv.expect_method("begin_resume(self, thr)")
        iv.expect_method("begin_interrupt(self)")
        iv.expect_method("begin_step_over(self, thread)")
        iv.expect_method("begin_step_into(self, thread)")
        iv.expect_method("begin_step_out(self, thread)")

        iv.expect_method("new_breakpoint(self, location, hit_cb)")
        iv.expect_method("enable_breakpoint(self, id)")
        iv.expect_method("disable_breakpoint(self, id)")
        iv.expect_method("delete_breakpoint(self, id)")

        iv.expect_method("get_call_stack(self, thr)")
        iv.expect_method("get_frame(self, thr, frame)")

        iv.expect_method("get_expr_value_async(self, thr, expr, cb)")
Ejemplo n.º 2
0
  def __init__(self):
    iv = InterfaceValidator(self);
    iv.expect_staticmethod("supports_multiple_processes()")
    iv.expect_method("shutdown(self, force=False)")
    iv.expect_get_property("debugger_pid") # the pid of the gdb/etc process or none
    iv.expect_get_property("status")
    iv.expect_get_property("status_changed")
    iv.expect_get_property("ptys")
    iv.expect_get_property("processes")
    iv.expect_get_property("threads")
    iv.expect_get_property("main_thread")
    iv.expect_get_property("thread_that_stopped")

    iv.expect_method("begin_launch_suspended(self, cmdline)")
    iv.expect_method("begin_attach_to_pid(self, pid, was_launched_hint)")

    iv.expect_method("kill_process(self, proc)")
    iv.expect_method("detach_process(self, proc)")

    iv.expect_method("begin_resume(self, thr)")
    iv.expect_method("begin_interrupt(self)")
    iv.expect_method("begin_step_over(self, thread)")
    iv.expect_method("begin_step_into(self, thread)")
    iv.expect_method("begin_step_out(self, thread)")

    iv.expect_method("new_breakpoint(self, location, hit_cb)")
    iv.expect_method("enable_breakpoint(self, id)")
    iv.expect_method("disable_breakpoint(self, id)")
    iv.expect_method("delete_breakpoint(self, id)")

    iv.expect_method("get_call_stack(self, thr)")
    iv.expect_method("get_frame(self, thr, frame)")

    iv.expect_method("get_expr_value_async(self, thr, expr, cb)")
Ejemplo n.º 3
0
class InterfaceValidatorArgumentTest(unittest.TestCase):
  def setUp(self):
    self.iv = InterfaceValidator( Example1(1,2), defer_validation=False )
  def tearDown(self):
    pass

  def test_methods_we_have(self):
    self.iv.expect_method("__init__(self, a, b)")
    self.iv.expect_method("m1(self)")
    self.iv.expect_method("m2(self, a)")
    self.iv.expect_method("m3(self, a, b=True)")
    self.iv.expect_method("m4(self, *args)")
    self.iv.expect_method("m5(self, bar, *args, **kwargs)")
    self.iv.expect_method("m6(self, bar, baz=True, *args, **kwargs)")

  def test_missing_methods(self):
    self.assertRaises(ValidationException, lambda: self.iv.expect_method("__len__(self)"))
    self.assertRaises(ValidationException, lambda: self.iv.expect_method("foo()"))

  def test_methods_with_bad_signature(self):
    self.assertRaises(ValidationException, lambda: self.iv.expect_method("__init__(self)"))

    self.assertRaises(ValidationException, lambda: self.iv.expect_method("m3(a, b=True)"))

    self.assertRaises(ValidationException, lambda: self.iv.expect_method("s1()")) # staticmethod
    self.assertRaises(ValidationException, lambda: self.iv.expect_method("s1(a)")) # staticmethod and arg mismatch

  def test_staticmethods_we_have(self):
    self.iv.expect_staticmethod("s1()")

  def test_staticmethods_with_issues(self):
    self.assertRaises(ValidationException, lambda: self.iv.expect_staticmethod("s1(a)"))
    self.assertRaises(ValidationException, lambda: self.iv.expect_staticmethod("get()"))
    self.assertRaises(ValidationException, lambda: self.iv.expect_staticmethod("m3(a, b=True)"))

  def test_properties_we_have(self):
    self.iv.expect_get_property("get")
    self.iv.expect_get_set_property("getset")
    self.iv.expect_get_set_del_property("getsetdel")


  def test_missing_properties(self):
    self.assertRaises(ValidationException, lambda: self.iv.expect_get_property("not_a_property"))

    self.assertRaises(ValidationException, lambda: self.iv.expect_get_set_property("not_a_property"))

    self.assertRaises(ValidationException, lambda: self.iv.expect_get_set_del_property("not_a_property"))

  def test_wrong_properties(self):
    self.assertRaises(ValidationException, lambda: self.iv.expect_get_property("getset"))

    self.assertRaises(ValidationException, lambda: self.iv.expect_get_property("getsetdel"))

    self.assertRaises(ValidationException, lambda: self.iv.expect_get_set_property("get"))

    self.assertRaises(ValidationException, lambda: self.iv.expect_get_set_property("getsetdel"))


    self.assertRaises(ValidationException, lambda: self.iv.expect_get_set_del_property("get"))

    self.assertRaises(ValidationException, lambda: self.iv.expect_get_set_del_property("getset"))
Ejemplo n.º 4
0
class InterfaceValidatorArgumentTest(unittest.TestCase):
    def setUp(self):
        self.iv = InterfaceValidator(Example1(1, 2), defer_validation=False)

    def tearDown(self):
        pass

    def test_methods_we_have(self):
        self.iv.expect_method("__init__(self, a, b)")
        self.iv.expect_method("m1(self)")
        self.iv.expect_method("m2(self, a)")
        self.iv.expect_method("m3(self, a, b=True)")
        self.iv.expect_method("m4(self, *args)")
        self.iv.expect_method("m5(self, bar, *args, **kwargs)")
        self.iv.expect_method("m6(self, bar, baz=True, *args, **kwargs)")

    def test_missing_methods(self):
        self.assertRaises(ValidationException,
                          lambda: self.iv.expect_method("__len__(self)"))
        self.assertRaises(ValidationException,
                          lambda: self.iv.expect_method("foo()"))

    def test_methods_with_bad_signature(self):
        self.assertRaises(ValidationException,
                          lambda: self.iv.expect_method("__init__(self)"))

        self.assertRaises(ValidationException,
                          lambda: self.iv.expect_method("m3(a, b=True)"))

        self.assertRaises(
            ValidationException,
            lambda: self.iv.expect_method("s1()"))  # staticmethod
        self.assertRaises(ValidationException, lambda: self.iv.expect_method(
            "s1(a)"))  # staticmethod and arg mismatch

    def test_staticmethods_we_have(self):
        self.iv.expect_staticmethod("s1()")

    def test_staticmethods_with_issues(self):
        self.assertRaises(ValidationException,
                          lambda: self.iv.expect_staticmethod("s1(a)"))
        self.assertRaises(ValidationException,
                          lambda: self.iv.expect_staticmethod("get()"))
        self.assertRaises(ValidationException,
                          lambda: self.iv.expect_staticmethod("m3(a, b=True)"))

    def test_properties_we_have(self):
        self.iv.expect_get_property("get")
        self.iv.expect_get_set_property("getset")
        self.iv.expect_get_set_del_property("getsetdel")

    def test_missing_properties(self):
        self.assertRaises(
            ValidationException,
            lambda: self.iv.expect_get_property("not_a_property"))

        self.assertRaises(
            ValidationException,
            lambda: self.iv.expect_get_set_property("not_a_property"))

        self.assertRaises(
            ValidationException,
            lambda: self.iv.expect_get_set_del_property("not_a_property"))

    def test_wrong_properties(self):
        self.assertRaises(ValidationException,
                          lambda: self.iv.expect_get_property("getset"))

        self.assertRaises(ValidationException,
                          lambda: self.iv.expect_get_property("getsetdel"))

        self.assertRaises(ValidationException,
                          lambda: self.iv.expect_get_set_property("get"))

        self.assertRaises(ValidationException,
                          lambda: self.iv.expect_get_set_property("getsetdel"))

        self.assertRaises(ValidationException,
                          lambda: self.iv.expect_get_set_del_property("get"))

        self.assertRaises(
            ValidationException,
            lambda: self.iv.expect_get_set_del_property("getset"))