mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 08:18:03 +02:00
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)
This commit is contained in:
parent
c5365ca482
commit
27c0d9d8b7
1 changed files with 43 additions and 1 deletions
|
|
@ -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 + \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue