clients/tests: workaround unexpected output for offline test

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.
This commit is contained in:
Thomas Haller 2022-04-20 15:11:15 +02:00
parent e27152f315
commit 6aef83a556
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 7 additions and 1 deletions

View file

@ -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

View file

@ -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 = [