tests: Split test_ust_constructor into several tests
[lttng-tools.git] / tests / regression / ust / ust-constructor / test_ust_constructor_cpp_static.py
CommitLineData
f506900f
KS
1#!/usr/bin/env python3
2#
3# Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4# Copyright (C) 2023 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5#
6# SPDX-License-Identifier: GPL-2.0-only
7
8
9"""
10Test instrumentation coverage of C++ constructors and destructors by LTTng-UST
11tracepoints with a static archive.
12
13This test successively sets up a session, traces a test application, and then
14reads the resulting trace to determine if all the expected events are present.
15"""
16
17import copy
18import pathlib
19import sys
20
21# Import in-tree test utils
22test_utils_import_path = pathlib.Path(__file__).absolute().parents[3] / "utils"
23sys.path.append(str(test_utils_import_path))
24
25import lttngtest
26import ust_constructor_common as ust
27
28test = {
29 "description": "Test user space constructor/destructor instrumentation coverage (C++ w/ static archive)",
30 "application": "gen-ust-events-constructor/gen-ust-events-constructor-a",
31 "expected_events": copy.deepcopy(
32 ust.expected_events_common
33 + ust.expected_events_common_cpp
34 + ust.expected_events_tp_a
35 + ust.expected_events_tp_a_cpp
36 ),
37 "skip_if_application_not_present": False,
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.025004 seconds and 4 git commands to generate.