test_java_isolation_rootfs.py (1971:3410f9d2a662) test_java_isolation_rootfs.py (2004:ca4c5855f139)
1import os
2import subprocess
3
4import pytest
5from unit.applications.lang.java import TestApplicationJava
6from unit.option import option
7
8

--- 4 unchanged lines hidden (view full) ---

13 if not is_su:
14 return
15
16 os.makedirs(option.temp_dir + '/jars')
17 os.makedirs(option.temp_dir + '/tmp')
18 os.chmod(option.temp_dir + '/tmp', 0o777)
19
20 try:
1import os
2import subprocess
3
4import pytest
5from unit.applications.lang.java import TestApplicationJava
6from unit.option import option
7
8

--- 4 unchanged lines hidden (view full) ---

13 if not is_su:
14 return
15
16 os.makedirs(option.temp_dir + '/jars')
17 os.makedirs(option.temp_dir + '/tmp')
18 os.chmod(option.temp_dir + '/tmp', 0o777)
19
20 try:
21 process = subprocess.Popen(
21 subprocess.run(
22 [
23 "mount",
24 "--bind",
25 option.current_dir + "/build",
26 option.temp_dir + "/jars",
27 ],
28 stderr=subprocess.STDOUT,
29 )
30
22 [
23 "mount",
24 "--bind",
25 option.current_dir + "/build",
26 option.temp_dir + "/jars",
27 ],
28 stderr=subprocess.STDOUT,
29 )
30
31 process.communicate()
32
33 except KeyboardInterrupt:
34 raise
35
31 except KeyboardInterrupt:
32 raise
33
36 except:
34 except subprocess.CalledProcessError:
37 pytest.fail('Can\'t run mount process.')
38
39 def teardown_method(self, is_su):
40 if not is_su:
41 return
42
43 try:
35 pytest.fail('Can\'t run mount process.')
36
37 def teardown_method(self, is_su):
38 if not is_su:
39 return
40
41 try:
44 process = subprocess.Popen(
42 subprocess.run(
45 ["umount", "--lazy", option.temp_dir + "/jars"],
46 stderr=subprocess.STDOUT,
47 )
48
43 ["umount", "--lazy", option.temp_dir + "/jars"],
44 stderr=subprocess.STDOUT,
45 )
46
49 process.communicate()
50
51 except KeyboardInterrupt:
52 raise
53
47 except KeyboardInterrupt:
48 raise
49
54 except:
55 pytest.fail('Can\'t run mount process.')
50 except subprocess.CalledProcessError:
51 pytest.fail('Can\'t run umount process.')
56
57 def test_java_isolation_rootfs_chroot_war(self, is_su, temp_dir):
58 if not is_su:
59 pytest.skip('require root')
60
61 isolation = {
62 'rootfs': temp_dir,
63 }

--- 15 unchanged lines hidden ---
52
53 def test_java_isolation_rootfs_chroot_war(self, is_su, temp_dir):
54 if not is_su:
55 pytest.skip('require root')
56
57 isolation = {
58 'rootfs': temp_dir,
59 }

--- 15 unchanged lines hidden ---