|
21 | 21 | import os |
22 | 22 | import unittest.mock |
23 | 23 |
|
| 24 | +import qubes.ext.audio |
24 | 25 | import qubes.ext.core_features |
25 | 26 | import qubes.ext.custom_persist |
26 | 27 | import qubes.ext.services |
@@ -2579,3 +2580,58 @@ def test_015_feature_set_path_with_colon_without_options(self): |
2579 | 2580 | self.vm.untrusted_qdb.write.assert_called_with( |
2580 | 2581 | "/persist/test", "/var/test:dir:with:colon" |
2581 | 2582 | ) |
| 2583 | + |
| 2584 | + |
| 2585 | +class TC_60_Audio(qubes.tests.QubesTestCase): |
| 2586 | + def setUp(self): |
| 2587 | + super().setUp() |
| 2588 | + self.ext = qubes.ext.audio.AUDIO() |
| 2589 | + self.audiovm = mock.MagicMock() |
| 2590 | + self.audiovm.name = "sys-audio" |
| 2591 | + self.client = mock.MagicMock() |
| 2592 | + self.client.name = "client" |
| 2593 | + self.client_alt = mock.MagicMock() |
| 2594 | + self.client_alt.name = "client" |
| 2595 | + |
| 2596 | + def test_000_shutdown(self): |
| 2597 | + self.ext.on_domain_pre_shutdown( |
| 2598 | + self.audiovm, |
| 2599 | + "domain-pre-shutdown", |
| 2600 | + ) |
| 2601 | + |
| 2602 | + def test_000_shutdown_used(self): |
| 2603 | + with unittest.mock.patch.object( |
| 2604 | + self.ext, "attached_vms", return_value=[self.client] |
| 2605 | + ), unittest.mock.patch.object( |
| 2606 | + self.client, "is_running", return_value=True |
| 2607 | + ): |
| 2608 | + self.client.is_preload = False |
| 2609 | + with self.assertRaises(qubes.exc.QubesVMInUseError): |
| 2610 | + self.ext.on_domain_pre_shutdown( |
| 2611 | + self.audiovm, |
| 2612 | + "domain-pre-shutdown", |
| 2613 | + ) |
| 2614 | + |
| 2615 | + self.client.is_preload = True |
| 2616 | + self.ext.on_domain_pre_shutdown( |
| 2617 | + self.audiovm, |
| 2618 | + "domain-pre-shutdown", |
| 2619 | + ) |
| 2620 | + |
| 2621 | + def test_000_shutdown_used_by_some(self): |
| 2622 | + with unittest.mock.patch.object( |
| 2623 | + self.ext, |
| 2624 | + "attached_vms", |
| 2625 | + return_value=[self.client, self.client_alt], |
| 2626 | + ), unittest.mock.patch.object( |
| 2627 | + self.client, "is_running", return_value=True |
| 2628 | + ), unittest.mock.patch.object( |
| 2629 | + self.client_alt, "is_running", return_value=True |
| 2630 | + ): |
| 2631 | + self.client.is_preload = False |
| 2632 | + self.client_alt.is_preload = True |
| 2633 | + with self.assertRaises(qubes.exc.QubesVMInUseError): |
| 2634 | + self.ext.on_domain_pre_shutdown( |
| 2635 | + self.audiovm, |
| 2636 | + "domain-pre-shutdown", |
| 2637 | + ) |
0 commit comments