Changeset 11060 in ntrip for trunk/BNC/tests/run_tests.py
- Timestamp:
- Oct 1, 2026, 5:35:37 PM (8 days ago)
- File:
-
- 1 edited
-
trunk/BNC/tests/run_tests.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/tests/run_tests.py
r11055 r11060 24 24 debug_trace true for BNC_DEBUG_SSR stderr traces: reported as 25 25 SKIP instead of FAIL if the build has no trace output 26 fakecaster optional local Ntrip caster for an upload during the run: 27 {"port", "out" (raw file, relative to the work dir), "sta", 28 "time" (epoch stamped on the raw file), "timeout"} 29 post optional list of further BNC runs after the main run, each 30 {"dir" (subdirectory of the work dir), "config", "raw" 31 (relative to the work dir), "args", "exit_code", "timeout"}; 32 outputs may refer to their files as "<dir>/Output/..." 26 33 27 34 BNC runs in tests/work/<name>/, which contains an "Input" symlink to … … 146 153 147 154 155 def run_bnc(bnc, workdir, spec, rawBase): 156 """Run BNC once in workdir (created with Input link and Output dir); spec 157 holds config, optional raw (relative to tests/, or to rawBase if given), 158 args and timeout. Returns the exit code or None on timeout.""" 159 os.makedirs(os.path.join(workdir, "Output"), exist_ok=True) 160 if not os.path.exists(os.path.join(workdir, "Input")): 161 os.symlink(os.path.join(ROOT, "Example_Configs", "Input"), os.path.join(workdir, "Input")) 162 cmd = [bnc, "--nw", "--platform", "offscreen", "--conf", resolve(ROOT, spec["config"])] 163 if spec.get("raw"): 164 cmd += ["--file", resolve(rawBase or TESTS, spec["raw"])] 165 cmd += spec.get("args", []) 166 env = dict(os.environ, QT_QPA_PLATFORM="offscreen", LC_ALL="C", TZ="UTC") 167 with open(os.path.join(workdir, "stdout.txt"), "wb") as out, \ 168 open(os.path.join(workdir, "stderr.txt"), "wb") as err: 169 try: 170 code = subprocess.run(cmd, cwd=workdir, stdout=out, stderr=err, env=env, 171 timeout=spec.get("timeout", 600)).returncode 172 except subprocess.TimeoutExpired: 173 code = None 174 with open(os.path.join(workdir, "command.txt"), "w") as f: 175 f.write(" ".join(cmd) + "\n") 176 return code 177 178 148 179 def run_case(name, bnc, update): 149 180 res = Result(name) … … 153 184 154 185 shutil.rmtree(work, ignore_errors=True) 155 os.makedirs(os.path.join(work, "Output"))156 os.symlink(os.path.join(ROOT, "Example_Configs", "Input"), os.path.join(work, "Input"))157 158 cmd = [bnc, "--nw", "--platform", "offscreen",159 "--conf", resolve(ROOT, case["config"])]160 if case.get("raw"):161 cmd += ["--file", resolve(TESTS, case["raw"])]162 cmd += case.get("args", [])163 164 env = dict(os.environ, QT_QPA_PLATFORM="offscreen", LC_ALL="C", TZ="UTC")165 186 t0 = time.time() 166 with open(os.path.join(work, "stdout.txt"), "wb") as out, \ 167 open(os.path.join(work, "stderr.txt"), "wb") as err: 187 188 # Optional local Ntrip caster receiving an upload (see tools/fakecaster.py) 189 fc = case.get("fakecaster") 190 fcProc = None 191 if fc: 192 os.makedirs(os.path.join(work, "Output")) 193 fcProc = subprocess.Popen( 194 [sys.executable, os.path.join(TESTS, "tools", "fakecaster.py"), 195 "--port", str(fc["port"]), "--out", os.path.join(work, fc["out"]), 196 "--sta", fc.get("sta", "CLOCK"), "--time", fc["time"], 197 "--timeout", str(fc.get("timeout", 10))], 198 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 199 fcProc.stdout.readline() # "listening" 200 201 code = run_bnc(bnc, work, case, "") 202 if fcProc: 168 203 try: 169 proc = subprocess.run(cmd, cwd=work, stdout=out, stderr=err, env=env, 170 timeout=case.get("timeout", 600)) 171 code = proc.returncode 204 fcProc.communicate(timeout=fc.get("timeout", 10) + 60) 172 205 except subprocess.TimeoutExpired: 173 code = None 174 res.seconds = time.time() - t0 175 with open(os.path.join(work, "command.txt"), "w") as f: 176 f.write(" ".join(cmd) + "\n") 206 fcProc.kill() 207 res.fail("fake caster did not finish") 177 208 178 209 if code is None: … … 181 212 if code != case.get("exit_code", 0): 182 213 res.fail("exit code %d, expected %d" % (code, case.get("exit_code", 0))) 214 215 # Optional further BNC runs, e.g. decoding the uploaded stream; each runs 216 # in its own subdirectory of the work directory, raw relative to work/ 217 for post in case.get("post", []): 218 pcode = run_bnc(bnc, os.path.join(work, post["dir"]), post, work) 219 if pcode is None or pcode != post.get("exit_code", 0): 220 res.fail("post step %s: exit code %s" % (post["dir"], pcode)) 221 res.seconds = time.time() - t0 183 222 184 223 # Collect (reference name, actual file, spec) triples
Note:
See TracChangeset
for help on using the changeset viewer.
