def test_file_strings_is_good(self):
        expected = [
            u'__text',
            u'__TEXT',
            u'__cstring',
            u'__TEXT',
            u'__jump_table',
            u'__IMPORT',
            u'__textcoal_nt',
            u'__TEXT',
            u'_main',
            u'___i686.get_pc_thunk.bx',
            u'_setlocale',
            u'_yyparse',
            u'/sw/src/fink.build/bison-2.3-1002/bison-2.3/lib/',
            u'main.c',
            u'gcc2_compiled.',
            u':t(0,1)=(0,1)',
            u'main:F(0,2)',
            u'int:t(0,2)=r(0,2);-2147483648;2147483647;'
        ]

        test_file = self.get_test_loc('strings/basic/main.o')
        result = list(strings.strings_from_file(test_file))
        assert expected == result
    def test_file_strings_is_good(self):
        expected = [
            u'__text',
            u'__TEXT',
            u'__cstring',
            u'__TEXT',
            u'__jump_table',
            u'__IMPORT',
            u'__textcoal_nt',
            u'__TEXT',
            u'_main',
            u'___i686.get_pc_thunk.bx',
            u'_setlocale',
            u'_yyparse',
            u'/sw/src/fink.build/bison-2.3-1002/bison-2.3/lib/',
            u'main.c',
            u'gcc2_compiled.',
            u':t(0,1)=(0,1)',
            u'main:F(0,2)',
            u'int:t(0,2)=r(0,2);-2147483648;2147483647;'
        ]

        test_file = self.get_test_loc('strings/basic/main.o')
        result = list(strings.strings_from_file(test_file))
        assert result == expected
示例#3
0
def unicode_text_lines_from_binary(location):
    """
    Return an iterable over unicode text lines extracted from a binary file at
    location.
    """
    T = typecode.get_type(location)
    if T.contains_text:
        for line in strings.strings_from_file(location):
            yield line
示例#4
0
def unicode_text_lines_from_binary(location):
    """
    Return an iterable over unicode text lines extracted from a binary file at
    location.
    """
    T = typecode.get_type(location)
    if T.contains_text:
        for line in strings.strings_from_file(location):
            yield line
 def check_file_strings(self, test_file, expected_file, regen=False):
     test_file = self.get_test_loc(test_file)
     result = u'\n'.join(strings.strings_from_file(test_file))
     expected = self.get_test_loc(expected_file)
     if regen:
         with open(expected, 'wb') as o:
             o.write(result)
     expected = open(expected, 'rb').read()
     assert expected == result
     return result
示例#6
0
 def check_file_strings(self, test_file, expected_file, regen=False):
     test_file = self.get_test_loc(test_file)
     result = u'\n'.join(strings.strings_from_file(test_file))
     expected = self.get_test_loc(expected_file)
     if regen:
         with open(expected, 'wb') as o:
             o.write(result)
     expected = open(expected, 'rb').read()
     assert expected == result
     return result
    def check_file_strings(self, test_file, expected_file, regen=False):
        test_file = self.get_test_loc(test_file)
        results = list(strings.strings_from_file(test_file))
        expected = self.get_test_loc(expected_file)
        if regen:
            with io.open(expected, 'w') as o:
                o.write(json.dumps(results, indent=2))

        with io.open(expected) as i:
            expected = json.loads(i.read())
        assert results == expected
        return results
 def test_strings_in_file_does_fail_if_contains_ERROR_string(self):
     test_file = self.get_test_loc('strings/bin/file_stripped')
     list(strings.strings_from_file(test_file))
 def test_strings_in_file_does_fail_if_contains_ERROR_string(self):
     test_file = self.get_test_loc('strings/bin/file_stripped')
     list(strings.strings_from_file(test_file))