|
@@ -69,9 +69,10 @@ class CmdTestAutosignBase(CmdTestBase):
|
|
self.network_ids = [c+'_tn' for c in self.daemon_coins] + self.daemon_coins
|
|
self.network_ids = [c+'_tn' for c in self.daemon_coins] + self.daemon_coins
|
|
|
|
|
|
self._create_autosign_instances(create_dirs=not cfg.skipping_deps)
|
|
self._create_autosign_instances(create_dirs=not cfg.skipping_deps)
|
|
|
|
+ self.fs_image_path = Path(self.tmpdir).absolute() / 'removable_device_image'
|
|
|
|
|
|
if sys.platform == 'linux':
|
|
if sys.platform == 'linux':
|
|
- self.txdev = VirtBlockDevice(self.asi.fs_image_path, '10M')
|
|
|
|
|
|
+ self.txdev = VirtBlockDevice(self.fs_image_path, '10M')
|
|
|
|
|
|
if not (cfg.skipping_deps or self.live):
|
|
if not (cfg.skipping_deps or self.live):
|
|
self._create_removable_device()
|
|
self._create_removable_device()
|
|
@@ -115,7 +116,7 @@ class CmdTestAutosignBase(CmdTestBase):
|
|
}))
|
|
}))
|
|
|
|
|
|
if create_dirs and not self.live:
|
|
if create_dirs and not self.live:
|
|
- for k in ('mountpoint', 'shm_dir', 'wallet_dir', 'dev_label_dir'):
|
|
|
|
|
|
+ for k in ('mountpoint', 'shm_dir', 'wallet_dir'):
|
|
if subdir == 'online' and k in ('shm_dir', 'wallet_dir'):
|
|
if subdir == 'online' and k in ('shm_dir', 'wallet_dir'):
|
|
continue
|
|
continue
|
|
if sys.platform == 'darwin' and k != 'mountpoint':
|
|
if sys.platform == 'darwin' and k != 'mountpoint':
|
|
@@ -127,6 +128,10 @@ class CmdTestAutosignBase(CmdTestBase):
|
|
|
|
|
|
setattr(self, data['name'], asi)
|
|
setattr(self, data['name'], asi)
|
|
|
|
|
|
|
|
+ def _set_e2label(self, label):
|
|
|
|
+ imsg(f'Setting label to {label}')
|
|
|
|
+ run(['/sbin/e2label', str(self.txdev.img_path), label], check=True)
|
|
|
|
+
|
|
def _create_removable_device(self):
|
|
def _create_removable_device(self):
|
|
if sys.platform == 'linux':
|
|
if sys.platform == 'linux':
|
|
self.txdev.create()
|
|
self.txdev.create()
|
|
@@ -143,14 +148,14 @@ class CmdTestAutosignBase(CmdTestBase):
|
|
cmd = [
|
|
cmd = [
|
|
'hdiutil', 'create', '-size', '10M', '-fs', 'exFAT',
|
|
'hdiutil', 'create', '-size', '10M', '-fs', 'exFAT',
|
|
'-volname', self.asi.dev_label,
|
|
'-volname', self.asi.dev_label,
|
|
- str(self.asi.fs_image_path)]
|
|
|
|
|
|
+ str(self.fs_image_path)]
|
|
redir = None if cfg.exact_output or cfg.verbose else DEVNULL
|
|
redir = None if cfg.exact_output or cfg.verbose else DEVNULL
|
|
run(cmd, stdout=redir, check=True)
|
|
run(cmd, stdout=redir, check=True)
|
|
|
|
|
|
def _macOS_mount_fs_image(self, loc):
|
|
def _macOS_mount_fs_image(self, loc):
|
|
time.sleep(0.2)
|
|
time.sleep(0.2)
|
|
run(
|
|
run(
|
|
- ['hdiutil', 'attach', '-mountpoint', str(loc.mountpoint), f'{loc.fs_image_path}.dmg'],
|
|
|
|
|
|
+ ['hdiutil', 'attach', '-mountpoint', str(loc.mountpoint), f'{self.fs_image_path}.dmg'],
|
|
stdout=DEVNULL, check=True)
|
|
stdout=DEVNULL, check=True)
|
|
|
|
|
|
def _macOS_eject_disk(self, label):
|
|
def _macOS_eject_disk(self, label):
|
|
@@ -236,8 +241,14 @@ class CmdTestAutosignBase(CmdTestBase):
|
|
return
|
|
return
|
|
loc = getattr(self, asi)
|
|
loc = getattr(self, asi)
|
|
if sys.platform == 'linux':
|
|
if sys.platform == 'linux':
|
|
- loc.dev_label_path.touch()
|
|
|
|
- # self.txdev.attach() # WIP
|
|
|
|
|
|
+ self._set_e2label(loc.dev_label)
|
|
|
|
+ self.txdev.attach()
|
|
|
|
+ for _ in range(20):
|
|
|
|
+ if loc.device_inserted:
|
|
|
|
+ break
|
|
|
|
+ time.sleep(0.1)
|
|
|
|
+ else:
|
|
|
|
+ die(2, f'device insert timeout exceeded {loc.dev_label}')
|
|
elif sys.platform == 'darwin':
|
|
elif sys.platform == 'darwin':
|
|
self._macOS_mount_fs_image(loc)
|
|
self._macOS_mount_fs_image(loc)
|
|
|
|
|
|
@@ -246,9 +257,13 @@ class CmdTestAutosignBase(CmdTestBase):
|
|
return
|
|
return
|
|
loc = getattr(self, asi)
|
|
loc = getattr(self, asi)
|
|
if sys.platform == 'linux':
|
|
if sys.platform == 'linux':
|
|
- if loc.dev_label_path.exists():
|
|
|
|
- loc.dev_label_path.unlink()
|
|
|
|
- # self.txdev.detach() # WIP
|
|
|
|
|
|
+ self.txdev.detach()
|
|
|
|
+ for _ in range(20):
|
|
|
|
+ if not loc.device_inserted:
|
|
|
|
+ break
|
|
|
|
+ time.sleep(0.1)
|
|
|
|
+ else:
|
|
|
|
+ die(2, f'device remove timeout exceeded {loc.dev_label}')
|
|
elif sys.platform == 'darwin':
|
|
elif sys.platform == 'darwin':
|
|
self._macOS_eject_disk(loc.dev_label)
|
|
self._macOS_eject_disk(loc.dev_label)
|
|
|
|
|