Skip to content

Commit 220a5a2

Browse files
committed
test: hook into PID in tracing tests
This makes sure to NOT hook into other bitcoind binaries run in paralell in the test framework. We only want to trace the intended binary. In interface_usdt_utxocache.py: While testing the utxocache flush with pruning, bitcoind is restarted and we need to hook into the new PID again.
1 parent 4129c13 commit 220a5a2

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

test/functional/interface_usdt_net.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def __repr__(self):
109109

110110
self.log.info(
111111
"hook into the net:inbound_message and net:outbound_message tracepoints")
112-
ctx = USDT(path=str(self.options.bitcoind))
112+
ctx = USDT(pid=self.nodes[0].process.pid)
113113
ctx.enable_probe(probe="net:inbound_message",
114114
fn_name="trace_inbound_message")
115115
ctx.enable_probe(probe="net:outbound_message",

test/functional/interface_usdt_utxocache.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def test_uncache(self):
173173
invalid_tx.vin[0].prevout.hash = int(block_1_coinbase_txid, 16)
174174

175175
self.log.info("hooking into the utxocache:uncache tracepoint")
176-
ctx = USDT(path=str(self.options.bitcoind))
176+
ctx = USDT(pid=self.nodes[0].process.pid)
177177
ctx.enable_probe(probe="utxocache:uncache",
178178
fn_name="trace_utxocache_uncache")
179179
bpf = BPF(text=utxocache_changes_program, usdt_contexts=[ctx], debug=0)
@@ -238,7 +238,7 @@ def test_add_spent(self):
238238

239239
self.log.info(
240240
"hook into the utxocache:add and utxocache:spent tracepoints")
241-
ctx = USDT(path=str(self.options.bitcoind))
241+
ctx = USDT(pid=self.nodes[0].process.pid)
242242
ctx.enable_probe(probe="utxocache:add", fn_name="trace_utxocache_add")
243243
ctx.enable_probe(probe="utxocache:spent",
244244
fn_name="trace_utxocache_spent")
@@ -334,7 +334,7 @@ def test_flush(self):
334334

335335
self.log.info("test the utxocache:flush tracepoint API")
336336
self.log.info("hook into the utxocache:flush tracepoint")
337-
ctx = USDT(path=str(self.options.bitcoind))
337+
ctx = USDT(pid=self.nodes[0].process.pid)
338338
ctx.enable_probe(probe="utxocache:flush",
339339
fn_name="trace_utxocache_flush")
340340
bpf = BPF(text=utxocache_flushes_program, usdt_contexts=[ctx], debug=0)
@@ -373,6 +373,7 @@ def handle_utxocache_flush(_, data, __):
373373
self.stop_node(0)
374374

375375
bpf.perf_buffer_poll(timeout=200)
376+
bpf.cleanup()
376377

377378
self.log.info("check that we don't expect additional flushes")
378379
assert_equal(0, len(expected_flushes))
@@ -381,6 +382,14 @@ def handle_utxocache_flush(_, data, __):
381382
self.log.info("restart the node with -prune")
382383
self.start_node(0, ["-fastprune=1", "-prune=1"])
383384

385+
self.log.info("test the utxocache:flush tracepoint API with pruning")
386+
self.log.info("hook into the utxocache:flush tracepoint")
387+
ctx = USDT(pid=self.nodes[0].process.pid)
388+
ctx.enable_probe(probe="utxocache:flush",
389+
fn_name="trace_utxocache_flush")
390+
bpf = BPF(text=utxocache_flushes_program, usdt_contexts=[ctx], debug=0)
391+
bpf["utxocache_flush"].open_perf_buffer(handle_utxocache_flush)
392+
384393
BLOCKS_TO_MINE = 350
385394
self.log.info(f"mine {BLOCKS_TO_MINE} blocks to be able to prune")
386395
self.generate(self.wallet, BLOCKS_TO_MINE)

test/functional/interface_usdt_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def __repr__(self):
9494
expected_blocks = list()
9595

9696
self.log.info("hook into the validation:block_connected tracepoint")
97-
ctx = USDT(path=str(self.options.bitcoind))
97+
ctx = USDT(pid=self.nodes[0].process.pid)
9898
ctx.enable_probe(probe="validation:block_connected",
9999
fn_name="trace_block_connected")
100100
bpf = BPF(text=validation_blockconnected_program,

0 commit comments

Comments
 (0)