run: fix image check logic accounting for userland

Was failing if I try to run userland (with abspath) when out/
directory is not present.
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-05-05 00:00:00 +00:00
parent 53620e5d32
commit 8dae332c17

20
run
View File

@@ -425,20 +425,24 @@ Extra options to append at the end of the emulator command line.
if self.env['emulator'] == 'gem5':
if self.env['quiet']:
show_stdout = False
if self.env['baremetal'] is None:
if not self.env['baremetal'] is None:
if not os.path.exists(self.env['gem5_fake_iso']):
os.makedirs(os.path.dirname(self.env['gem5_fake_iso']), exist_ok=True)
self.sh.write_string_to_file(self.env['gem5_fake_iso'], 'a' * 512)
elif self.env['userland'] is None:
if not os.path.exists(self.env['rootfs_raw_file']):
if not os.path.exists(self.env['qcow2_file']):
raise_rootfs_not_found()
self.raw_to_qcow2(qemu_which=self.env['qemu_which'], reverse=True)
else:
if not os.path.exists(self.env['gem5_fake_iso']):
os.makedirs(os.path.dirname(self.env['gem5_fake_iso']), exist_ok=True)
self.sh.write_string_to_file(self.env['gem5_fake_iso'], 'a' * 512)
if not os.path.exists(self.env['image']):
# This is to run gem5 from a prebuilt download.
if (not self.env['baremetal'] is None) or (not os.path.exists(self.env['linux_image'])):
raise_image_not_found()
self.sh.run_cmd([os.path.join(self.env['extract_vmlinux'], self.env['linux_image'])])
if (
self.env['baremetal'] is None and
self.env['userland'] is None
):
if not os.path.exists(self.env['linux_image']):
raise_image_not_found()
self.sh.run_cmd([os.path.join(self.env['extract_vmlinux'], self.env['linux_image'])])
os.makedirs(os.path.dirname(self.env['gem5_readfile']), exist_ok=True)
self.sh.write_string_to_file(self.env['gem5_readfile'], self.env['gem5_readfile'])
memory = '{}B'.format(self.env['memory'])