Skip to content

Commit 369374b

Browse files
authored
Merge pull request #302 from xcp-ng/abo/new-test-perf-probe
Add a new test on 'perf probe' bug
2 parents adc14d2 + c2d9d96 commit 369374b

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

tests/packages/linux_image/__init__.py

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import logging
2+
import pytest
3+
import urllib.request
4+
5+
# Explicitly import package-scoped fixtures (see explanation in pkgfixtures.py)
6+
from pkgfixtures import host_with_saved_yum_state
7+
8+
@pytest.fixture(scope="package")
9+
def host_with_perf(host_with_saved_yum_state):
10+
host = host_with_saved_yum_state
11+
12+
logging.info(f"Getting perf package")
13+
14+
host.yum_install(['perf'])
15+
yield host
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Requirements:
2+
# From --hosts parameter:
3+
# - host(A1): any xcp-ng host
4+
import re
5+
6+
def perf_probe(host, probe):
7+
host.ssh(['perf', 'probe', '--add', probe])
8+
host.ssh(['perf', 'record', '-e', 'probe:' + probe, '-o', '~/perf.data', '-aR', '--', 'sleep', '10'])
9+
host.ssh(['perf', 'probe', '--del', probe])
10+
11+
samples = host.ssh(['perf', 'report', '-i', '~/perf.data', '-D', '--stdio-color', 'never'])
12+
host.ssh(['rm', '~/perf.data'])
13+
14+
return re.findall(r'RECORD_SAMPLE', samples)
15+
16+
def test_linux_image_perf_probe(host_with_perf):
17+
# Probe that triggers very often:
18+
probe = 'xen_flush_tlb_one_user'
19+
20+
match = perf_probe(host_with_perf, probe)
21+
22+
assert len(match) > 0, "No sample found for probe %s!" % probe
23+
24+
# Example of a function that isn't called often:
25+
probe = 'xenbus_backend_ioctl'
26+
27+
match = perf_probe(host_with_perf, probe)
28+
29+
assert len(match) == 0, "Samples found for probe %s!" % probe

0 commit comments

Comments
 (0)