This commit is contained in:
drindhauser
2020-02-28 12:34:01 +01:00
parent 9c0b1f98b0
commit 75ba3d012c
2 changed files with 125 additions and 48 deletions

View File

@@ -12,6 +12,7 @@ from coredump_uploader import Thread
from coredump_uploader import Stacktrace
from coredump_uploader import get_threads
from coredump_uploader import signal_name_to_signal_number
from coredump_uploader import get_stacktrace
def test_code_id_to_debug_id():
@@ -168,6 +169,7 @@ def test_image_to_json():
"debug_id": None,
"code_id": "b417c0ba7cc5cf06d1d1bed6652cedb9253c60d0",
"code_file": "/lib/x86_64-linux-gnu/libc.so.6",
"arch": "",
}
@@ -246,9 +248,7 @@ Thread 3 (Thread 0x5846 (LWP 40)):
],
)
def test_get_threads(gdb_output):
thread_list, exit_signal, stacktrace, crashed_thread_id = get_threads(
gdb_output, True
)
thread_list, exit_signal, stacktrace, crashed_thread_id = get_threads(gdb_output)
assert exit_signal == "SIGSEGV"
assert thread_list[2].to_json() == {
"id": "1",
@@ -326,3 +326,45 @@ def test_get_threads(gdb_output):
"registers": {},
}
assert crashed_thread_id == "1"
@pytest.mark.parametrize(
"gdb_output",
[
"""
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...done.
[New LWP 1335]
Core was generated by `./a.out'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x000056416d5c760a in crashing_function () at ./test.c:3
3 *bad_pointer = 1;
(gdb) bt
#0 0x000056416d5c760a in crashing_function () at ./test.c:3
#1 0x000056416d5c761c in main () at ./test.c:7
(gdb) quit"""
],
)
def test_get_stacktrace(gdb_output):
stacktrace, exit_signal = get_stacktrace(gdb_output)
assert exit_signal == "SIGSEGV"
assert stacktrace.to_json() == {
"frames": [
{
"filename": "./test.c",
"function": "crashing_function",
"instruction_addr": "0x000056416d5c760a",
"lineno": 3,
"package": None,
},
{
"filename": "./test.c",
"function": "crashing_function",
"instruction_addr": "0x000056416d5c760a",
"lineno": 3,
"package": None,
},
],
"registers": {},
}