From a35cb463421ad9785a207306cdea0229aebdd3e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 28 Feb 2019 05:34:42 +0100 Subject: [PATCH] tests: vm.run, vm.run_with_args QubesOS/qubes-issues#4850 --- qubesadmin/tests/vm/actions.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/qubesadmin/tests/vm/actions.py b/qubesadmin/tests/vm/actions.py index be92c38..734a55c 100644 --- a/qubesadmin/tests/vm/actions.py +++ b/qubesadmin/tests/vm/actions.py @@ -73,3 +73,36 @@ class TC_00_Actions(qubesadmin.tests.vm.VMTestCase): b'0\x00' self.vm.resume() self.assertAllCalled() + + def test_010_run_linux(self): + self.app.expected_calls[ + ('test-vm', 'admin.vm.feature.CheckWithTemplate', 'os', None)] = \ + b'2\x00QubesFeatureNotFoundError\x00\x00Feature \'os\' not set\x00' + self.vm.run('some command') + self.assertEqual(self.app.service_calls, [ + ('test-vm', 'qubes.VMShell', {}), + ('test-vm', 'qubes.VMShell', b'some command; exit\n'), + ]) + + def test_011_run_windows(self): + self.app.expected_calls[ + ('test-vm', 'admin.vm.feature.CheckWithTemplate', 'os', None)] = \ + b'0\x00Windows' + self.vm.run('some command') + self.assertEqual(self.app.service_calls, [ + ('test-vm', 'qubes.VMShell', {}), + ('test-vm', 'qubes.VMShell', b'some command& exit\n'), + ]) + + def test_015_run_with_args(self): + self.app.expected_calls[ + ('test-vm', 'admin.vm.feature.CheckWithTemplate', 'os', None)] = \ + b'2\x00QubesFeatureNotFoundError\x00\x00Feature \'os\' not set\x00' + self.vm.run_with_args('some', 'argument with spaces', + 'and $pecial; chars') + self.assertEqual(self.app.service_calls, [ + ('test-vm', 'qubes.VMShell', {}), + ('test-vm', 'qubes.VMShell', + b'some \'argument with spaces\' \'and $pecial; chars\'; ' + b'exit\n'), + ])