generate core just-in-time

pull/880/head
Daniel Ebert 4 years ago committed by Disconnect3d
parent 83e385a764
commit 1d8568c45b

@ -90,12 +90,15 @@ def test_loads_binary_without_crashing():
def test_loads_binary_with_core_without_crashing(): def test_loads_binary_with_core_without_crashing():
if not os.path.isfile(BINARY): if not os.path.isfile(BINARY):
compile_binary(BINARY_SOURCE, BINARY) compile_binary(BINARY_SOURCE, BINARY)
if not os.path.isfile(CORE):
create_coredump = ['run', f'generate-core-file {CORE}']
run_gdb_with_script(binary=BINARY, pyafter=create_coredump)
assert os.path.isfile(CORE)
output = run_gdb_with_script(binary=BINARY, core=CORE).splitlines() output = run_gdb_with_script(binary=BINARY, core=CORE).splitlines()
expected = [ expected = [
'Reading symbols from %s...' % BINARY, 'Reading symbols from %s...' % BINARY,
'(No debugging symbols found in %s)' % BINARY, '(No debugging symbols found in %s)' % BINARY,
"Core was generated by `./binary'.",
'Program terminated with signal SIGFPE, Arithmetic exception.', 'Program terminated with signal SIGFPE, Arithmetic exception.',
] ]
expected += HELLO expected += HELLO
@ -106,6 +109,10 @@ def test_loads_binary_with_core_without_crashing():
lwp_line = re.compile('^\[New LWP \d+\]$') lwp_line = re.compile('^\[New LWP \d+\]$')
assert any([lwp_line.match(line) for line in output]) assert any([lwp_line.match(line) for line in output])
# matches for example "Core was generated by `./binary'."
binary_line = re.compile("^Core was generated by .+$")
assert any([binary_line.match(line) for line in output])
# matches for example '#0 0x0000556e99b7913c in main ()' # matches for example '#0 0x0000556e99b7913c in main ()'
crash_address_line = re.compile('^#0 0x[0-9a-fA-F]+ in main \(\)$') crash_address_line = re.compile('^#0 0x[0-9a-fA-F]+ in main \(\)$')
assert any([crash_address_line.match(line) for line in output]) assert any([crash_address_line.match(line) for line in output])
@ -115,10 +122,13 @@ def test_loads_binary_with_core_without_crashing():
def test_loads_core_without_crashing(): def test_loads_core_without_crashing():
if not os.path.isfile(BINARY): if not os.path.isfile(BINARY):
compile_binary(BINARY_SOURCE, BINARY) compile_binary(BINARY_SOURCE, BINARY)
if not os.path.isfile(CORE):
create_coredump = ['run', f'generate-core-file {CORE}']
run_gdb_with_script(binary=BINARY, pyafter=create_coredump)
assert os.path.isfile(CORE)
output = run_gdb_with_script(core=CORE).splitlines() output = run_gdb_with_script(core=CORE).splitlines()
expected = [ expected = [
"Core was generated by `./binary'.",
'Program terminated with signal SIGFPE, Arithmetic exception.', 'Program terminated with signal SIGFPE, Arithmetic exception.',
] ]
expected += HELLO expected += HELLO
@ -129,6 +139,10 @@ def test_loads_core_without_crashing():
lwp_line = re.compile('^\[New LWP \d+\]$') lwp_line = re.compile('^\[New LWP \d+\]$')
assert any([lwp_line.match(line) for line in output]) assert any([lwp_line.match(line) for line in output])
# matches for example "Core was generated by `./binary'."
binary_line = re.compile("^Core was generated by .+$")
assert any([binary_line.match(line) for line in output])
# matches for example '#0 0x0000556e99b7913c in ?? ()' # matches for example '#0 0x0000556e99b7913c in ?? ()'
crash_address_line = re.compile('^#0 0x[0-9a-fA-F]+ in \?\? \(\)$') crash_address_line = re.compile('^#0 0x[0-9a-fA-F]+ in \?\? \(\)$')
assert any([crash_address_line.match(line) for line in output]) assert any([crash_address_line.match(line) for line in output])

Loading…
Cancel
Save