Commit | Line | Data |
---|---|---|
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 | """ | |
10 | Test instrumentation coverage of C++ constructors and destructors by LTTng-UST | |
11 | tracepoints with a static archive. | |
12 | ||
13 | This test successively sets up a session, traces a test application, and then | |
14 | reads the resulting trace to determine if all the expected events are present. | |
15 | """ | |
16 | ||
17 | import copy | |
18 | import pathlib | |
19 | import sys | |
20 | ||
21 | # Import in-tree test utils | |
22 | test_utils_import_path = pathlib.Path(__file__).absolute().parents[3] / "utils" | |
23 | sys.path.append(str(test_utils_import_path)) | |
24 | ||
25 | import lttngtest | |
26 | import ust_constructor_common as ust | |
27 | ||
28 | test = { | |
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 | ||
40 | tap = lttngtest.TapGenerator(7 + len(test["expected_events"])) | |
41 | with 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 | ||
58 | sys.exit(0 if tap.is_successful else 1) |