# BNC regression tests Run BNC headless on fixed inputs and compare its outputs with stored reference outputs. No network access is needed. ``` tests/run_tests.py # all cases (parallel), exit code 1 on failure tests/run_tests.py ssr_ rinex_qc # only cases whose name contains a pattern tests/run_tests.py --list tests/run_tests.py --update NAME # accept current output as new reference # (removes references of outputs no longer produced) ``` Build `./bnc` first. Each case runs in `tests/work//`, which has an `Input` symlink to `Example_Configs/Input` and an empty `Output` directory, so the example configurations run unchanged. On a failure, the full diff is at `tests/work//.diff` and the exact command line is in `tests/work//command.txt`. ## Layout | Path | Content | |---|---| | `run_tests.py` | runner; the `case.json` format is documented in its header | | `cases//case.json` | config, extra `-key` arguments, raw capture, outputs to compare | | `cases//expected/*.gz` | normalised reference outputs | | `data/*.raw` | short raw captures (BNC `rawOutFile` format) replayed via `--file` | | `data/rnx402_MO.rnx`, `data/rnx402_MN.rnx` | crafted RINEX 4.02 files: 3 BRUX epochs with receiver clock offset, pico-sec digits and `RCV CLOCK OFFS APPL`; GLONASS FDMA/L1OC/L3OC ephemerides and STO/EOP/ION examples of the RINEX 4.02 document (ION with subtypes KLOB/NEQN, ION J CNVX without subtype) | | `data/rnx402_events_MO.rnx` | `data/rnx402_MO.rnx` with event records (flags 1-6, blank epochs, pico-sec event epoch, events after the last epoch) and further header records (SYS / SCALE FACTOR, DCBS/PCVS APPLIED, CENTER OF MASS: XYZ, PRN / # OF OBS, an unknown record) | | `data/nav402_p?_MN.rnx`, `data/nav305_?_MN.rnx`, `data/nav211_?.26n` | navigation files for the concatenation: 3 overlapping pieces of the 1 h BRUX RINEX 4.01 file (with STO/ION records); 2 RINEX 3.05 and 2 RINEX 2.11 GPS files (converted by BNC) with added IONOSPHERIC CORR/TIME SYSTEM CORR/LEAP SECONDS resp. ION ALPHA/ION BETA/DELTA-UTC records, differing between the files | | `data/nav401_gps_MN.rnx` | GPS LNAV records of the daily BRUX RINEX 4.01 file incl. ION and STO records (conversion to RINEX 3/2 header records) | | `data/obs_p1_MO.rnx`, `data/obs_p2_MO.rnx` | epochs 0-14 and 10-24 of the 1 h BRUX observation file, the second with another receiver firmware and antenna | | `data/nav402_navic_MN.rnx` | NavIC STO IRUT records for UTC(NPLI) and UTCIRN (RINEX 4.02 examples) and one GPS ephemeris | | `tools/fakecaster.py` | local Ntrip caster recording an upload as a BNC raw file (case key `fakecaster`); optionally TLS and serving a stream | | `tools/bncraw.py` | `info` (streams, time span, RTCM3 message types), `slice` and `crs` (decode 1300/1301/1302) for raw captures | | `tools/mkcrafted.py` | writes `data/crafted_limits.raw`: crafted frames at the upper field limits | | `tools/ssr_harness.sh` | builds `tools/ssr_harness.cpp` with the SSR decoders under ASan/UBSan and runs it | | `tools/ssl_check.py` | TLS checks of the Ntrip 2s client and upload (not part of `run_tests.py`) | | `tools/net_check.py` | UDP/RTP sender filter and upload status checks on loopback (not part of `run_tests.py`) | | `tools/cred_check.py` | credentials files (`~/.netrc`, BNC format) for download and upload (not part of `run_tests.py`) | | `tools/logcheck.py` | structured logfile: JSON/logfmt syntax, both formats equal, `time` = classic GPS time stamp - leap seconds, optional `epoch`, `msg` = classic logfile | | `work/` | scratch output, not versioned | Before comparing, the runner removes content that changes with each run or BNC version: wall-clock log prefixes, `Start BNC` lines, the BNC version string, the RINEX `PGM / RUN BY / DATE` line, and the `Run by`/`Date` lines in reqc logs. ## Cases * File-based examples: `rinex_concat`, `rinex_qc`, `sp3_compare`, `ppp_postproc`, `ppp_osm` (04, 05, 21, 11, 12), plus the command-line variants `*_cli` and `sp3_compare_exclude` (scripts 24, 23, 28). The QC cases use the 1 h BRUX files instead of the full-day file. * `rinex_edit_minele`: Edit/Concatenate with a 10 deg elevation mask (1 h BRUX files), covering the ephemeris selection for the elevation mask. * `rinex_edit_v402`: Edit/Concatenate of `data/rnx402_*` to RINEX 4.02 at 0.1 sec sampling: epoch clock offset and pico-sec digits kept unchanged, no `SYS / PHASE SHIFT` records (deprecated in RINEX 4), L1OC/L3OC records complete (incl. Beta, AODE/AODC order), non-EPH records skipped. * `rinex_edit_v402_to_v2`: the same observations as RINEX 2.11 (clock offset F12.9 in columns 69-80; the pico-sec digits cannot be written there). * `rinex_edit_v402_events`, `rinex_edit_v402_events_to_v2`: Edit/Concatenate of `data/rnx402_events_MO.rnx` to RINEX 4.02 and 2.11: events kept (in RINEX 2 without records not existing there, and without changes of the observation types), scaled observations, header records kept, TIME OF LAST OBS, # OF SATELLITES and PRN / # OF OBS of the written file. * `rinex_nav_concat_v4`, `rinex_nav_concat_v4_to_v3`, `rinex_nav_concat_v3`, `rinex_nav_concat_v3_to_v4`, `rinex_nav_concat_v2`: navigation file concatenation: duplicates removed, RINEX 4 STO/ION records and header records (first one of a kind) kept, records not convertible to the output version reported in the log; `rinex_nav_concat_v4` equals the edit of the original 1 h file. * `rinex_nav_v4_gps_to_v2`, `rinex_nav_v4_gps_to_v3`, `rinex_nav_v2_to_v3`: conversion of RINEX 4 ION/STO records to RINEX 2/3 header records (ION ALPHA/BETA, DELTA-UTC resp. IONOSPHERIC CORR, TIME SYSTEM CORR) and of RINEX 2 to RINEX 3 header records; `rinex_nav_concat_v4_to_v3` also covers BDS (time mark, GEO/IGSO priority), Galileo, GLONASS. * `rinex_nav_navic_irut_to_v3`: of two NavIC IRUT offsets, the one to UTCIRN becomes TIME SYSTEM CORR IRUT in RINEX 3. * `rinex_edit_long_marker`: marker name longer than 9 characters kept in RINEX 4. * `rinex_concat_overlap`: overlapping observation files (epochs written once) with header changes between the files (event flag 4). * Stream replays of the real-time examples (`replay_*`), all from the 5 min slice `data/wtzr_cnes_5min.raw` (BCEP00BKG0, WTZR00DEU0, SSRA00CNE1): `replay_rinex_obs` (01, skeleton not mandatory as there is no caster offline), `replay_rinex_eph` (02), `replay_feed_engine` (07, IP port disabled) and `replay_save_sp3` (14, with SSRA00CNE1 instead of SSRA00BKG1). * `replay_rinex_eph_perstream`: 02 with 'File per stream' on `data/eph_perstream_260930_4min.raw` (ephemeris messages of BCEP00BKG0, SSRA00EUH0, FFMJ00DEU0, WTZR00DEU0 cut from the merged capture): one RINEX 4 navigation file per stream. * `replay_eph_cutover`: 02 on `data/eph_cutover_261023_20min.raw` (GPS ephemerides of BCEP00BKG0, BCEP01JPL0, BCEP00CAS0, 23 Oct 2026 01:05-01:25): the G17 upload within the fit interval (IOD 4, TOC 01:59:44, 16 s before IOD 148) is accepted, the data set mixed from both uploads (IODE 4, IODC 148) rejected. * `replay_save_sp3_has`: 14 with Galileo HAS (SSRA00EUH0) only; its epochs are off the SP3/CLK sampling grid and are written at the preceding grid epoch. * Real-time PPP replays (`ppp_rt_*`) from 11 min slices of the CNES and WHU captures (`data/wtzr_cnes_11min.raw`, `data/wtzr_whu_11min.raw`): `ppp_rt_float` (08), `ppp_rt_quickstart` (10, NMEA port disabled), `ppp_rt_ar_cnes` (29) and `ppp_rt_ar_whu` (30), compared exactly. * `log_structured`: 10 as `ppp_rt_quickstart` with the structured logfile, JSON in the main run and logfmt in the post step `lf`; `tools/logcheck.py` compares both formats with each other and their `msg` with the classic log. The latency events (`stream_latency`) are not covered: in `--file` replay the latency check uses the wall clock, so no latencies are computed. * `ppp_rt_net` (09, two stations) and `ppp_rt_has` (13, Galileo HAS via SSRA00EUH0) from `data/merged_260930_11min.raw`, a slice of two simultaneous recordings merged by time (BCEP00BKG0, WTZR00DEU0, FFMJ00DEU0, SSRA00CNE1, SSRA00EUH0). * Combination (`combi`, `combi_ppp`; 17 and 18 unchanged) from `data/combi_261005_11min.raw` (SSRA00BKG1, SSRA00CNE1, SSRA00CHC1, BCEP00BKG0, FFMJ00DEU0), upload to the caster disabled, SP3/CLK/BIA written to files. * `combi_multi`: 17 with the 7 ACs of an operational combination (BKG1, CHC1, CNE1, GFZ1, GMV0, NRC0, SHA1; IGS-SSR and RTCM-SSR) from `data/combi_multi_261002_5min.raw`. Covers legacy and erroneous epoch encodings, missing reference-signal biases, inconsistent biases and persistent outliers. The longest case (about 4 min). * `combi_bds_level`: 17 with the six inputs of the IGS03 combination (CAS01, CHC00, GMV00, CNE00, BKG00, SHA01 without BDS; 10 s) from `data/combi_bds_level_261121_13min.raw` (21 Nov 2026 18:50-19:03, cut from the SSR QC recording). At 19:01:00 the master AC CAS01 refers C14 to an IOD not yet received from BCEP00BKG0, C14 is missing in one epoch; the level of the combined clocks must not jump (before: all BDS clocks -0.92 m and back). `tools/clkjumps.py` lists common clock jumps > 0.1 m of the CLK file. * `combi_refsig`: `combi` with non-default reference signals (`ssrRefSignals C:1P&5P`): BDS clock referral and code biases from the Bias SINEX file on C1P/C5P (generic DCB derivation), CLK/BIA and the combination log compared. * Upload (`upload_*`; 16, 19, 20) from `data/upload_rtnet_5min.raw` (RTNET engine output + BCEP00BKG0): BNC uploads to a local fake caster (`tools/fakecaster.py`, Ntrip 1/2, chunked), and a `post` step decodes the received stream again: `upload_rtnet` (IGS-SSR encoding, SP3/CLK/BIA files, decoded `.ssr`, CRS messages 1300/1302 decoded by `bncraw.py crs` in a `tool` post step), `upload_eph` (RTCM3 ephemerides to RINEX nav) and `upload_raw` (raw forwarding to RINEX nav). `upload_rtnet_rtcm` encodes the same input to RTCM-SSR (message numbers 1057-1068, 1240-1270) and decodes it again. `upload_eph_vote` replays the ephemerides of 89 uploader input streams (`data/eph_vote_261118_20min.raw`, 18 Nov 2026 17:43-18:03, BCEP00BKG0 removed) and compares the log with the majority vote replacements (e.g. R06/R19/R20 Bn = 1 from RIO200ARG0); the uploaded stream depends on the wall-clock timing and is not compared. `eph_out_of_range` replays 6 min of the same input with a G39 copy of the G24 ephemerides of 3 stations (`tools/mk_eph_g39.py`): the G39 data set is logged once as RINEX record, the RINEX navigation file and the uploaded stream (`bncraw.py ephsats`) have no G39. * SSR decoding (`ssr_*`): 3 min slices of real streams replayed through `03_BrdcCorr.bnc`. They compare the `.ssr` files and the `BNC_DEBUG_SSR` stderr trace. On a build without that trace, the trace comparison is reported as SKIP. * `ssr_igs_SSRA00CNE1`: IGS-SSR 4076, `SsrCorrIgs` * `ssr_rtcm_SSRA00CNE0`, `ssr_rtcm_WHU1_OSBC`: RTCM 1059-1270; these test whichever class `RTCM3Decoder.cpp` selects for non-4076 SSR. * `ssr_weekchange`: 2 min across the GPS week change (SSRA00CNE1, SSRA00CHC1); corrections of Saturday received after midnight must keep their epochs. * `ssr_qc`, `ssr_qc_select`: SSR QC (31_SsrQC, one file per stream, 5 min interval; all streams resp. `ssrQcStreams SSRA00CNE1,SSRA00GMV0`) of the 7 AC streams of `data/combi_multi_261002_5min.raw`. `ssr_qc_bias` adds the CAS DCB file as 'QC Bias File' (code bias check against the other ACs and the file). * `ssr_qc_ephmount`: `ssr_qc` with the general option 'Ephemeris streams' empty (31_SsrQC.bnc has BCEP00BKG0): the ephemerides contained in SSRA00GMV0 are used too, so the GPS uploads within the fit interval of G10, G22, G29 (only in SSRA00GMV0 on 2 Oct) are found. * `ssr_qc_iod`: IOD check of the SSR QC on `data/qc_iod_261015.raw` (made with `tools/mk_qc_iod.py` from the QC capture of 15 Oct 2026: BCEP00BKG0 with each message only at its first reception from 00:00, SSRA00WHU1/GMV1/CNE1 01:55-02:10): IODs received only later (WHU1), never received (GMV1 G16, upload not in BCEP00BKG0), ephemeris outside its validity (CNE1 GLONASS). * `ssr_qc_outage`: common outage of the input on `data/ssr_qc_outage_261002_5min.raw` (`data/combi_multi_261002_5min.raw` without the chunks of all 7 AC streams 11:43:00-11:44:00, BCEP00BKG0 kept, and without those of SSRA00CNE1 11:44:30-11:45:10): the outage is listed in each report and not counted as gap, the own gap of CNE1 is. The IOD switch delays (after the reception by BNC, BDS also after TOC) appear in all SSR QC cases. * `ssr_qc_bad_epoch`: `data/ssr_qc_bad_epoch_261122_10min.raw` (22 Nov 2026 00:10:30-00:21, cut from the QC capture: BCEP00BKG0, SSRA00SHA1, SSRA00CNE1, SSRA00GMV0): SSRA00SHA1 sends a GLONASS epoch 11758 s ahead; its 159 corrections are not used (counted in the report), the 5 min reports continue normally. * `ssr_qc_has`: `data/merged_260930_11min.raw` with 31_SsrQC (SSRA00EUH0 Galileo HAS and SSRA00CNE1): the HAS code biases keep their reference time 12876 s before reception and are still evaluated (bias epochs are only rejected more than 900 s in the future). * `ssr_qc_glo_ln`: GLONASS health flag ln on `data/glo_ln_261015_1h.raw` (BCEP00BKG0 GLONASS ephemerides 09:40-10:40 and SSRA00GMV0 GLONASS corrections 09:55-10:40 of 15 Oct 2026, merged from two `bncraw.py slice` outputs; 'Ephemeris streams' BCEP00BKG0): the R14 data sets from tb 13:15 Moscow time on have ln = 1 with Bn = 0, Cn = 1 and are unhealthy (ICD 5.1, 5.3). * `ssr_qc_phase_bias`: phase bias indicators and Melbourne-Wuebbena check on `data/combi_multi_261002_5min.raw` (one MW epoch, 11:45): CHC1, CNE1, SHA1 (IGS-SSR) and NRC0 (old RTCM-SSR); MW consistency indicator 1 only for CNE1/NRC0, CNE1 vs NRC0 GPS 0.14 cycles (G01 G04 G11 G23 G28 0.2-0.3 cycles, verified by hand from the decoded .ssr files), all other pairs ~0.25 cycles; CNE1 BeiDou phase biases with integer indicator 0. * `ssr_qc_apc_com`: code biases of the APC stream SSRA00GMV0 vs. the CoM stream SSRC00GMV0 (old RTCM-SSR) on `data/apc_com_gmv_261015_10min.raw` (with BCEP00BKG0, 15 Oct 2026 10:00-10:10, `bncraw.py slice` of the QC capture), 'QC ANTEX File' igs20.atx: the GPS/Galileo/BDS biases of the APC stream are shifted by the PCO differences z(f) - z(ref) (residuals 2/3/14 mm, verified by hand from the decoded .ssr files: C06 C6I -0.42 m = z(B3I) - z(B1I)), GLONASS biases equal. * `decoder_limits`: crafted, CRC-valid frames from `tools/mkcrafted.py` using the largest values the formats allow: VTEC with degree/order 16 (IGS-SSR 4076/201 and RTCM-SSR 1264, 2 and 4 layers) and RTCM 1300/1301/1302 with 31-character names, listed by the RTCM scan in the log. The coefficients are C(d,o) = (100*d+o)/200 TECU and S = -C, both `.ssr` files are identical apart from the station ID. These frames overflowed the coefficient and name arrays; the 4-layer VTEC crashed BNC. Also two RTCM 1033: a complete one and one whose receiver descriptor length runs beyond the message (rejected; before, stale buffer content was logged). * `rawfile_hostile`: raw file with hostile chunk headers from `tools/mkcrafted.py --rawfile`: the station ID `../ESCAPE0` must give `Output/.._ESCAPE0_*.ssr` (no file outside the output directory), a chunk header announcing 2000000000 bytes is rejected with a log message. ## Sanitizer check of the SSR decoders ``` tests/tools/ssr_harness.sh # crafted_limits.raw tests/tools/ssr_harness.sh tests/data/*.raw # real captures ``` In BNC all SSR target structs are members of one `RTCM3coDecoder` object, so a write beyond one struct corrupts the next member without any AddressSanitizer report. The harness decodes every frame with all three format classes into separately allocated structs, so ASan reports it. It also covers the new RTCM-SSR metadata (message 60 in `crafted_limits.raw`: 7 entries with additional parameters of 40 and 0 bits, and 31 entries, which must be rejected) and satellite antenna messages (BDS with mask bits in all four 16-bit quarters, GPS with shared blocks), which `RTCM3Decoder.cpp` does not dispatch at present. Every decoded VTEC, metadata and antenna message is encoded again with the `Make*` function of the same class and decoded once more; the result must be identical, for the antenna messages also the bytes. Exit code 0 only without sanitizer errors and differences. ## TLS check ``` tests/tools/ssl_check.py [--bnc PATH] ``` Runs BNC against `tools/fakecaster.py` with TLS on port 443 (BNC uploads with Ntrip 2s always to 443) inside an unprivileged user and network namespace (`unshare -rn`), with a test CA, server and client certificates created by openssl in `work/ssl_check/`. Checks for upload and download: certificate of an unknown CA rejected, accepted with the CA in `sslCaCertPath`, accepted with `sslIgnoreErrors` and the ignored errors logged; for upload also a certificate for another host name (rejected) and a client certificate required by the caster, with and without `sslIgnoreErrors`. Takes about 3 min. ## Network check ``` tests/tools/net_check.py [--bnc PATH] ``` Runs BNC live against fake servers on loopback addresses (no root needed). A second sender on another address sends spoofed datagrams to BNC's port: in the modes 'U' (Ntrip 2 UDP) and 'R' (RTSP/RTP) and in 'UN' with a sender address in the URL, BNC's raw output must contain only the server's data; 'UN' with 127.0.0.1 accepts any sender, as before. An Ntrip 1 caster sending an endless response header is cut off, a normal Ntrip 1 stream still works. An upload answered with `HTTP/1.1 401` and a header containing `200` must be reported as broken. Takes about 2 min. ## Credentials check ``` tests/tools/cred_check.py [--bnc PATH] ``` BNC against `tools/fakecaster.py --auth user:password` (other credentials rejected), each scenario with its own `HOME`: password in the configuration file (hint logged), `~/.netrc` with two users for the host, `$NETRC` with `machine host:port` preferred, BNC format file (`credentialsFile`) with exact port preferred over `*` and a quoted password, URL without user (no credentials sent), user without entry, `~/.netrc` readable for others and the netrc `default` entry (not used), Ntrip 1 download, Ntrip 2 upload and Ntrip 1 upload without user. Takes about 2 min. ## Adding a replay case ``` tests/tools/bncraw.py info capture.raw tests/tools/bncraw.py slice capture.raw tests/data/new.raw --stations SSRA00XYZ0 \ --start 2026-09-28T12:00:00 --end 2026-09-28T12:03:00 mkdir tests/cases/new && $EDITOR tests/cases/new/case.json # copy an ssr_* case tests/run_tests.py --update new ``` Before accepting a reference with `--update`, check it by hand; for decoder cases, hand-decode the raw bits. The reference records what BNC does, not what is correct. ## Reproducibility of replays In batch post-processing (`--file`), BNC delivers decoded ephemerides and corrections synchronously to the PPP (`t_bncCore::decoderConnectionType`) and starts reading only after all PPP instances are connected (`t_pppThread::waitUntilReady`). Replays are therefore reproducible run to run, including PPP with ambiguity resolution. Live operation is not affected.