tests: Split test_ust_constructor into several tests
[lttng-tools.git] / tests / regression / ust / ust-constructor / test_ust_constructor_cpp_dynamic.py
CommitLineData
f506900f
KS
1#!/usr/bin/env python3
2#
3# SPDX-FileCopyrightText: Kienan Stewart <kstewart@efficios.com>
4# SPDX-License-Identifier: GPL-2.0-only
5#
6
7"""
8Test instrumentation coverage of C++ constructors and destructors by LTTng-UST
9tracepoints with a dynamic object.
10
11This test successively sets up a session, traces a test application, and then
12reads the resulting trace to determine if all the expected events are present.
13"""
14
15import copy
16import pathlib
17import sys
18
19# Import in-tree test utils
20test_utils_import_path = pathlib.Path(__file__).absolute().parents[3] / "utils"
21sys.path.append(str(test_utils_import_path))
22
23import lttngtest
24import ust_constructor_common as ust
25
26test = {
27 "description": "Test user space constructor/destructor instrumentation coverage (C++ w/ dynamic object",
28 "application": "gen-ust-events-constructor/gen-ust-events-constructor-so",
29 "expected_events": copy.deepcopy(
30 ust.expected_events_common
31 + ust.expected_events_common_cpp
32 + ust.expected_events_tp_so
33 + ust.expected_events_tp_so_cpp
34 ),
35 # This application is not be built when `NO_SHARED` is set in the
36 # configuration options.
37 "skip_if_application_not_present": True,
38}
39
40tap = lttngtest.TapGenerator(7 + len(test["expected_events"]))
41with lttngtest.test_environment(with_sessiond=True, log=tap.diagnostic) as test_env:
42 try:
43 outputlocation = ust.capture_trace(
44 tap, test_env, test["application"], test["description"]
45 )
46 except FileNotFoundError as fne:
47 tap.diagnostic(fne)
48 if test["skip_if_application_not_present"]:
49 tap.skip(
50 "Test application '{}' not found".format(test["application"]),
51 tap.remaining_test_cases,
52 )
53 sys.exit(0)
54 # Warning: validate_trace mutates test['expected_events']
55 ust.validate_trace(outputlocation.path, tap, test["expected_events"])
56
57
58sys.exit(0 if tap.is_successful else 1)
This page took 0.024796 seconds and 4 git commands to generate.