-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathtest_breakpoints.py
More file actions
116 lines (87 loc) · 2.89 KB
/
test_breakpoints.py
File metadata and controls
116 lines (87 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#! /usr/bin/env python
# SPDX-FileCopyrightText: 2020 - 2024 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
"""Tests for Setting Breakpoints
https://www.sourceware.org/gdb/onlinedocs/gdb/Set-Breaks.html
"""
import pytest
from numba_dpex.tests._helper import skip_no_gdb
from .gdb import gdb
pytestmark = skip_no_gdb
@pytest.mark.parametrize(
"breakpoint",
[
"side-by-side.py:15",
"common_loop_body",
"side-by-side.py:common_loop_body",
],
)
@pytest.mark.parametrize(
"api",
[
"numba",
"numba-ndpx-kernel",
],
)
@pytest.mark.parametrize(
"condition, exp_var, exp_val",
[
("param_a == 3", "param_a", 3),
("param_a == 7", "param_a", 7),
(None, "param_a", r"[0-9]+"), # No condition
],
)
def test_device_func_breakpoint(
app: gdb, breakpoint, api, condition, exp_var, exp_val
):
"""Function breakpoints and argument initializing
Test that it is possible to set conditional breakpoint at the beginning
of the function and use a function argument in the condition.
It is important that breakpoint by function name hits at the first line in
the function body and not at the function definition line.
Test for https://github.com/numba/numba/issues/7415
SAT-4449
"""
app.breakpoint(breakpoint, condition=condition)
app.run(f"side-by-side.py --api={api}")
app.expect_hit_breakpoint(expected_location="side-by-side.py:15")
if exp_var is not None:
app.print(exp_var, expected=exp_val)
@pytest.mark.parametrize(
"condition, exp_var, exp_val",
[
("i == 3", "i", 3),
(None, "i", r"[0-9]+"), # No condition
],
)
def test_kernel_breakpoint(app: gdb, condition, exp_var, exp_val):
"""Function breakpoints and argument initializing
Test that it is possible to set conditional breakpoint at the beginning
of the function and use a function argument in the condition.
It is important that breakpoint by function name hits at the first line in
the function body and not at the function definition line.
Test for https://github.com/numba/numba/issues/7415
SAT-4449
"""
app.breakpoint("simple_sum.py:13", condition=condition)
app.run("simple_sum.py")
app.expect_hit_breakpoint("simple_sum.py:13")
if exp_var is not None:
app.print(exp_var, expected=exp_val)
def test_all_kernel_breakpoints_hit(app: gdb):
"""Test that every thread was hit"""
app.breakpoint("simple_sum.py:13")
app.run("simple_sum.py")
indexes = []
for _ in range(10):
app.expect_hit_breakpoint("simple_sum.py:13")
# Recover the index of the thread
app._command("print i")
app.child.expect(r"\$[0-9]+ = ")
index = app.child.read(1)
app.expect_eol()
indexes.append(int(index))
app.continue_()
indexes.sort()
assert indexes == list(range(10))