1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 import arvados_fuse.command
14 from shlex import quote
16 from pipes import quote
18 def try_exec(mnt, cmd):
20 arvados_fuse.command.Mount(
21 arvados_fuse.command.ArgumentParser().parse_args([
24 '--unmount-timeout=0.1',
26 '--exec'] + cmd)).run()
30 raise AssertionError('should have exited')
33 class ExecMode(unittest.TestCase):
37 run_test_server.run_keep(enforce_permissions=True, num_servers=2)
38 run_test_server.authorize_with('active')
41 def tearDownClass(cls):
42 run_test_server.stop_keep(num_servers=2)
45 self.mnt = tempfile.mkdtemp()
46 _, self.okfile = tempfile.mkstemp()
47 self.pool = multiprocessing.Pool(1)
53 os.unlink(self.okfile)
56 self.pool.apply(try_exec, (self.mnt, [
58 'echo -n foo >{}; cp {} {}'.format(
59 quote(os.path.join(self.mnt, 'zzz', 'foo.txt')),
60 quote(os.path.join(self.mnt, 'zzz', '.arvados#collection')),
61 quote(os.path.join(self.okfile)))]))
62 self.assertRegexpMatches(
63 json.load(open(self.okfile))['manifest_text'],