def test_content_source_without_extension(tmpdir): path1 = str(tmpdir.join('test1')) path2 = str(tmpdir.join('test2')) shutil.copy(TEST_FILE1_PATH, path1) shutil.copy(TEST_FILE2_PATH, path2) gzip1 = specialize(FilesystemFile(path1)) gzip2 = specialize(FilesystemFile(path2)) difference = gzip1.compare(gzip2).details assert difference[1].source1 == 'test1-content' assert difference[1].source2 == 'test2-content'
def test_content_source_without_extension(tmpdir): path1 = str(tmpdir.join("test1")) path2 = str(tmpdir.join("test2")) shutil.copy(TEST_FILE1_PATH, path1) shutil.copy(TEST_FILE2_PATH, path2) bzip1 = specialize(FilesystemFile(path1)) bzip2 = specialize(FilesystemFile(path2)) differences = bzip1.compare(bzip2).details assert differences[0].source1 == "test1-content" assert differences[0].source2 == "test2-content"
def test_content_source_without_extension(tmpdir): path1 = str(tmpdir.join('test1')) path2 = str(tmpdir.join('test2')) shutil.copy(TEST_FILE1_PATH, path1) shutil.copy(TEST_FILE2_PATH, path2) bzip1 = specialize(FilesystemFile(path1)) bzip2 = specialize(FilesystemFile(path2)) differences = bzip1.compare(bzip2).details assert differences[0].source1 == 'test1-content' assert differences[0].source2 == 'test2-content'
def test_dot_dsc_invalid(tmpdir, dot_dsc2): tmpdir.mkdir('a') dot_dsc_path = str(tmpdir.join('a/test_1.dsc')) shutil.copy(TEST_DOT_CHANGES_FILE1_PATH, dot_dsc_path) # we don't copy the referenced .tar.gz identified = specialize(FilesystemFile(dot_dsc_path)) assert not isinstance(identified, DotDscFile)
def test_dot_buildinfo_invalid(tmpdir): tmpdir.mkdir('a') dot_buildinfo_path = str(tmpdir.join('a/test_1.buildinfo')) shutil.copy(TEST_DOT_BUILDINFO_FILE1_PATH, dot_buildinfo_path) # we don't copy the referenced .deb identified = specialize(FilesystemFile(dot_buildinfo_path)) assert not isinstance(identified, DotBuildinfoFile)
def dot_buildinfo2(tmpdir): tmpdir.mkdir('b') dot_buildinfo_path = str(tmpdir.join('b/test_1.buildinfo')) shutil.copy(TEST_DOT_BUILDINFO_FILE2_PATH, dot_buildinfo_path) shutil.copy(TEST_DOT_DSC_FILE2_PATH, str(tmpdir.join('b/test_1.dsc'))) shutil.copy(TEST_DEB_FILE2_PATH, str(tmpdir.join('b/test_1_all.deb'))) return specialize(FilesystemFile(dot_buildinfo_path))
def test_dot_changes_invalid(tmpdir): tmpdir.mkdir('a') dot_changes_path = str(tmpdir.join('a/test_1.changes')) shutil.copy(TEST_DOT_CHANGES_FILE1_PATH, dot_changes_path) # we don't copy the referenced .deb identified = specialize(FilesystemFile(dot_changes_path)) assert not isinstance(identified, DotChangesFile)
def test_difference_between_iso88591_and_unicode_only(iso8859, tmpdir): utf8_path = str(tmpdir.join('utf8')) with open(utf8_path, 'wb') as f: f.write(codecs.open(os.path.join(os.path.dirname(__file__), '../data/text_iso8859'), encoding='iso8859-1').read().encode('utf-8')) utf8 = specialize(FilesystemFile(utf8_path)) difference = iso8859.compare(utf8) assert difference.unified_diff is None assert difference.details[0].source1 == 'encoding'
def rom2(tmpdir): path = str(tmpdir.join('coreboot2.rom')) size = 32768 check_call(['cbfstool', path, 'create', '-m', 'x86', '-s', '%s' % size], shell=False) check_call(['cbfstool', path, 'add', '-f', TEST_FILE2_PATH, '-n', 'text', '-t', 'raw'], shell=False) # Remove the last 4 bytes to exercice the full header search buf = bytearray(size) with open(path, 'rb') as f: f.readinto(buf) with open(path, 'wb') as f: size = struct.unpack_from('!I', buf, offset=len(buf) - 4 - 32 + 8)[0] struct.pack_into('!I', buf, len(buf) - 4 - 32 + 8, size - 4) f.write(buf[:-4]) return specialize(FilesystemFile(path))
def image2(): return specialize(FilesystemFile(TEST_FILE2_PATH))
def mozzip2(): return specialize(FilesystemFile(TEST_MOZZIP2_PATH))
def dot_dsc2(tmpdir): tmpdir.mkdir('b') dot_dsc_path = str(tmpdir.join('b/test_1.dsc')) shutil.copy(TEST_DOT_DSC_FILE2_PATH, dot_dsc_path) shutil.copy(TEST_DEB_SRC2_PATH, str(tmpdir.join('b/test_1.tar.gz'))) return specialize(FilesystemFile(dot_dsc_path))
def test_identification_of_md5sums_outside_deb(tmpdir): path = str(tmpdir.join('md5sums')) open(path, 'w') f = specialize(FilesystemFile(path)) assert type(f) is FilesystemFile
def dbgsym_dir2(): container = FilesystemDirectory(os.path.dirname(TEST_DBGSYM_DEB2_PATH)).as_container return specialize(FilesystemFile(TEST_DBGSYM_DEB2_PATH, container=container))
def mo_iso8859_1(): return specialize( FilesystemFile( os.path.join(os.path.dirname(__file__), '../data/test_iso8859-1.mo')))
def unicode2(): return specialize(FilesystemFile(os.path.join(os.path.dirname(__file__), '../data/text_unicode2')))
def ascii2(): return specialize(FilesystemFile(os.path.join(os.path.dirname(__file__), '../data/text_ascii2')))
def rom1(tmpdir): path = str(tmpdir.join('coreboot1')) check_call(['cbfstool', path, 'create', '-m', 'x86', '-s', '32768'], shell=False) check_call(['cbfstool', path, 'add', '-f', TEST_FILE1_PATH, '-n', 'text', '-t', 'raw'], shell=False) return specialize(FilesystemFile(path))
def no_permissions_tar(): return specialize(FilesystemFile(os.path.join(os.path.dirname(__file__), '../data/no-perms.tar')))
def lib2(): return specialize(FilesystemFile(TEST_LIB2_PATH))
def dbgsym_dir2(): container = FilesystemDirectory( os.path.dirname(TEST_DBGSYM_DEB2_PATH)).as_container return specialize( FilesystemFile(TEST_DBGSYM_DEB2_PATH, container=container))
def bzip2(): return specialize(FilesystemFile(TEST_FILE2_PATH))
def iso8859(): return specialize(FilesystemFile(os.path.join(os.path.dirname(__file__), '../data/text_iso8859')))
def fuzzy_tar_in_tar2(): return specialize(FilesystemFile(os.path.join(os.path.dirname(__file__), '../data/fuzzy-tar-in-tar2.tar')))
def binary2(): return specialize(FilesystemFile(TEST_FILE2_PATH))
def mo_iso8859_1(): return specialize(FilesystemFile(os.path.join(os.path.dirname(__file__), '../data/test_iso8859-1.mo')))
def dot_dsc1(tmpdir): tmpdir.mkdir("a") dot_dsc_path = str(tmpdir.join("a/test_1.dsc")) shutil.copy(TEST_DOT_DSC_FILE1_PATH, dot_dsc_path) shutil.copy(TEST_DEB_SRC1_PATH, str(tmpdir.join("a/test_1.tar.gz"))) return specialize(FilesystemFile(dot_dsc_path))
def dot_changes1(tmpdir): tmpdir.mkdir("a") dot_changes_path = str(tmpdir.join("a/test_1.changes")) shutil.copy(TEST_DOT_CHANGES_FILE1_PATH, dot_changes_path) shutil.copy(TEST_DEB_FILE1_PATH, str(tmpdir.join("a/test_1_all.deb"))) return specialize(FilesystemFile(dot_changes_path))
def squashfs2(): return specialize(FilesystemFile(TEST_FILE2_PATH))
def binary1(): return specialize(FilesystemFile(TEST_FILE1_PATH))
def sqlite3db2(): return specialize(FilesystemFile(TEST_FILE2_PATH))
def tar1(): return specialize(FilesystemFile(TEST_FILE1_PATH))
def obj2(): return specialize(FilesystemFile(TEST_OBJ2_PATH))
def iso1(): return specialize(FilesystemFile(TEST_FILE1_PATH))
def fuzzy_tar3(): return specialize( FilesystemFile( os.path.join(os.path.dirname(__file__), '../data/fuzzy3.tar')))
def no_permissions_tar(): return specialize( FilesystemFile( os.path.join(os.path.dirname(__file__), '../data/no-perms.tar')))
def file2(): return specialize(FilesystemFile(TEST_FILE2_PATH))
def class2(): return specialize(FilesystemFile(TEST_FILE2_PATH))
def mo_no_charset(): return specialize( FilesystemFile( os.path.join(os.path.dirname(__file__), '../data/test_no_charset.mo')))
def fuzzy_tar_in_tar2(): return specialize( FilesystemFile( os.path.join(os.path.dirname(__file__), '../data/fuzzy-tar-in-tar2.tar')))
def dot_changes2(tmpdir): tmpdir.mkdir('b') dot_changes_path = str(tmpdir.join('b/test_1.changes')) shutil.copy(TEST_DOT_CHANGES_FILE2_PATH, dot_changes_path) shutil.copy(TEST_DEB_FILE2_PATH, str(tmpdir.join('b/test_1_all.deb'))) return specialize(FilesystemFile(dot_changes_path))
def fuzzy_tar3(): return specialize(FilesystemFile(os.path.join(os.path.dirname(__file__), '../data/fuzzy3.tar')))
def mo_no_charset(): return specialize(FilesystemFile(os.path.join(os.path.dirname(__file__), '../data/test_no_charset.mo')))