Skip to content

Commit

Permalink
Provide error strings if kernel tracing test skipped
Browse files Browse the repository at this point in the history
Signed-off-by: Christophe Bedard <christophe.bedard@apex.ai>
  • Loading branch information
christophebedard committed Oct 7, 2024
1 parent c105689 commit 485dca3
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions test_ros2trace/test/test_ros2trace/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ def are_tracepoints_included() -> bool:
return 0 == process.returncode


def skip_if_no_kernel_tracing():
kernel_tracepoints = lttngpy.get_tracepoints(domain_type=lttngpy.LTTNG_DOMAIN_KERNEL)
syscalls = lttngpy.get_syscalls()
error = ', '.join(
f'{name}: {lttngpy.lttng_strerror(error_code)}' for name, error_code in (
('kernel tracepoints', kernel_tracepoints),
('syscalls', syscalls),
)
if isinstance(error_code, int)
)
if error:
return unittest.skip(f'kernel tracer is required: {error}')
return lambda test_case: test_case


@unittest.skipIf(not is_lttng_installed(minimum_version='2.9.0'), 'LTTng is required')
class TestROS2TraceCLI(unittest.TestCase):

Expand Down Expand Up @@ -316,13 +331,7 @@ def test_default_tracing(self) -> None:

shutil.rmtree(tmpdir)

@unittest.skipIf(
(
isinstance(lttngpy.get_tracepoints(domain_type=lttngpy.LTTNG_DOMAIN_KERNEL), int) or
isinstance(lttngpy.get_syscalls(), int)
),
'kernel tracer is required',
)
@skip_if_no_kernel_tracing()
def test_kernel_tracing(self) -> None:
tmpdir = self.create_test_tmpdir('test_kernel_tracing')
session_name = 'test_kernel_tracing'
Expand Down

0 comments on commit 485dca3

Please sign in to comment.