fix(recovery): use modern no-log-replay mount option and report stderr
This commit is contained in:
@@ -252,6 +252,14 @@ s.restore(sys.argv[3])
|
||||
self.assertEqual((self.top / '@root/kernel').read_text(), 'old kernel')
|
||||
|
||||
class NativeBoundaryTests(unittest.TestCase):
|
||||
def test_failed_native_command_includes_bounded_stderr(self):
|
||||
backend = r.Btrfs()
|
||||
error = subprocess.CalledProcessError(32, ['mount'], stderr='specific mount failure\n' + 'x' * 5000)
|
||||
with patch.object(r.subprocess, 'run', side_effect=error):
|
||||
with self.assertRaisesRegex(r.RecoveryError, 'specific mount failure') as caught:
|
||||
backend.run(['mount', '-t', 'btrfs', '/dev/example', '/run/example'])
|
||||
self.assertLess(len(str(caught.exception)), 2300)
|
||||
|
||||
def test_btrfs_show_parser_and_readonly_property(self):
|
||||
backend = r.Btrfs()
|
||||
sample = '''@snapshots/example/root
|
||||
@@ -292,7 +300,7 @@ class NativeBoundaryTests(unittest.TestCase):
|
||||
with self.assertRaises(r.RecoveryError):
|
||||
with r.mounted(backend, '/dev/fake', 'btrfs'): pass
|
||||
self.assertEqual([argv[0] for argv in calls], ['mount', 'btrfs', 'umount'])
|
||||
self.assertIn('ro,nosuid,nodev,noexec,subvolid=5,nologreplay', calls[0])
|
||||
self.assertIn('ro,nosuid,nodev,noexec,subvolid=5,rescue=nologreplay', calls[0])
|
||||
def test_cli_requires_matching_confirmation_before_probe(self):
|
||||
with patch.object(r, 'DeviceProbe') as probe, patch.object(sys, 'stderr', new_callable=io.StringIO):
|
||||
self.assertEqual(r.main(['restore', '--root-uuid', ROOT_UUID, '--checkpoint', ROOT_PART, '--execute']), 1)
|
||||
|
||||
Reference in New Issue
Block a user