| 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 | """ |
| 8 | Test instrumentation coverage of C constructors and destructors by LTTng-UST |
| 9 | tracepoints with a static archive. |
| 10 | |
| 11 | This test successively sets up a session, traces a test application, and then |
| 12 | reads the resulting trace to determine if all the expected events are present. |
| 13 | """ |
| 14 | |
| 15 | import copy |
| 16 | import pathlib |
| 17 | import sys |
| 18 | |
| 19 | # Import in-tree test utils |
| 20 | test_utils_import_path = pathlib.Path(__file__).absolute().parents[3] / "utils" |
| 21 | sys.path.append(str(test_utils_import_path)) |
| 22 | |
| 23 | import lttngtest |
| 24 | import ust_constructor_common as ust |
| 25 | |
| 26 | test = { |
| 27 | "description": "Test user space constructor/destructor instrumentation coverage (C w/ static archive)", |
| 28 | "application": "gen-ust-events-constructor/gen-ust-events-c-constructor-a", |
| 29 | "expected_events": copy.deepcopy( |
| 30 | ust.expected_events_common + ust.expected_events_tp_a |
| 31 | ), |
| 32 | "skip_if_application_not_present": False, |
| 33 | } |
| 34 | |
| 35 | tap = lttngtest.TapGenerator(7 + len(test["expected_events"])) |
| 36 | with lttngtest.test_environment(with_sessiond=True, log=tap.diagnostic) as test_env: |
| 37 | try: |
| 38 | outputlocation = ust.capture_trace( |
| 39 | tap, test_env, test["application"], test["description"] |
| 40 | ) |
| 41 | except FileNotFoundError as fne: |
| 42 | tap.diagnostic(fne) |
| 43 | if test["skip_if_application_not_present"]: |
| 44 | tap.skip( |
| 45 | "Test application '{}' not found".format(test["application"]), |
| 46 | tap.remaining_test_cases, |
| 47 | ) |
| 48 | sys.exit(0) |
| 49 | # Warning: validate_trace mutates test['expected_events'] |
| 50 | ust.validate_trace(outputlocation.path, tap, test["expected_events"]) |
| 51 | |
| 52 | |
| 53 | sys.exit(0 if tap.is_successful else 1) |