tests: check importing empty data into ThinVolume
Verify if it really discards old content. QubesOS/qubes-issues#5192
This commit is contained in:
parent
790c2ad8cb
commit
19186f7840
@ -843,6 +843,37 @@ class TC_00_ThinPool(ThinPoolBase):
|
||||
|
||||
self.loop.run_until_complete(volume.remove())
|
||||
|
||||
def test_034_import_data_empty(self):
|
||||
config = {
|
||||
'name': 'root',
|
||||
'pool': self.pool.name,
|
||||
'save_on_stop': True,
|
||||
'rw': True,
|
||||
'size': 1024 * 1024,
|
||||
}
|
||||
vm = qubes.tests.storage.TestVM(self)
|
||||
volume = self.app.get_pool(self.pool.name).init_volume(vm, config)
|
||||
with unittest.mock.patch('time.time') as mock_time:
|
||||
mock_time.side_effect = [1521065905]
|
||||
self.loop.run_until_complete(volume.create())
|
||||
p = self.loop.run_until_complete(asyncio.create_subprocess_exec(
|
||||
'sudo', 'dd', 'if=/dev/urandom', 'of=' + volume.path, 'count=1', 'bs=1M'
|
||||
))
|
||||
self.loop.run_until_complete(p.wait())
|
||||
import_path = self.loop.run_until_complete(volume.import_data())
|
||||
self.assertNotEqual(volume.path, import_path)
|
||||
p = self.loop.run_until_complete(asyncio.create_subprocess_exec(
|
||||
'sudo', 'touch', import_path))
|
||||
self.loop.run_until_complete(p.wait())
|
||||
self.loop.run_until_complete(volume.import_data_end(True))
|
||||
self.assertFalse(os.path.exists(import_path), import_path)
|
||||
p = self.loop.run_until_complete(asyncio.create_subprocess_exec(
|
||||
'sudo', 'cat', volume.path,
|
||||
stdout=subprocess.PIPE
|
||||
))
|
||||
volume_data, _ = self.loop.run_until_complete(p.communicate())
|
||||
self.assertEqual(volume_data.strip(b'\0'), b'')
|
||||
|
||||
def test_040_volatile(self):
|
||||
'''Volatile volume test'''
|
||||
config = {
|
||||
|
Loading…
Reference in New Issue
Block a user