コード例 #1
0
def test_wipe_sub(n_bytes, mkfs_cmd):
    """Test FileUtilities.wipe_path"""

    filename = create_disk_image(n_bytes)
    print('created disk image %s' % filename)

    # format filesystem
    format_filesystem(filename, mkfs_cmd)

    # mount
    mountpoint = tempfile.mkdtemp(prefix='bleachbit-wipe-mountpoint')
    mount_filesystem(filename, mountpoint)

    # baseline free disk space
    print('df for clean filesystem')
    print(run_external(['df', mountpoint])[1])

    # make dirty
    make_dirty(mountpoint)

    # verify dirtiness
    unmount_filesystem(mountpoint)
    assert (verify_cleanliness(filename) == 11)
    mount_filesystem(filename, mountpoint)

    # standard delete
    logger.info('standard delete')
    delete_counter = 0
    for secretfile in listdir(mountpoint):
        if 'secret' not in secretfile:
            # skip lost+found
            continue
        delete(secretfile, shred=False)
        delete_counter += 1
    logger.debug('deleted %d files', delete_counter)

    # check
    print('df for empty, dirty filesystem')
    print(run_external(['df', mountpoint])[1])

    # verify dirtiness
    unmount_filesystem(mountpoint)
    assert (verify_cleanliness(filename) == 11)
    mount_filesystem(filename, mountpoint)
    expected_free_space = free_space(mountpoint)

    # measure effectiveness of multiple wipes
    for i in range(1, 10):
        print('*' * 30)
        print('* pass %d *' % i)
        print('*' * 30)

        # remount
        if i > 1:
            mount_filesystem(filename, mountpoint)\

        # really wipe
        print('wiping %s' % mountpoint)
        for w in wipe_path(mountpoint):
            pass

        # verify cleaning process freed all space it allocated
        actual_free_space = free_space(mountpoint)
        if not expected_free_space == actual_free_space:
            print('expecting %d free space but got %d' %
                  (expected_free_space, actual_free_space))
            import pdb
            pdb.set_trace()

        # unmount
        unmount_filesystem(mountpoint)

        # verify cleanliness
        cleanliness = verify_cleanliness(filename)

    assert (cleanliness < 2)

    # remove temporary
    delete(filename)
    delete(mountpoint)
コード例 #2
0
ファイル: TestWipe.py プロジェクト: Nullstr1ng/bleachbit
def test_wipe_sub(n_bytes, mkfs_cmd):
    """Test FileUtilities.wipe_path"""
    if 'nt' == os.name:
        print 'WARNING: test_wipe() not supported on Windows'
        return
    filename = create_disk_image(n_bytes)
    print 'created disk image %s' % filename

    # format filesystem
    format_filesystem(filename, mkfs_cmd)

    # mount
    mountpoint = tempfile.mkdtemp(prefix='bleachbit-wipe-mountpoint')
    mount_filesystem(filename, mountpoint)

    # baseline free disk space
    print 'df for clean filesystem'
    print run_external(['df', mountpoint])[1]

    # make dirty
    make_dirty(mountpoint)

    # verify dirtiness
    unmount_filesystem(mountpoint)
    assert(verify_cleanliness(filename) == 11)
    mount_filesystem(filename, mountpoint)

    # standard delete
    print 'info: standard delete'
    delete_counter = 0
    for secretfile in listdir(mountpoint):
        if not 'secret' in secretfile:
            # skip lost+found
            continue
        delete(secretfile, shred=False)
        delete_counter += 1
    print 'debug: deleted %d files' % delete_counter

    # check
    print 'df for empty, dirty filesystem'
    print run_external(['df', mountpoint])[1]

    # verify dirtiness
    unmount_filesystem(mountpoint)
    assert(verify_cleanliness(filename) == 11)
    mount_filesystem(filename, mountpoint)
    expected_free_space = free_space(mountpoint)

    # measure effectiveness of multiple wipes
    for i in range(1, 10):
        print '*' * 30
        print '* pass %d *' % i
        print '*' * 30

        # remount
        if i > 1:
            mount_filesystem(filename, mountpoint)\

        # really wipe
        print 'wiping %s' % mountpoint
        for w in wipe_path(mountpoint):
            pass

        # verify cleaning process freed all space it allocated
        actual_free_space = free_space(mountpoint)
        if not expected_free_space == actual_free_space:
            print 'expecting %d free space but got %d' % \
                (expected_free_space, actual_free_space)
            import pdb
            pdb.set_trace()

        # unmount
        unmount_filesystem(mountpoint)

        # verify cleanliness
        cleanliness = verify_cleanliness(filename)

    assert(cleanliness < 2)

    # remove temporary
    delete(filename)
    delete(mountpoint)
コード例 #3
0
ファイル: TestWipe.py プロジェクト: kleopatra999/bleachbit
def test_wipe_sub(n_bytes, mkfs_cmd):
    """Test FileUtilities.wipe_path"""
    if 'nt' == os.name:
        print 'WARNING: test_wipe() not supported on Windows'
        return
    filename = create_disk_image(n_bytes)
    print 'created disk image %s' % filename

    # format filesystem
    format_filesystem(filename, mkfs_cmd)

    # mount
    mountpoint = tempfile.mkdtemp('bleachbit-wipe-mountpoint')
    mount_filesystem(filename, mountpoint)

    # baseline free disk space
    print 'df for clean filesystem'
    print run_external(['df', mountpoint])[1]

    # make dirty
    make_dirty(mountpoint)

    # verify dirtiness
    unmount_filesystem(mountpoint)
    assert (verify_cleanliness(filename) == 11)
    mount_filesystem(filename, mountpoint)

    # standard delete
    print 'info: standard delete'
    delete_counter = 0
    for secretfile in listdir(mountpoint):
        if not 'secret' in secretfile:
            # skip lost+found
            continue
        delete(secretfile, shred=False)
        delete_counter += 1
    print 'debug: deleted %d files' % delete_counter

    # check
    print 'df for empty, dirty filesystem'
    print run_external(['df', mountpoint])[1]

    # verify dirtiness
    unmount_filesystem(mountpoint)
    assert (verify_cleanliness(filename) == 11)
    mount_filesystem(filename, mountpoint)
    expected_free_space = free_space(mountpoint)

    # measure effectiveness of multiple wipes
    for i in range(1, 10):
        print '*' * 30
        print '* pass %d *' % i
        print '*' * 30

        # remount
        if i > 1:
            mount_filesystem(filename, mountpoint)\

        # really wipe
        print 'wiping %s' % mountpoint
        for w in wipe_path(mountpoint):
            pass

        # verify cleaning process freed all space it allocated
        actual_free_space = free_space(mountpoint)
        if not expected_free_space == actual_free_space:
            print 'expecting %d free space but got %d' % \
                (expected_free_space, actual_free_space)
            import pdb
            pdb.set_trace()

        # unmount
        unmount_filesystem(mountpoint)

        # verify cleanliness
        cleanliness = verify_cleanliness(filename)

    assert (cleanliness < 2)

    # remove temporary
    delete(filename)
    delete(mountpoint)