Skip to content

Commit 7b5e46f

Browse files
committed
Test capture of exit code when debuggee process terminates
1 parent 7ca7caf commit 7b5e46f

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

test.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,19 @@ def thread_task():
383383
t.start()
384384
t.join()
385385

386-
sys.exit(-1)
386+
# return code tests
387+
for tb in [x for x in testbins if x.startswith('exitcode')]:
388+
testbin = tb
389+
390+
fpath = testbin_to_fpath()
387391

392+
for (arg, expected) in [('-11',245), ('-1',255), ('-3',253), ('0',0), ('3',3), ('7',7), ('123',123)]:
393+
adapter = DebugAdapter.get_adapter_for_current_system()
394+
utils.green('testing %s %s' % (tb, arg))
395+
adapter.exec(fpath, [arg])
396+
(reason, extra) = go_initial(adapter)
397+
assert_equality(reason, DebugAdapter.STOP_REASON.PROCESS_EXITED)
398+
assert_equality(extra, expected)
388399

389400
# exception test
390401
for tb in testbins:

testbins/Makefile-macos

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# make -f Makefile-macosos
22

3-
TARGETS = helloworld_x64-macos helloworld_loop_x64-macos helloworld_thread_x64-macos helloworld_func_x64-macos helloworld_recursion_x64-macos helloworld_pie_x64-macos helloworld_thread_pie_x64-macos helloworld_loop_pie_x64-macos helloworld_func_pie_x64-macos helloworld_recursion_pie_x64-macos asmtest_x64-macos nopspeed_x64-macos cat_x64-macos commandline_test_x64-macos helloworld_objc_x64-macos helloworld_virtual_x64-macos do_exception_x64-macos
3+
TARGETS = helloworld_x64-macos exitcode_x64-macos helloworld_loop_x64-macos helloworld_thread_x64-macos helloworld_func_x64-macos helloworld_recursion_x64-macos helloworld_pie_x64-macos helloworld_thread_pie_x64-macos helloworld_loop_pie_x64-macos helloworld_func_pie_x64-macos helloworld_recursion_pie_x64-macos asmtest_x64-macos nopspeed_x64-macos cat_x64-macos commandline_test_x64-macos helloworld_objc_x64-macos helloworld_virtual_x64-macos do_exception_x64-macos
44

55
all: $(TARGETS)
66

@@ -10,6 +10,9 @@ clean:
1010
helloworld_x64-macos: helloworld.c
1111
gcc -Wl,-no_pie helloworld.c -o helloworld_x64-macos
1212

13+
exitcode_x64-macos: exitcode.c
14+
gcc -Wl,-no_pie exitcode.c -o exitcode_x64-macos
15+
1316
helloworld_thread_x64-macos: helloworld_thread.c
1417
gcc -Wl,-no_pie helloworld_thread.c -o helloworld_thread_x64-macos
1518

testbins/exitcode.c

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
int main(int ac, char **av)
5+
{
6+
int rc = atoi(av[1]);
7+
printf("returning %d\n", rc);
8+
return rc;
9+
}

0 commit comments

Comments
 (0)