diff options
author | Tiago Natel <t.nateldemoura@f5.com> | 2019-11-09 20:14:52 +0000 |
---|---|---|
committer | Tiago Natel <t.nateldemoura@f5.com> | 2019-11-09 20:14:52 +0000 |
commit | 19b974674c1fdd8fc46eb0877d2a8ff8b794490d (patch) | |
tree | 7d436f600dfe8a4bd7e66ff20be0b9ced6e48fb8 /test/unit/main.py | |
parent | 94a9162baa82809ec58a3d06ca3489c7e7fed6ed (diff) | |
download | unit-19b974674c1fdd8fc46eb0877d2a8ff8b794490d.tar.gz unit-19b974674c1fdd8fc46eb0877d2a8ff8b794490d.tar.bz2 |
Tests: fixed tests to run as root.
- The mode of testdir was changed to allow reading from other users/groups.
- The java multipart test now uploads the file into an app writable dir.
- The build directory was made readable for other users.
- The python environment test now uses the HOME env var instead of PWD
because the latter is not set by the root shell (/bin/sh) by default.
- The node `node_modules` directory now is copied into the `testdir` instead
of using symlinks.
Diffstat (limited to 'test/unit/main.py')
-rw-r--r-- | test/unit/main.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/test/unit/main.py b/test/unit/main.py index 094fdb0e..ea6afd7f 100644 --- a/test/unit/main.py +++ b/test/unit/main.py @@ -1,6 +1,7 @@ import os import re import sys +import stat import time import fcntl import shutil @@ -20,6 +21,9 @@ class TestUnit(unittest.TestCase): pardir = os.path.abspath( os.path.join(os.path.dirname(__file__), os.pardir, os.pardir) ) + is_su = os.geteuid() == 0 + uid = os.geteuid() + gid = os.getegid() architecture = platform.architecture()[0] system = platform.system() maxDiff = None @@ -188,13 +192,19 @@ class TestUnit(unittest.TestCase): self.stop_processes() def _run(self): - self.unitd = self.pardir + '/build/unitd' + build_dir = self.pardir + '/build' + self.unitd = build_dir + '/unitd' if not os.path.isfile(self.unitd): exit("Could not find unit") self.testdir = tempfile.mkdtemp(prefix='unit-test-') + self.public_dir(self.testdir) + + if oct(stat.S_IMODE(os.stat(build_dir).st_mode)) != '0o777': + self.public_dir(build_dir) + os.mkdir(self.testdir + '/state') print() @@ -328,6 +338,15 @@ class TestUnit(unittest.TestCase): return ret + def public_dir(self, path): + os.chmod(path, 0o777) + + for root, dirs, files in os.walk(path): + for d in dirs: + os.chmod(os.path.join(root, d), 0o777) + for f in files: + os.chmod(os.path.join(root, f), 0o777) + @staticmethod def _parse_args(): parser = argparse.ArgumentParser(add_help=False) |