Browse Source

minor fixes and cleanups

The MMGen Project 6 months ago
parent
commit
36814cc03c
4 changed files with 14 additions and 10 deletions
  1. 1 1
      mmgen/autosign.py
  2. 4 4
      test/cmdtest.py
  3. 8 4
      test/cmdtest_py_d/ct_autosign.py
  4. 1 1
      test/include/common.py

+ 1 - 1
mmgen/autosign.py

@@ -502,7 +502,7 @@ class Autosign:
 				if not silent:
 				if not silent:
 					msg(f"Mounting '{self.mountpoint}'")
 					msg(f"Mounting '{self.mountpoint}'")
 			else:
 			else:
-				die(1,f"Unable to mount device at '{self.mountpoint}'")
+				die(1,f'Unable to mount device {self.dev_label} at {self.mountpoint}')
 
 
 		for dirname in self.dirs:
 		for dirname in self.dirs:
 			check_or_create(dirname)
 			check_or_create(dirname)

+ 4 - 4
test/cmdtest.py

@@ -995,14 +995,14 @@ if __name__ == '__main__':
 		tr = CmdTestRunner(data_dir,trash_dir)
 		tr = CmdTestRunner(data_dir,trash_dir)
 		tr.run_tests(cmd_args)
 		tr.run_tests(cmd_args)
 		tr.warn_skipped()
 		tr.warn_skipped()
-		if tr.daemon_started:
-			stop_test_daemons(network_id)
+		if tr.daemon_started and not cfg.no_daemon_stop:
+			stop_test_daemons(network_id, remove_datadir=True)
 		if hasattr(tr, 'tg'):
 		if hasattr(tr, 'tg'):
 			del tr.tg
 			del tr.tg
 		del tr
 		del tr
 	except KeyboardInterrupt:
 	except KeyboardInterrupt:
-		if tr.daemon_started:
-			stop_test_daemons(network_id)
+		if tr.daemon_started and not cfg.no_daemon_stop:
+			stop_test_daemons(network_id, remove_datadir=True)
 		tr.warn_skipped()
 		tr.warn_skipped()
 		die(1,yellow('\ntest.py exiting at user request'))
 		die(1,yellow('\ntest.py exiting at user request'))
 	except TestSuiteSpawnedScriptException as e:
 	except TestSuiteSpawnedScriptException as e:

+ 8 - 4
test/cmdtest_py_d/ct_autosign.py

@@ -149,7 +149,9 @@ class CmdTestAutosignBase(CmdTestBase):
 
 
 	def _macOS_mount_fs_image(self, loc):
 	def _macOS_mount_fs_image(self, loc):
 		time.sleep(0.2)
 		time.sleep(0.2)
-		run(f'hdiutil attach -mountpoint {loc.mountpoint} {loc.fs_image_path}.dmg'.split(), stdout=DEVNULL, check=True)
+		run(
+			['hdiutil', 'attach', '-mountpoint', str(loc.mountpoint), f'{loc.fs_image_path}.dmg'],
+			stdout=DEVNULL, check=True)
 
 
 	def _macOS_eject_disk(self, label):
 	def _macOS_eject_disk(self, label):
 		try:
 		try:
@@ -348,6 +350,7 @@ class CmdTestAutosignClean(CmdTestAutosignBase):
 		self.spawn('', msg_only=True)
 		self.spawn('', msg_only=True)
 
 
 		self.insert_device()
 		self.insert_device()
+
 		silence()
 		silence()
 		self.do_mount()
 		self.do_mount()
 		end_silence()
 		end_silence()
@@ -358,7 +361,9 @@ class CmdTestAutosignClean(CmdTestAutosignBase):
 		t = self.spawn('mmgen-autosign', [f'--coins={coins}','clean'], no_msg=True)
 		t = self.spawn('mmgen-autosign', [f'--coins={coins}','clean'], no_msg=True)
 		out = t.read()
 		out = t.read()
 
 
-		self.insert_device()
+		if sys.platform == 'darwin':
+			self.insert_device()
+
 		silence()
 		silence()
 		self.do_mount()
 		self.do_mount()
 		end_silence()
 		end_silence()
@@ -436,8 +441,7 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase):
 
 
 	def _wait_signed(self,desc):
 	def _wait_signed(self,desc):
 		oqmsg_r(gray(f'→ offline wallet{"s" if desc.endswith("s") else ""} waiting for {desc}'))
 		oqmsg_r(gray(f'→ offline wallet{"s" if desc.endswith("s") else ""} waiting for {desc}'))
-		assert not self.asi.device_inserted, (
-				f'‘{getattr(self.asi, "dev_label_path", self.asi.dev_label)}’ is inserted!')
+		assert not self.asi.device_inserted, f'‘{self.asi.dev_label}’ is inserted!'
 		assert not self.asi.mountpoint.is_mount(), f'‘{self.asi.mountpoint}’ is mounted!'
 		assert not self.asi.mountpoint.is_mount(), f'‘{self.asi.mountpoint}’ is mounted!'
 		self.insert_device()
 		self.insert_device()
 		while True:
 		while True:

+ 1 - 1
test/include/common.py

@@ -420,7 +420,7 @@ class VirtBlockDeviceLinux(VirtBlockDeviceBase):
 		do_run(['sudo', '/sbin/losetup', dev, str(path)])
 		do_run(['sudo', '/sbin/losetup', dev, str(path)])
 
 
 	def do_detach(self, dev, check=True):
 	def do_detach(self, dev, check=True):
-		do_run(['/sbin/losetup', '-d', dev], check=check)
+		do_run(['sudo', '/sbin/losetup', '-d', dev], check=check)
 
 
 class VirtBlockDeviceMacOS(VirtBlockDeviceBase):
 class VirtBlockDeviceMacOS(VirtBlockDeviceBase):