summaryrefslogtreecommitdiff
path: root/test/v9fs_driver_test.py
blob: 9781c4fe5efbd6b4859fd56ed61ed40ff75d8b8f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3
"""Unprivileged regression checks for the v9fs helper launcher."""
import os
import sys
import unittest

from v9fs import run_helper


class HelperLaunchTests(unittest.TestCase):
    def test_preserves_session_for_terminal_scoped_sudo_credentials(self):
        output = run_helper([sys.executable, '-c', 'import os; print(os.getsid(0))'])
        self.assertEqual(int(output), os.getsid(0))

    def test_failure_preserves_diagnostics(self):
        with self.assertRaisesRegex(RuntimeError, r'(?s)failed \(7\).*mount refused'):
            run_helper([sys.executable, '-c',
                        'import sys; print("mount refused", file=sys.stderr); sys.exit(7)'])

    def test_timeout_is_not_a_passing_probe(self):
        with self.assertRaisesRegex(RuntimeError, 'timed out; no compatibility result'):
            run_helper([sys.executable, '-c', 'import time; time.sleep(60)'], timeout=.1)


if __name__ == '__main__':
    unittest.main()