diff options
author | Thomas Haller <thaller@redhat.com> | 2020-03-23 13:20:35 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-03-23 13:30:13 +0100 |
commit | 27c0d9d8b7d10512057698e716fd0d1030cf6212 (patch) | |
tree | 98ef4e03d1fc1498c1791b055b07443fe6b2dbe2 | |
parent | c5365ca48286758c926074fb26b31c1401e8d9d3 (diff) | |
download | NetworkManager-27c0d9d8b7d10512057698e716fd0d1030cf6212.tar.gz |
clients/tests: comment return code by signal in test output
Otherwise, we just see "returncode: -11", which isn't very clear.
By default, our test nmcli invocations should never exit by a signal.
Usually, when we encounter a signal, it indicates to a bug and a crash
during the test.
Print more information about the exit code.
returncode: -11 (SIGNAL SIGSEGV)
-rwxr-xr-x | clients/tests/test-client.py | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/clients/tests/test-client.py b/clients/tests/test-client.py index 2742824cee..a3c667c5f3 100755 --- a/clients/tests/test-client.py +++ b/clients/tests/test-client.py @@ -137,6 +137,43 @@ _UNSTABLE_OUTPUT = object() class Util: + _signal_no_lookup = { + 1: "SIGHUP", + 2: "SIGINT", + 3: "SIGQUIT", + 4: "SIGILL", + 5: "SIGTRAP", + 6: "SIGABRT", + 8: "SIGFPE", + 9: "SIGKILL", + 11: "SIGSEGV", + 12: "SIGSYS", + 13: "SIGPIPE", + 14: "SIGALRM", + 15: "SIGTERM", + 16: "SIGURG", + 17: "SIGSTOP", + 18: "SIGTSTP", + 19: "SIGCONT", + 20: "SIGCHLD", + 21: "SIGTTIN", + 22: "SIGTTOU", + 23: "SIGPOLL", + 24: "SIGXCPU", + 25: "SIGXFSZ", + 26: "SIGVTALRM", + 27: "SIGPROF", + 30: "SIGUSR1", + 31: "SIGUSR2", + } + + @classmethod + def signal_no_to_str(cls, signal): + s = cls._signal_no_lookup.get(signal, None) + if s is None: + return "<unknown %d>" % (signal) + return s + @staticmethod def python_has_version(major, minor = 0): return sys.version_info[0] > major \ @@ -807,10 +844,15 @@ class TestNmcli(NmTestBase): cmd = '$NMCLI %s' % (' '.join([Util.quote(a) for a in args[1:]])) cmd = Util.replace_text(cmd, replace_cmd) + if returncode < 0: + returncode_str = '%d (SIGNAL %s)' % (returncode, Util.signal_no_to_str(-returncode)) + else: + returncode_str = '%d' % (returncode) + content = ('location: %s\n' % (calling_location)).encode('utf8') + \ ('cmd: %s\n' % (cmd)).encode('utf8') + \ ('lang: %s\n' % (lang)).encode('utf8') + \ - ('returncode: %d\n' % (returncode)).encode('utf8') + ('returncode: %s\n' % (returncode_str)).encode('utf8') if len(stdout) > 0: content += ('stdout: %d bytes\n>>>\n' % (len(stdout))).encode('utf8') + \ stdout + \ |