Changeset 11127 in ntrip for trunk/BNC/tests/run_tests.py


Ignore:
Timestamp:
Oct 24, 2026, 11:15:22 PM (32 hours ago)
Author:
stuerze
Message:

test suite extended regardiing security aspects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/tests/run_tests.py

    r11069 r11127  
    3030               {"dir" (subdirectory of the work dir), "config", "raw"
    3131                (relative to the work dir), "args", "exit_code", "timeout"};
    32                outputs may refer to their files as "<dir>/Output/..."
     32               outputs may refer to their files as "<dir>/Output/...";
     33               instead of a BNC run, {"dir", "tool": [script in tools/, args]}
     34               runs a Python tool in the work directory, stdout to <dir>/stdout.txt
    3335
    3436BNC runs in tests/work/<name>/, which contains an "Input" symlink to
    … …  
    178180
    179181
     182def run_tool(work, spec):
     183    """Run tools/<script> with args in the work directory, stdout to
     184    <dir>/stdout.txt. Returns the exit code or None on timeout."""
     185    outdir = os.path.join(work, spec["dir"])
     186    os.makedirs(outdir, exist_ok=True)
     187    cmd = [sys.executable, "-I", os.path.join(TESTS, "tools", spec["tool"][0])] + spec["tool"][1:]
     188    with open(os.path.join(outdir, "stdout.txt"), "wb") as out:
     189        try:
     190            return subprocess.run(cmd, cwd=work, stdout=out, stderr=subprocess.STDOUT,
     191                                  timeout=spec.get("timeout", 600)).returncode
     192        except subprocess.TimeoutExpired:
     193            return None
     194
     195
    180196def run_case(name, bnc, update):
    181197    res = Result(name)
    … …  
    217233    # in its own subdirectory of the work directory, raw relative to work/
    218234    for post in case.get("post", []):
    219         pcode = run_bnc(bnc, os.path.join(work, post["dir"]), post, work)
     235        if "tool" in post:
     236            pcode = run_tool(work, post)
     237        else:
     238            pcode = run_bnc(bnc, os.path.join(work, post["dir"]), post, work)
    220239        if pcode is None or pcode != post.get("exit_code", 0):
    221240            res.fail("post step %s: exit code %s" % (post["dir"], pcode))
    … …  
    250269        expfile = os.path.join(expdir, ref + ".gz")
    251270        if update:
     271            if spec.get("debug_trace") and not actual.strip() and os.path.exists(expfile):
     272                # build without BNC_DEBUG_SSR: keep the existing trace reference
     273                written.add(os.path.basename(expfile))
     274                res.skip("%s: no BNC_DEBUG_SSR trace in this build, reference kept" % ref)
     275                continue
    252276            write_expected(expfile, actual)
    253277            written.add(os.path.basename(expfile))
Note: See TracChangeset for help on using the changeset viewer.