コード例 #1
0
ファイル: test.py プロジェクト: wmitros/scylla
 def __init__(self, test_no, shortname, args, suite, mode, options):
     super().__init__(test_no, shortname, suite, mode, options)
     self.path = os.path.join("build", self.mode, "test", self.name)
     self.args = shlex.split(args) + UnitTest.standard_args
     if self.mode == "coverage":
         self.env = coverage.env(self.path)
     else:
         self.env = dict()
コード例 #2
0
ファイル: test.py プロジェクト: psarna/scylla
 def __init__(self, path, cfg, options, mode):
     super().__init__(path, cfg, options, mode)
     self.scylla_exe = os.path.join("build", self.mode, "scylla")
     if self.mode == "coverage":
         self.scylla_env = coverage.env(self.scylla_exe,
                                        distinct_id=self.name)
     else:
         self.scylla_env = dict()
     self.scylla_env['SCYLLA'] = self.scylla_exe
コード例 #3
0
ファイル: test.py プロジェクト: wmitros/scylla
    def __init__(self, test_no, shortname, suite, mode, options):
        super().__init__(test_no, shortname, suite, mode, options)
        self.path = os.path.join(suite.path, shortname)
        self.xmlout = os.path.join(options.tmpdir, self.mode, "xml", self.uname + ".xunit.xml")
        self.args = ["--junit-xml={}".format(self.xmlout)]
        self.scylla_path = os.path.join("build", self.mode, "scylla")

        if self.mode == "coverage":
            self.env = coverage.env(self.scylla_path, distinct_id=self.suite.name)
        else:
            self.env = dict()
        self.env['SCYLLA'] = self.scylla_path
コード例 #4
0
ファイル: test.py プロジェクト: wmitros/scylla
 def __init__(self, test_no, shortname, suite, mode, options):
     super().__init__(test_no, shortname, suite, mode, options)
     # Path to cql_repl driver, in the given build mode
     self.path = os.path.join("build", self.mode, "test/tools/cql_repl")
     self.cql = os.path.join(suite.path, self.shortname + ".cql")
     self.result = os.path.join(suite.path, self.shortname + ".result")
     self.tmpfile = os.path.join(options.tmpdir, self.mode, self.uname + ".reject")
     self.reject = os.path.join(suite.path, self.shortname + ".reject")
     self.args = shlex.split("-c1 -m2G --input={} --output={} --log={}".format(
         self.cql, self.tmpfile, self.log_filename))
     self.args += UnitTest.standard_args
     self.is_executed_ok = False
     self.is_new = False
     self.is_equal_result = None
     self.summary = "not run"
     if self.mode == "coverage":
         self.env = coverage.env(self.path, distinct_id=self.id)
     else:
         self.env = dict()
コード例 #5
0
async def run_test(test, options, gentle_kill=False, env=dict()):
    """Run test program, return True if success else False"""

    with open(test.log_filename, "wb") as log:

        def report_error(error):
            msg = "=== TEST.PY SUMMARY START ===\n"
            msg += "{}\n".format(error)
            msg += "=== TEST.PY SUMMARY END ===\n"
            log.write(msg.encode(encoding="UTF-8"))

        process = None
        stdout = None
        logging.info("Starting test #%d: %s %s", test.id, test.path,
                     " ".join(test.args))
        UBSAN_OPTIONS = [
            "halt_on_error=1",
            "abort_on_error=1",
            f"suppressions={os.getcwd()}/ubsan-suppressions.supp",
            os.getenv("UBSAN_OPTIONS"),
        ]
        ASAN_OPTIONS = [
            "disable_coredump=0",
            "abort_on_error=1",
            "detect_stack_use_after_return=1",
            os.getenv("ASAN_OPTIONS"),
        ]
        try:
            log.write("=== TEST.PY STARTING TEST #{} ===\n".format(
                test.id).encode(encoding="UTF-8"))
            log.write("export UBSAN_OPTIONS='{}'\n".format(":".join(
                filter(None, UBSAN_OPTIONS))).encode(encoding="UTF-8"))
            log.write("export ASAN_OPTIONS='{}'\n".format(":".join(
                filter(None, ASAN_OPTIONS))).encode(encoding="UTF-8"))
            log.write("{} {}\n".format(test.path, " ".join(
                test.args)).encode(encoding="UTF-8"))
            log.write("=== TEST.PY TEST OUTPUT ===\n".format(
                test.id).encode(encoding="UTF-8"))
            log.flush()
            test.time_start = time.time()
            test.time_end = 0
            process = await asyncio.create_subprocess_exec(
                test.path,
                *test.args,
                stderr=log,
                stdout=log,
                env=dict(
                    os.environ,
                    UBSAN_OPTIONS=":".join(filter(None, UBSAN_OPTIONS)),
                    ASAN_OPTIONS=":".join(filter(None, ASAN_OPTIONS)),
                    # TMPDIR env variable is used by any seastar/scylla
                    # test for directory to store test temporary data.
                    TMPDIR=os.path.join(options.tmpdir, test.mode),
                    **coverage.env(test.path),
                    **env,
                ),
                preexec_fn=os.setsid,
            )
            stdout, _ = await asyncio.wait_for(process.communicate(),
                                               options.timeout)
            test.time_end = time.time()
            if process.returncode != 0:
                report_error('Test exited with code {code}\n'.format(
                    code=process.returncode))
                return False
            try:
                test.check_log(not options.save_log_on_success)
            except Exception as e:
                print("")
                print(test.name + ": " +
                      palette.crit("failed to parse XML output: {}".format(e)))
                # return False
            return True
        except (asyncio.TimeoutError, asyncio.CancelledError) as e:
            if process is not None:
                if gentle_kill:
                    process.terminate()
                else:
                    process.kill()
                stdout, _ = await process.communicate()
            if isinstance(e, asyncio.TimeoutError):
                report_error("Test timed out")
            elif isinstance(e, asyncio.CancelledError):
                print(test.name, end=" ")
                report_error("Test was cancelled")
        except Exception as e:
            report_error("Failed to run the test:\n{e}".format(e=e))
    return False