Skip to content

Commit 458720e

Browse files
committed
Merge bitcoin/bitcoin#32336: test: Suppress upstream -Wduplicate-decl-specifier in bpfcc
facb9b3 scripted-diff: Use bpf_cflags (MarcoFalke) fa0c1ba test: Add imports for util bpf_cflags (MarcoFalke) Pull request description: On some Linux kernel versions, the bpf compiler invoked in the functional tests will issue a `-Wduplicate-decl-specifier` warning. This seems harmless and should be fixed upstream in the Linux kernel. Here, simply suppress it for now. Fixes bitcoin/bitcoin#32322 ACKs for top commit: laanwj: Code review ACK facb9b3 hebasto: ACK facb9b3, I have reviewed the code and it looks OK. Tree-SHA512: 53387127e3c2a2dbfe05281b2d2e61efbd3c3adcc3b4bf2f11540042f86e1e8c06637f80d246310bc44ca0612318472f25545c1e1ca3636fda97d04381f9e905
2 parents 9efe546 + facb9b3 commit 458720e

File tree

6 files changed

+46
-26
lines changed

6 files changed

+46
-26
lines changed

test/functional/interface_usdt_coinselection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# Copyright (c) 2022 The Bitcoin Core developers
2+
# Copyright (c) 2022-present The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

@@ -17,6 +17,7 @@
1717
assert_equal,
1818
assert_greater_than,
1919
assert_raises_rpc_error,
20+
bpf_cflags,
2021
)
2122

2223
coinselection_tracepoints_program = """
@@ -175,7 +176,7 @@ def run_test(self):
175176
ctx.enable_probe(probe="coin_selection:normal_create_tx_internal", fn_name="trace_normal_create_tx")
176177
ctx.enable_probe(probe="coin_selection:attempting_aps_create_tx", fn_name="trace_attempt_aps")
177178
ctx.enable_probe(probe="coin_selection:aps_create_tx_internal", fn_name="trace_aps_create_tx")
178-
self.bpf = BPF(text=coinselection_tracepoints_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
179+
self.bpf = BPF(text=coinselection_tracepoints_program, usdt_contexts=[ctx], debug=0, cflags=bpf_cflags())
179180

180181
self.log.info("Prepare wallets")
181182
self.generate(self.nodes[0], 101)

test/functional/interface_usdt_mempool.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# Copyright (c) 2022 The Bitcoin Core developers
2+
# Copyright (c) 2022-present The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

@@ -20,7 +20,10 @@
2020
from test_framework.messages import COIN, DEFAULT_MEMPOOL_EXPIRY_HOURS
2121
from test_framework.p2p import P2PDataStore
2222
from test_framework.test_framework import BitcoinTestFramework
23-
from test_framework.util import assert_equal
23+
from test_framework.util import (
24+
assert_equal,
25+
bpf_cflags,
26+
)
2427
from test_framework.wallet import MiniWallet
2528

2629
MEMPOOL_TRACEPOINTS_PROGRAM = """
@@ -166,7 +169,7 @@ def added_test(self):
166169
node = self.nodes[0]
167170
ctx = USDT(pid=node.process.pid)
168171
ctx.enable_probe(probe="mempool:added", fn_name="trace_added")
169-
bpf = BPF(text=MEMPOOL_TRACEPOINTS_PROGRAM, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
172+
bpf = BPF(text=MEMPOOL_TRACEPOINTS_PROGRAM, usdt_contexts=[ctx], debug=0, cflags=bpf_cflags())
170173

171174
def handle_added_event(_, data, __):
172175
events.append(bpf["added_events"].event(data))
@@ -203,7 +206,7 @@ def removed_test(self):
203206
node = self.nodes[0]
204207
ctx = USDT(pid=node.process.pid)
205208
ctx.enable_probe(probe="mempool:removed", fn_name="trace_removed")
206-
bpf = BPF(text=MEMPOOL_TRACEPOINTS_PROGRAM, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
209+
bpf = BPF(text=MEMPOOL_TRACEPOINTS_PROGRAM, usdt_contexts=[ctx], debug=0, cflags=bpf_cflags())
207210

208211
def handle_removed_event(_, data, __):
209212
events.append(bpf["removed_events"].event(data))
@@ -249,7 +252,7 @@ def replaced_test(self):
249252
node = self.nodes[0]
250253
ctx = USDT(pid=node.process.pid)
251254
ctx.enable_probe(probe="mempool:replaced", fn_name="trace_replaced")
252-
bpf = BPF(text=MEMPOOL_TRACEPOINTS_PROGRAM, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
255+
bpf = BPF(text=MEMPOOL_TRACEPOINTS_PROGRAM, usdt_contexts=[ctx], debug=0, cflags=bpf_cflags())
253256

254257
def handle_replaced_event(_, data, __):
255258
event = ctypes.cast(data, ctypes.POINTER(MempoolReplaced)).contents
@@ -302,7 +305,7 @@ def rejected_test(self):
302305
self.log.info("Hooking into mempool:rejected tracepoint...")
303306
ctx = USDT(pid=node.process.pid)
304307
ctx.enable_probe(probe="mempool:rejected", fn_name="trace_rejected")
305-
bpf = BPF(text=MEMPOOL_TRACEPOINTS_PROGRAM, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
308+
bpf = BPF(text=MEMPOOL_TRACEPOINTS_PROGRAM, usdt_contexts=[ctx], debug=0, cflags=bpf_cflags())
306309

307310
def handle_rejected_event(_, data, __):
308311
events.append(bpf["rejected_events"].event(data))

test/functional/interface_usdt_net.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# Copyright (c) 2022 The Bitcoin Core developers
2+
# Copyright (c) 2022-present The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

@@ -17,7 +17,11 @@
1717
from test_framework.messages import CBlockHeader, MAX_HEADERS_RESULTS, msg_headers, msg_version
1818
from test_framework.p2p import P2PInterface
1919
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+
)
2125

2226
# Tor v3 addresses are 62 chars + 6 chars for the port (':12345').
2327
MAX_PEER_ADDR_LENGTH = 68
@@ -283,7 +287,7 @@ def __repr__(self):
283287
fn_name="trace_inbound_message")
284288
ctx.enable_probe(probe="net:outbound_message",
285289
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())
287291

288292
EXPECTED_INOUTBOUND_VERSION_MSG = 1
289293
checked_inbound_version_msg = 0
@@ -341,7 +345,7 @@ def inbound_conn_tracepoint_test(self):
341345
ctx = USDT(pid=self.nodes[0].process.pid)
342346
ctx.enable_probe(probe="net:inbound_connection",
343347
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())
345349

346350
inbound_connections = []
347351
EXPECTED_INBOUND_CONNECTIONS = 2
@@ -378,7 +382,7 @@ def outbound_conn_tracepoint_test(self):
378382
ctx = USDT(pid=self.nodes[0].process.pid)
379383
ctx.enable_probe(probe="net:outbound_connection",
380384
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())
382386

383387
# that the handle_* function succeeds.
384388
EXPECTED_OUTBOUND_CONNECTIONS = 2
@@ -419,7 +423,7 @@ def evicted_inbound_conn_tracepoint_test(self):
419423
ctx = USDT(pid=self.nodes[0].process.pid)
420424
ctx.enable_probe(probe="net:evicted_inbound_connection",
421425
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())
423427

424428
EXPECTED_EVICTED_CONNECTIONS = 2
425429
evicted_connections = []
@@ -456,7 +460,7 @@ def misbehaving_conn_tracepoint_test(self):
456460
ctx = USDT(pid=self.nodes[0].process.pid)
457461
ctx.enable_probe(probe="net:misbehaving_connection",
458462
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())
460464

461465
EXPECTED_MISBEHAVING_CONNECTIONS = 2
462466
misbehaving_connections = []
@@ -490,7 +494,7 @@ def closed_conn_tracepoint_test(self):
490494
ctx = USDT(pid=self.nodes[0].process.pid)
491495
ctx.enable_probe(probe="net:closed_connection",
492496
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())
494498

495499
EXPECTED_CLOSED_CONNECTIONS = 2
496500
closed_connections = []

test/functional/interface_usdt_utxocache.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# Copyright (c) 2022 The Bitcoin Core developers
2+
# Copyright (c) 2022-present The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

@@ -15,7 +15,10 @@
1515
pass
1616
from test_framework.messages import COIN
1717
from test_framework.test_framework import BitcoinTestFramework
18-
from test_framework.util import assert_equal
18+
from test_framework.util import (
19+
assert_equal,
20+
bpf_cflags,
21+
)
1922
from test_framework.wallet import MiniWallet
2023

2124
utxocache_changes_program = """
@@ -181,7 +184,7 @@ def test_uncache(self):
181184
ctx = USDT(pid=self.nodes[0].process.pid)
182185
ctx.enable_probe(probe="utxocache:uncache",
183186
fn_name="trace_utxocache_uncache")
184-
bpf = BPF(text=utxocache_changes_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
187+
bpf = BPF(text=utxocache_changes_program, usdt_contexts=[ctx], debug=0, cflags=bpf_cflags())
185188

186189
# The handle_* function is a ctypes callback function called from C. When
187190
# we assert in the handle_* function, the AssertError doesn't propagate
@@ -250,7 +253,7 @@ def test_add_spent(self):
250253
ctx.enable_probe(probe="utxocache:add", fn_name="trace_utxocache_add")
251254
ctx.enable_probe(probe="utxocache:spent",
252255
fn_name="trace_utxocache_spent")
253-
bpf = BPF(text=utxocache_changes_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
256+
bpf = BPF(text=utxocache_changes_program, usdt_contexts=[ctx], debug=0, cflags=bpf_cflags())
254257

255258
# The handle_* function is a ctypes callback function called from C. When
256259
# we assert in the handle_* function, the AssertError doesn't propagate
@@ -350,7 +353,7 @@ def test_flush(self):
350353
ctx = USDT(pid=self.nodes[0].process.pid)
351354
ctx.enable_probe(probe="utxocache:flush",
352355
fn_name="trace_utxocache_flush")
353-
bpf = BPF(text=utxocache_flushes_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
356+
bpf = BPF(text=utxocache_flushes_program, usdt_contexts=[ctx], debug=0, cflags=bpf_cflags())
354357

355358
# The handle_* function is a ctypes callback function called from C. When
356359
# we assert in the handle_* function, the AssertError doesn't propagate
@@ -407,7 +410,7 @@ def handle_utxocache_flush(_, data, __):
407410
ctx = USDT(pid=self.nodes[0].process.pid)
408411
ctx.enable_probe(probe="utxocache:flush",
409412
fn_name="trace_utxocache_flush")
410-
bpf = BPF(text=utxocache_flushes_program, usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
413+
bpf = BPF(text=utxocache_flushes_program, usdt_contexts=[ctx], debug=0, cflags=bpf_cflags())
411414
bpf["utxocache_flush"].open_perf_buffer(handle_utxocache_flush)
412415

413416
self.log.info("prune blockchain to trigger a flush for pruning")

test/functional/interface_usdt_validation.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# Copyright (c) 2022 The Bitcoin Core developers
2+
# Copyright (c) 2022-present The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

@@ -18,8 +18,10 @@
1818

1919
from test_framework.address import ADDRESS_BCRT1_UNSPENDABLE
2020
from test_framework.test_framework import BitcoinTestFramework
21-
from test_framework.util import assert_equal
22-
21+
from test_framework.util import (
22+
assert_equal,
23+
bpf_cflags,
24+
)
2325

2426
validation_blockconnected_program = """
2527
#include <uapi/linux/ptrace.h>
@@ -97,7 +99,7 @@ def __repr__(self):
9799
ctx.enable_probe(probe="validation:block_connected",
98100
fn_name="trace_block_connected")
99101
bpf = BPF(text=validation_blockconnected_program,
100-
usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])
102+
usdt_contexts=[ctx], debug=0, cflags=bpf_cflags())
101103

102104
def handle_blockconnected(_, data, __):
103105
event = ctypes.cast(data, ctypes.POINTER(Block)).contents

test/functional/test_framework/util.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,13 @@ def wait_until_helper_internal(predicate, *, timeout=60, lock=None, timeout_fact
321321
raise AssertionError("Predicate {} not true after {} seconds".format(predicate_source, timeout))
322322

323323

324+
def bpf_cflags():
325+
return [
326+
"-Wno-error=implicit-function-declaration",
327+
"-Wno-duplicate-decl-specifier", # https://github.com/bitcoin/bitcoin/issues/32322
328+
]
329+
330+
324331
def sha256sum_file(filename):
325332
h = hashlib.sha256()
326333
with open(filename, 'rb') as f:

0 commit comments

Comments
 (0)