From 9bc60927c5d2d29751a90fbb86c758ef98ee584e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 24 Jun 2016 12:13:16 +0200 Subject: [PATCH] tests: replace sfdisk call with verbatim partition table sfdisk options and input format differs between versions (dropped MB units support), so instead of supporting all the combinations, simply paste its result verbatim. --- tests/backupcompatibility.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/backupcompatibility.py b/tests/backupcompatibility.py index 775db92f..826830d2 100644 --- a/tests/backupcompatibility.py +++ b/tests/backupcompatibility.py @@ -167,14 +167,20 @@ class TC_00_BackupCompatibility(qubes.tests.BackupTestsMixin, qubes.tests.QubesT def create_volatile_img(self, filename): self.create_sparse(filename, 11.5*2**30) - sfdisk_input="0,1024,S\n,10240,L\n" - p = subprocess.Popen(["/usr/sbin/sfdisk", "--no-reread", "-u", - "M", - filename], stdout=open("/dev/null","w"), - stderr=subprocess.STDOUT, stdin=subprocess.PIPE) - p.communicate(input=sfdisk_input) - self.assertEqual(p.returncode, 0, "sfdisk failed with code %d" % p - .returncode) + # here used to be sfdisk call with "0,1024,S\n,10240,L\n" input, + # but since sfdisk folks like to change command arguments in + # incompatible way, have an partition table verbatim here + ptable = ( + '\x00\x00\x00\x00\x00\x00\x00\x00\xab\x39\xd5\xd4\x00\x00\x20\x00' + '\x00\x21\xaa\x82\x82\x28\x08\x00\x00\x00\x00\x00\x00\x20\xaa\x00' + '\x82\x29\x15\x83\x9c\x79\x08\x00\x00\x20\x00\x00\x01\x40\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xaa\x55' + ) + with open(filename, 'r+') as f: + f.seek(0x1b0) + f.write(ptable) + # TODO: mkswap def fullpath(self, name):