|
1 | 1 | #!/usr/bin/env python3 |
2 | | -# Copyright (c) 2022 The Bitcoin Core developers |
| 2 | +# Copyright (c) 2022-present The Bitcoin Core developers |
3 | 3 | # Distributed under the MIT software license, see the accompanying |
4 | 4 | # file COPYING or http://www.opensource.org/licenses/mit-license.php. |
5 | 5 |
|
|
17 | 17 | from test_framework.messages import CBlockHeader, MAX_HEADERS_RESULTS, msg_headers, msg_version |
18 | 18 | from test_framework.p2p import P2PInterface |
19 | 19 | from test_framework.test_framework import BitcoinTestFramework |
20 | | -from test_framework.util import assert_equal, assert_greater_than |
| 20 | +from test_framework.util import ( |
| 21 | + assert_equal, |
| 22 | + assert_greater_than, |
| 23 | + bpf_cflags, |
| 24 | +) |
21 | 25 |
|
22 | 26 | # Tor v3 addresses are 62 chars + 6 chars for the port (':12345'). |
23 | 27 | MAX_PEER_ADDR_LENGTH = 68 |
@@ -283,7 +287,7 @@ def __repr__(self): |
283 | 287 | fn_name="trace_inbound_message") |
284 | 288 | ctx.enable_probe(probe="net:outbound_message", |
285 | 289 | fn_name="trace_outbound_message") |
286 | | - bpf = BPF(text=net_tracepoints_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"]) |
| 290 | + bpf = BPF(text=net_tracepoints_program, usdt_contexts=[ctx], debug=0, cflags=bpf_cflags()) |
287 | 291 |
|
288 | 292 | EXPECTED_INOUTBOUND_VERSION_MSG = 1 |
289 | 293 | checked_inbound_version_msg = 0 |
@@ -341,7 +345,7 @@ def inbound_conn_tracepoint_test(self): |
341 | 345 | ctx = USDT(pid=self.nodes[0].process.pid) |
342 | 346 | ctx.enable_probe(probe="net:inbound_connection", |
343 | 347 | fn_name="trace_inbound_connection") |
344 | | - bpf = BPF(text=net_tracepoints_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"]) |
| 348 | + bpf = BPF(text=net_tracepoints_program, usdt_contexts=[ctx], debug=0, cflags=bpf_cflags()) |
345 | 349 |
|
346 | 350 | inbound_connections = [] |
347 | 351 | EXPECTED_INBOUND_CONNECTIONS = 2 |
@@ -378,7 +382,7 @@ def outbound_conn_tracepoint_test(self): |
378 | 382 | ctx = USDT(pid=self.nodes[0].process.pid) |
379 | 383 | ctx.enable_probe(probe="net:outbound_connection", |
380 | 384 | fn_name="trace_outbound_connection") |
381 | | - bpf = BPF(text=net_tracepoints_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"]) |
| 385 | + bpf = BPF(text=net_tracepoints_program, usdt_contexts=[ctx], debug=0, cflags=bpf_cflags()) |
382 | 386 |
|
383 | 387 | # that the handle_* function succeeds. |
384 | 388 | EXPECTED_OUTBOUND_CONNECTIONS = 2 |
@@ -419,7 +423,7 @@ def evicted_inbound_conn_tracepoint_test(self): |
419 | 423 | ctx = USDT(pid=self.nodes[0].process.pid) |
420 | 424 | ctx.enable_probe(probe="net:evicted_inbound_connection", |
421 | 425 | fn_name="trace_evicted_inbound_connection") |
422 | | - bpf = BPF(text=net_tracepoints_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"]) |
| 426 | + bpf = BPF(text=net_tracepoints_program, usdt_contexts=[ctx], debug=0, cflags=bpf_cflags()) |
423 | 427 |
|
424 | 428 | EXPECTED_EVICTED_CONNECTIONS = 2 |
425 | 429 | evicted_connections = [] |
@@ -456,7 +460,7 @@ def misbehaving_conn_tracepoint_test(self): |
456 | 460 | ctx = USDT(pid=self.nodes[0].process.pid) |
457 | 461 | ctx.enable_probe(probe="net:misbehaving_connection", |
458 | 462 | fn_name="trace_misbehaving_connection") |
459 | | - bpf = BPF(text=net_tracepoints_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"]) |
| 463 | + bpf = BPF(text=net_tracepoints_program, usdt_contexts=[ctx], debug=0, cflags=bpf_cflags()) |
460 | 464 |
|
461 | 465 | EXPECTED_MISBEHAVING_CONNECTIONS = 2 |
462 | 466 | misbehaving_connections = [] |
@@ -490,7 +494,7 @@ def closed_conn_tracepoint_test(self): |
490 | 494 | ctx = USDT(pid=self.nodes[0].process.pid) |
491 | 495 | ctx.enable_probe(probe="net:closed_connection", |
492 | 496 | fn_name="trace_closed_connection") |
493 | | - bpf = BPF(text=net_tracepoints_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"]) |
| 497 | + bpf = BPF(text=net_tracepoints_program, usdt_contexts=[ctx], debug=0, cflags=bpf_cflags()) |
494 | 498 |
|
495 | 499 | EXPECTED_CLOSED_CONNECTIONS = 2 |
496 | 500 | closed_connections = [] |
|
0 commit comments