forked from getsentry/coredump-uploader
Update test_basic.py
This commit is contained in:
@ -12,6 +12,7 @@ from coredump_uploader import _image_re
|
||||
from coredump_uploader import Thread
|
||||
from coredump_uploader import Stacktrace
|
||||
from coredump_uploader import main
|
||||
from coredump_uploader import get_all_threads
|
||||
|
||||
|
||||
def test_code_id_to_debug_id():
|
||||
@ -147,14 +148,21 @@ def test_frame_to_json():
|
||||
|
||||
|
||||
def test_image_to_json():
|
||||
image = Image()
|
||||
image = Image(
|
||||
None,
|
||||
"0x7fb45a61f000",
|
||||
"4131552",
|
||||
None,
|
||||
"b417c0ba7cc5cf06d1d1bed6652cedb9253c60d0",
|
||||
"/lib/x86_64-linux-gnu/libc.so.6",
|
||||
)
|
||||
assert image.to_json() == {
|
||||
"type": "",
|
||||
"image_addr": "",
|
||||
"image_size": "",
|
||||
"debug_id": "",
|
||||
"code_id": "",
|
||||
"code_file": "",
|
||||
"type": None,
|
||||
"image_addr": "0x7fb45a61f000",
|
||||
"image_size": "4131552",
|
||||
"debug_id": None,
|
||||
"code_id": "b417c0ba7cc5cf06d1d1bed6652cedb9253c60d0",
|
||||
"code_file": "/lib/x86_64-linux-gnu/libc.so.6",
|
||||
}
|
||||
|
||||
|
||||
@ -166,7 +174,7 @@ def test_stacktrace_to_json():
|
||||
lineno=None,
|
||||
)
|
||||
stacktrace = Stacktrace()
|
||||
stacktrace.append_frame(frame.to_json())
|
||||
stacktrace.append_frame(frame)
|
||||
assert stacktrace.to_json() == {
|
||||
"frames": [
|
||||
{
|
||||
@ -176,16 +184,136 @@ def test_stacktrace_to_json():
|
||||
"lineno": None,
|
||||
"package": None,
|
||||
}
|
||||
]
|
||||
],
|
||||
"registers": {},
|
||||
}
|
||||
|
||||
|
||||
def test_thread_to_json():
|
||||
stacktrace = Stacktrace()
|
||||
thread = Thread(9, None, False, stacktrace.to_json())
|
||||
thread = Thread(9, "test", False, Stacktrace())
|
||||
assert thread.to_json() == {
|
||||
"stacktrace": {"frames": []},
|
||||
"stacktrace": {"frames": [], "registers": {}},
|
||||
"id": 9,
|
||||
"name": None,
|
||||
"name": "test",
|
||||
"crashed": False,
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"gdb_output",
|
||||
[
|
||||
"""
|
||||
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
|
||||
Copyright (C) 2018 Free Software Foundation, Inc.
|
||||
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
|
||||
and "show warranty" for details.
|
||||
This GDB was configured as "x86_64-linux-gnu".
|
||||
Type "show configuration" for configuration details.
|
||||
For bug reporting instructions, please see:
|
||||
<http://w ww.gnu.org/software/gdb/bugs/>.
|
||||
Find the GDB manual and other documentation resources online at:
|
||||
<http://www.gnu.org/software/gdb/documentation/>.
|
||||
For help, type "help".
|
||||
Type "apropos word" to search for commands related to "word"...
|
||||
Reading symbols from a.out...done.
|
||||
[New LWP 3421]
|
||||
Core was generated by `./a.out'.
|
||||
[Current thread is 1 (LWP 3421)]
|
||||
Program terminated with signal SIGSEGV, Segmentation fault.
|
||||
#0 0x000055931ccfe60a in crashing_function () at test.c:3
|
||||
3 *bad_pointer = 1;
|
||||
(gdb)
|
||||
Thread 1 (LWP 3421):
|
||||
#0 0x000055931ccfe60a in crashing_function () at test.c:3
|
||||
#1 0x000055931ccfe61c in main () at test.c:7
|
||||
|
||||
Thread 2 (LWP 45):
|
||||
#0 0x00005594565cfeab in test_function () at test_file.c:7
|
||||
#1 0x0000563f31ccfafc in test () at test_file.c:9
|
||||
|
||||
Thread 3 (Thread 0x5846 (LWP 40)):
|
||||
#0 0x00005594565cfeab in test_function () at test_file.c:7
|
||||
#2 0x000055a7df18760a in std::test::read () from /lib/x86_64-linux-gnu/libc.so.6
|
||||
(gdb) quit
|
||||
"""
|
||||
],
|
||||
)
|
||||
def test_get_all_threads(gdb_output):
|
||||
ls, exit_signal = get_all_threads(gdb_output)
|
||||
assert exit_signal == "SIGSEGV"
|
||||
assert ls[2].to_json() == {
|
||||
"id": "1",
|
||||
"name": "LWP 3421",
|
||||
"crashed": True,
|
||||
"stacktrace": {
|
||||
"frames": [
|
||||
{
|
||||
"instruction_addr": "0x000055931ccfe61c",
|
||||
"function": "main",
|
||||
"filename": "test.c",
|
||||
"lineno": 7,
|
||||
"package": None,
|
||||
},
|
||||
{
|
||||
"instruction_addr": "0x000055931ccfe60a",
|
||||
"function": "crashing_function",
|
||||
"filename": "test.c",
|
||||
"lineno": 3,
|
||||
"package": None,
|
||||
},
|
||||
],
|
||||
"registers": {},
|
||||
},
|
||||
}
|
||||
|
||||
assert ls[1].to_json() == {
|
||||
"id": "2",
|
||||
"name": "LWP 45",
|
||||
"crashed": False,
|
||||
"stacktrace": {
|
||||
"frames": [
|
||||
{
|
||||
"instruction_addr": "0x0000563f31ccfafc",
|
||||
"function": "test",
|
||||
"filename": "test_file.c",
|
||||
"lineno": 9,
|
||||
"package": None,
|
||||
},
|
||||
{
|
||||
"instruction_addr": "0x00005594565cfeab",
|
||||
"function": "test_function",
|
||||
"filename": "test_file.c",
|
||||
"lineno": 7,
|
||||
"package": None,
|
||||
},
|
||||
],
|
||||
"registers": {},
|
||||
},
|
||||
}
|
||||
|
||||
assert ls[0].to_json() == {
|
||||
"id": "3",
|
||||
"name": "LWP 40",
|
||||
"crashed": False,
|
||||
"stacktrace": {
|
||||
"frames": [
|
||||
{
|
||||
"instruction_addr": "0x000055a7df18760a",
|
||||
"function": "std::test::read",
|
||||
"filename": None,
|
||||
"lineno": None,
|
||||
"package": "/lib/x86_64-linux-gnu/libc.so.6",
|
||||
},
|
||||
{
|
||||
"instruction_addr": "0x00005594565cfeab",
|
||||
"function": "test_function",
|
||||
"filename": "test_file.c",
|
||||
"lineno": 7,
|
||||
"package": None,
|
||||
},
|
||||
],
|
||||
"registers": {},
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user