Пример #1
0
def test_first_partition_offset():
    table = backend.PartitionTable()
    table.grain = 4096

    # Grain = 4096, first_lba = None.
    # 20480 = (512 bytes sector size + 16896 bytes footer) rounded up to multiple of 4096 grain.
    assert table.first_partition_offset() == 20480

    # Grain = 4096, first_lba not None.
    # 32768 = first_lba of 64 * 512 bytes of sector_size.
    table.first_lba = 64
    assert table.first_partition_offset() == 32768

    # 0 since first_lba = 0 will be multiplied by some value of sector_size.
    table.first_lba = 0
    assert table.first_partition_offset() == 0

    # Grain = 1024 ** 2, first_lba = None.
    # 1048576 = (512 bytes sector size + 16896 bytes footer) rounded up to multiple of 1024 ** 2 grain.
    table.grain = 1024**2
    table.first_lba = None
    assert table.first_partition_offset() == 1048576

    # Grain = 1024 ** 2, first_lba not None.
    # 65536 = first_lba of 128 * 512 bytes of sector_size.
    table.first_lba = 128
    assert table.first_partition_offset() == 65536

    # Grain = 1024 ** 2, first_lba not None.
    # 131072 = first_lba of 256 * 512 bytes of sector_size.
    table.first_lba = 256
    assert table.first_partition_offset() == 131072
Пример #2
0
def test_disk_size():
    table = backend.PartitionTable()
    table.grain = 4096
    table.last_partition_sector = 0
    table.first_lba = 64
    # When disk_size() cascade upwards all the way to first_partition_offset, if clause.
    assert table.disk_size() == 53248

    # When disk_size() cascade upwards all the way to first_partition_offset, else clause.
    table.first_lba = None
    assert table.disk_size() == 40960

    # When disk_size() cascade upwards to last_partition_offset, if clause.
    table.last_partition_sector = 32
    assert table.disk_size() == 36864
Пример #3
0
def test_last_partition_offset():
    table = backend.PartitionTable()
    table.grain = 4096

    table.last_partition_sector = 32
    assert table.last_partition_offset() == 16384

    table.last_partition_sector = 16
    assert table.last_partition_offset() == 8192

    table.last_partition_sector = 1
    assert table.last_partition_offset() == 4096

    table.last_partition_sector = 0
    table.first_lba = 64
    assert table.last_partition_offset() == 32768

    table.first_lba = 0
    assert table.last_partition_offset() == 0
Пример #4
0
def test_footer_size():
    table = backend.PartitionTable()
    assert table.footer_size() == 16896
    assert table.footer_size(max_partitions=64) == 8704
    assert table.footer_size(max_partitions=1) == 1024
    assert table.footer_size(max_partitions=0) == 512