From 6aef83a55641665486c00ab18539266af72f16ca Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 20 Apr 2022 15:11:15 +0200 Subject: [PATCH] clients/tests: workaround unexpected output for offline test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test calls "nmcli g" with a bogus D-Bus bus address. We expect a failure on stderr. On alpine:latest, the error however looks slightly different: b'size: 258\nlocation: src/tests/client/test-client.py:test_offline()/1\ncmd: $NMCLI g\nlang: C\nreturncode: 1\nstderr: 136 bytes\n>>>\nError: Could not create NMClient object: Key/Value pair 0, *invalid*, in address element *very:invalid* does not contain an equal sign.\n\n<<<\n' On ubuntu:16.04 and debian:9 we got: b"size: 258\nlocation: src/tests/client/test-client.py:test_offline()/1\ncmd: $NMCLI g\nlang: C\nreturncode: 1\nstderr: 136 bytes\n>>>\nError: Could not create NMClient object: Key/Value pair 0, 'invalid', in address element 'very:invalid' does not contain an equal sign.\n\n<<<\n" On fedora and most recent systemd we got: b'size: 258\nlocation: src/tests/client/test-client.py:test_offline()/1\ncmd: $NMCLI g\nlang: C\nreturncode: 1\nstderr: 136 bytes\n>>>\nError: Could not create NMClient object: Key/Value pair 0, ?invalid?, in address element ?very:invalid? does not contain an equal sign.\n\n<<<\n' This depends on the glib version (whether to print `%s', '%s', or ā€œ%sā€). Also, as we run the application with lang=C, so that libc (I think) replaces Unicode with an ASCII character. Here musl and glibc behave differently. Workaround by replace the unexpected text. --- .../client/test-client.check-on-disk/test_offline.expected | 2 +- src/tests/client/test-client.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tests/client/test-client.check-on-disk/test_offline.expected b/src/tests/client/test-client.check-on-disk/test_offline.expected index 1e95bfc4e6..f6f11ba443 100644 --- a/src/tests/client/test-client.check-on-disk/test_offline.expected +++ b/src/tests/client/test-client.check-on-disk/test_offline.expected @@ -5,7 +5,7 @@ lang: C returncode: 1 stderr: 136 bytes >>> -Error: Could not create NMClient object: Key/Value pair 0, ?invalid?, in address element ?very:invalid? does not contain an equal sign. +Error: Could not create NMClient object: Key/Value pair 0, 'invalid', in address element 'very:invalid' does not contain an equal sign. <<< size: 319 diff --git a/src/tests/client/test-client.py b/src/tests/client/test-client.py index 21fd583d8a..dee5c94c27 100755 --- a/src/tests/client/test-client.py +++ b/src/tests/client/test-client.py @@ -1725,6 +1725,12 @@ class TestNmcli(NmTestBase): self.call_nmcli( ["g"], extra_env=no_dbus_env, + replace_stderr=[ + Util.ReplaceTextUsingRegex( + r"Key/Value pair 0, [*?']invalid[*?'], in address element [*?']very:invalid[*?'] does not contain an equal sign", + "Key/Value pair 0, 'invalid', in address element 'very:invalid' does not contain an equal sign", + ) + ], ) replace_uuids = [