Beispiel #1
0
def test_can_be_instantiated_with_a_block(_):
    arch = ArchX86()
    block = Block(0x42, byte_string=b'', arch=arch)
    subject = Subject(block, None)

    nose.tools.assert_equals(subject.content, block)
    nose.tools.assert_equals(subject.type, SubjectType.Block)
Beispiel #2
0
def test_func_graph_attribute_should_raise_error_when_subject_is_a_block():
    arch = ArchX86()
    block = Block(0x42, byte_string=b'', arch=arch)
    subject = Subject(block, None)

    with nose.tools.assert_raises(TypeError):
        _ = subject.func_graph
Beispiel #3
0
 def test_func_graph_attribute_should_raise_error_when_subject_is_a_block(
         self):
     arch = ArchX86()
     block = Block(0x42, byte_string=b'', arch=arch)
     subject = Subject(block)
     with self.assertRaises(TypeError):
         _ = subject.func_graph
Beispiel #4
0
    def test_can_be_instantiated_with_a_block(self, _):
        arch = ArchX86()
        block = Block(0x42, byte_string=b'', arch=arch)
        subject = Subject(block)

        assert subject.content == block
        assert subject.type == SubjectType.Block
Beispiel #5
0
def test_when_instanciated_with_a_function_need_other_attributes(_, __):
    function = _a_mock_function(0x42, 'function_name')
    func_graph = 'mock_func_graph'
    cc = 'mock_cc'

    subject = Subject(function, None, func_graph, cc)

    nose.tools.assert_equals(subject.func_graph, func_graph)
    nose.tools.assert_equals(subject.cc, cc)
Beispiel #6
0
    def test_when_instanciated_with_a_function_need_other_attributes(
            self, _, __):
        function = _a_mock_function(0x42, 'function_name')
        func_graph = networkx.DiGraph()
        cc = 'mock_cc'

        subject = Subject(function, func_graph, cc)

        assert subject.func_graph == func_graph
        assert subject.cc == cc
Beispiel #7
0
def test_can_be_instantiated_with_an_ailment_block():
    block = ailment.Block(0x42, original_size=4)
    subject = Subject(block, None)

    nose.tools.assert_equals(subject.content, block)
    nose.tools.assert_equals(subject.type, SubjectType.Block)
Beispiel #8
0
def test_can_be_instantiated_with_a_function(_):
    function = _a_mock_function(0x42, 'function_name')
    subject = Subject(function, None)

    nose.tools.assert_equals(subject.content, function)
    nose.tools.assert_equals(subject.type, SubjectType.Function)
Beispiel #9
0
    def test_can_be_instantiated_with_an_ailment_block(self):
        block = ailment.Block(0x42, original_size=4)
        subject = Subject(block)

        assert subject.content == block
        assert subject.type == SubjectType.Block
Beispiel #10
0
    def test_can_be_instantiated_with_a_function(self, _):
        function = _a_mock_function(0x42, 'function_name')
        subject = Subject(function)

        assert subject.content == function
        assert subject.type == SubjectType.Function
Beispiel #11
0
def test_can_be_instantiated_with_a_slice(_):
    cfg_slice_to_sink = CFGSliceToSink(None, {})
    subject = Subject(cfg_slice_to_sink, None)

    nose.tools.assert_equals(subject.content, cfg_slice_to_sink)
    nose.tools.assert_equals(subject.type, SubjectType.CFGSliceToSink)