Skip to content

Commit a85cdf8

Browse files
donny-wongDonny Wongpre-commit-ci[bot]
authored
Sticky bit unit test (#501)
--------- Co-authored-by: Donny Wong <donnywong@cs.toronto.edu> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a1b9c05 commit a85cdf8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

server/autotest_server/tests/test_autotest_server.py

+22
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import subprocess
2+
13
import pytest
24
import fakeredis
35
import rq
46
import autotest_server
7+
import os
58

69

710
@pytest.fixture
@@ -26,3 +29,22 @@ def fake_redis_db(monkeypatch, fake_job):
2629

2730
def test_redis_connection(fake_redis_conn):
2831
assert autotest_server.redis_connection() == fake_redis_conn
32+
33+
34+
def test_sticky():
35+
workers = autotest_server.config["workers"]
36+
autotest_worker = workers[0]["user"]
37+
autotest_worker_working_dir = f"/home/docker/.autotesting/workers/{autotest_worker}"
38+
path = f"{autotest_worker_working_dir}/test_sticky"
39+
40+
if not os.path.exists(path):
41+
mkdir_cmd = f"sudo -u {autotest_worker} mkdir {path}"
42+
chmod_cmd = f"sudo -u {autotest_worker} chmod 000 {path}"
43+
chmod_sticky_cmd = f"sudo -u {autotest_worker} chmod +t {path}"
44+
subprocess.run(mkdir_cmd, shell=True)
45+
subprocess.run(chmod_cmd, shell=True)
46+
subprocess.run(chmod_sticky_cmd, shell=True)
47+
48+
autotest_server._clear_working_directory(autotest_worker_working_dir, autotest_worker)
49+
50+
assert os.path.exists(path) is False

0 commit comments

Comments
 (0)