X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=test%2Fpy%2Ftests%2Ftest_gpt.py;h=4329b69b7adda59f8c1d0bf495e096d6d026e24d;hb=ac122efdb66f24fe4a642ec76bd32d80bf34bba4;hp=b9b5e5fbb04f4d6e0df511500f6735b45f1a7eac;hpb=84d46e7e8948780d7ca20c24dfc7b653b900f728;p=platform%2Fkernel%2Fu-boot.git diff --git a/test/py/tests/test_gpt.py b/test/py/tests/test_gpt.py index b9b5e5f..4329b69 100644 --- a/test/py/tests/test_gpt.py +++ b/test/py/tests/test_gpt.py @@ -32,23 +32,24 @@ class GptTestDiskImage(object): persistent = u_boot_console.config.persistent_data_dir + '/' + filename self.path = u_boot_console.config.result_dir + '/' + filename - if os.path.exists(persistent): - u_boot_console.log.action('Disk image file ' + persistent + - ' already exists') - else: - u_boot_console.log.action('Generating ' + persistent) - fd = os.open(persistent, os.O_RDWR | os.O_CREAT) - os.ftruncate(fd, 4194304) - os.close(fd) - cmd = ('sgdisk', '-U', '375a56f7-d6c9-4e81-b5f0-09d41ca89efe', - persistent) - u_boot_utils.run_and_log(u_boot_console, cmd) - cmd = ('sgdisk', '--new=1:2048:2560', '-c 1:part1', persistent) - u_boot_utils.run_and_log(u_boot_console, cmd) - cmd = ('sgdisk', '--new=2:4096:4608', '-c 2:part2', persistent) - u_boot_utils.run_and_log(u_boot_console, cmd) - cmd = ('sgdisk', '-l', persistent) - u_boot_utils.run_and_log(u_boot_console, cmd) + with u_boot_utils.persistent_file_helper(u_boot_console.log, persistent): + if os.path.exists(persistent): + u_boot_console.log.action('Disk image file ' + persistent + + ' already exists') + else: + u_boot_console.log.action('Generating ' + persistent) + fd = os.open(persistent, os.O_RDWR | os.O_CREAT) + os.ftruncate(fd, 4194304) + os.close(fd) + cmd = ('sgdisk', '-U', '375a56f7-d6c9-4e81-b5f0-09d41ca89efe', + persistent) + u_boot_utils.run_and_log(u_boot_console, cmd) + cmd = ('sgdisk', '--new=1:2048:2560', '-c 1:part1', persistent) + u_boot_utils.run_and_log(u_boot_console, cmd) + cmd = ('sgdisk', '--new=2:4096:4608', '-c 2:part2', persistent) + u_boot_utils.run_and_log(u_boot_console, cmd) + cmd = ('sgdisk', '-l', persistent) + u_boot_utils.run_and_log(u_boot_console, cmd) cmd = ('cp', persistent, self.path) u_boot_utils.run_and_log(u_boot_console, cmd)