From 3ad7283ba329392f0032f7bf28fe854b7f2e9e3b Mon Sep 17 00:00:00 2001 From: Ramil Valitov Date: Thu, 17 Sep 2026 16:15:49 +0300 Subject: [PATCH] fix(test): make the client_mss config assertions actually test something MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit generate_telemt_config() takes a destination path and writes the TOML there — it does not print it. This test captured its stdout instead, so `cfg` was always empty and both config assertions were decided by that emptiness rather than by the generated config: - "client_mss omitted when off" passed *vacuously*: grep found nothing in an empty string, so it reported "absent" no matter what the product did, including when client_mss was emitted unconditionally. - "client_mss emitted when set to tspu" could never pass on any platform. Demonstration: against a product mutated to always emit `client_mss = "tspu"`, the old test produced byte-identical output to the unmutated product (8 tests, 1 failure both times). It had no signal. Write to a temp destination and grep that file, and add an explicit "config is written" assertion so that if generation ever fails the test fails loudly instead of passing vacuously again. Verified: the repaired test passes on Debian 12, Ubuntu 22.04/24.04, Alpine 3.20 and Fedora 41, and now fails correctly under both mutations (emission removed, and emission made unconditional) where the old test caught neither. --- tests/test_client_mss.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/test_client_mss.sh b/tests/test_client_mss.sh index fddd5c1..8f8a09e 100644 --- a/tests/test_client_mss.sh +++ b/tests/test_client_mss.sh @@ -41,9 +41,17 @@ echo "Telemt client_mss tests" assert_eq "out-of-the-box default CLIENT_MSS is empty" "" "$CLIENT_MSS" # 2. Config generation when CLIENT_MSS is empty (off) +# generate_telemt_config writes the TOML to a destination path — it does not print it. +# Capturing its stdout (as this test used to) yields an empty string, so `grep` on it +# found nothing and every assertion below was decided by that emptiness rather than by +# the generated config. The file-exists assertion exists so that if generation ever +# breaks, this test fails outright instead of passing vacuously again. CLIENT_MSS="" -cfg=$(generate_telemt_config) -if echo "$cfg" | grep -q 'client_mss'; then +dest_off="$TEST_TMPDIR/config-off.toml" +generate_telemt_config "$dest_off" >/dev/null 2>&1 +assert_eq "config is written when client_mss is off" "written" \ + "$([ -f "$dest_off" ] && echo written || echo missing)" +if grep -q 'client_mss' "$dest_off" 2>/dev/null; then assert_eq "client_mss omitted when off" "absent" "present" else assert_eq "client_mss omitted when off" "absent" "absent" @@ -51,8 +59,11 @@ fi # 3. Config generation when CLIENT_MSS="tspu" CLIENT_MSS="tspu" -cfg=$(generate_telemt_config) -if echo "$cfg" | grep -q 'client_mss = "tspu"'; then +dest_tspu="$TEST_TMPDIR/config-tspu.toml" +generate_telemt_config "$dest_tspu" >/dev/null 2>&1 +assert_eq "config is written when client_mss is tspu" "written" \ + "$([ -f "$dest_tspu" ] && echo written || echo missing)" +if grep -q 'client_mss = "tspu"' "$dest_tspu" 2>/dev/null; then assert_eq "client_mss emitted when set to tspu" "present" "present" else assert_eq "client_mss emitted when set to tspu" "present" "absent"