Ejemplo n.º 1
0
def setup():
    # create DB with 3 entries
    shutil.rmtree(db1, True)
    H.hashdb(["create", db1])
    H.rm_tempfile(xml1)
    H.write_temp_dfxml_hash(byte_run_hashdigest="00", byte_run_file_offset=1*4096, repository_name="r1")
    H.hashdb(["import", db1, "temp_dfxml_hash"])
    H.write_temp_dfxml_hash(byte_run_hashdigest="00", byte_run_file_offset=2*4096, repository_name="r1", byte_run_hash_label="H")
    H.hashdb(["import", db1, "temp_dfxml_hash"])
    H.write_temp_dfxml_hash(byte_run_hashdigest="11", byte_run_file_offset=3*4096, byte_run_hash_label="L")
    H.hashdb(["import", db1, "temp_dfxml_hash"])
Ejemplo n.º 2
0
def test_add_repository():
    # hash with correct repository name is added
    shutil.rmtree(db1, True)
    shutil.rmtree(db2, True)
    H.rm_tempfile(xml1)
    H.hashdb(["create", db1])
    H.write_temp_dfxml_hash(repository_name="r1")
    H.hashdb(["import", db1, "temp_dfxml_hash"])
    H.write_temp_dfxml_hash(repository_name="r2")
    H.hashdb(["import", db1, "temp_dfxml_hash"])
    H.hashdb(["add_repository", db1, db2, "r1"])
    sizes = H.parse_sizes(H.hashdb(["size", db2]))
    H.int_equals(sizes['hash_store_size'],1)
    H.int_equals(sizes['source_store_size'],1)
    H.hashdb(["export", db2, xml1])
    H.dfxml_hash_equals(repository_name="r1")
Ejemplo n.º 3
0
def test_subtract():
    # db1 - db2 -> db3 where source must match
    shutil.rmtree(db1, True)
    shutil.rmtree(db2, True)
    shutil.rmtree(db3, True)
    H.rm_tempfile(xml1)
    H.hashdb(["create", db1])
    H.hashdb(["create", db2])
    H.write_temp_dfxml_hash(repository_name="r1")
    H.hashdb(["import", db1, "temp_dfxml_hash"])
    H.hashdb(["import", db2, "temp_dfxml_hash"])
    H.write_temp_dfxml_hash(repository_name="r2")
    H.hashdb(["import", db1, "temp_dfxml_hash"])
    H.hashdb(["subtract", db1, db2, db3])
    sizes = H.parse_sizes(H.hashdb(["size", db3]))
    H.int_equals(sizes['hash_store_size'],1)
    H.hashdb(["export", db3, xml1])
    H.dfxml_hash_equals(repository_name="r2")
Ejemplo n.º 4
0
def test_intersect_hash():
    # db1 with a,b and db2 with b,c intersect to db3 with just b
    # using different hash
    shutil.rmtree(db1, True)
    shutil.rmtree(db2, True)
    shutil.rmtree(db3, True)
    H.rm_tempfile(xml1)
    H.hashdb(["create", db1])
    H.hashdb(["create", db2])
    H.write_temp_dfxml_hash(byte_run_hashdigest="00112233445566778899aabbccddeef1")
    H.hashdb(["import", db1, "temp_dfxml_hash"])
    H.write_temp_dfxml_hash(byte_run_hashdigest="00112233445566778899aabbccddeef2")
    H.hashdb(["import", db1, "temp_dfxml_hash"])
    H.hashdb(["import", db2, "temp_dfxml_hash"])
    H.write_temp_dfxml_hash(byte_run_hashdigest="00112233445566778899aabbccddeef3")
    H.hashdb(["import", db2, "temp_dfxml_hash"])
    H.hashdb(["intersect_hash", db1, db2, db3])
    sizes = H.parse_sizes(H.hashdb(["size", db3]))
    H.int_equals(sizes['hash_store_size'],1)
    H.int_equals(sizes['source_store_size'],1)
    H.hashdb(["export", db3, xml1])
    H.dfxml_hash_equals(byte_run_hashdigest="00112233445566778899aabbccddeef2")
Ejemplo n.º 5
0
def test_intersect():
    # db1 with a,b and db2 with b,c intersect to db3 with just b
    # using same hash and different repository name
    shutil.rmtree(db1, True)
    shutil.rmtree(db2, True)
    shutil.rmtree(db3, True)
    H.rm_tempfile(xml1)
    H.hashdb(["create", db1])
    H.hashdb(["create", db2])
    H.write_temp_dfxml_hash(repository_name="r1")
    H.hashdb(["import", db1, "temp_dfxml_hash"])
    H.write_temp_dfxml_hash(repository_name="r2")
    H.hashdb(["import", db1, "temp_dfxml_hash"])
    H.hashdb(["import", db2, "temp_dfxml_hash"])
    H.write_temp_dfxml_hash(repository_name="r3")
    H.hashdb(["import", db2, "temp_dfxml_hash"])
    H.hashdb(["intersect", db1, db2, db3])
    sizes = H.parse_sizes(H.hashdb(["size", db3]))
    H.int_equals(sizes['hash_store_size'],1)
    H.int_equals(sizes['source_store_size'],1)
    H.hashdb(["export", db3, xml1])
    H.dfxml_hash_equals(repository_name="r2")
Ejemplo n.º 6
0
def setup():
    # create DFXML with hash values 00, 11, 22
    shutil.rmtree(db1, True)
    H.hashdb(["create", db1])
    H.rm_tempfile(xml1)
    H.write_temp_dfxml_hash(byte_run_hashdigest="00", byte_run_file_offset=1*4096)
    H.hashdb(["import", db1, "temp_dfxml_hash"])
    H.write_temp_dfxml_hash(byte_run_hashdigest="11", byte_run_file_offset=2*4096)
    H.hashdb(["import", db1, "temp_dfxml_hash"])
    H.write_temp_dfxml_hash(byte_run_hashdigest="22", byte_run_file_offset=3*4096)
    H.hashdb(["import", db1, "temp_dfxml_hash"])
    H.hashdb(["export", db1, xml1])

    # create DB with two entries of hash 00 and one entry of hash 11
    # to provide two duplicate hash entries and two duplicate source entries
    shutil.rmtree(db1, True)
    H.hashdb(["create", db1])
    H.write_temp_dfxml_hash(byte_run_hashdigest="00", repository_name="r1")
    H.hashdb(["import", db1, "temp_dfxml_hash"])
    H.write_temp_dfxml_hash(byte_run_hashdigest="00", repository_name="r2", byte_run_hash_label="H")
    H.hashdb(["import", db1, "temp_dfxml_hash"])
    H.write_temp_dfxml_hash(byte_run_hashdigest="11", repository_name="r2", byte_run_hash_label="L")
    H.hashdb(["import", db1, "temp_dfxml_hash"])