Commit | Line | Data |
---|---|---|
6a96f8df KS |
1 | #!/usr/bin/env python3 |
2 | # | |
3 | # Copyright (C) 2024 Kienan Stewart <kstewart@efficios.com> | |
4 | # SPDX-License-Identifier: GPL-2.0-only | |
5 | # | |
6 | ||
7 | """ | |
8 | Test for https://review.lttng.org/c/lttng-tools/+/11819 | |
9 | ||
10 | A live client shouldn't hang around after a session with no data has | |
11 | been destroyed | |
12 | """ | |
13 | ||
14 | import pathlib | |
15 | import socket | |
16 | import subprocess | |
17 | import sys | |
6a96f8df KS |
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 bt2 | |
25 | ||
26 | tap = lttngtest.TapGenerator(1) | |
27 | ||
28 | ||
29 | def test_live_hang(tap, test_env): | |
30 | client = lttngtest.LTTngClient(test_env, log=tap.diagnostic) | |
31 | ||
32 | # lttng create --live | |
33 | output = lttngtest.NetworkSessionOutputLocation( | |
34 | "net://localhost:{}:{}/".format( | |
35 | test_env.lttng_relayd_control_port, test_env.lttng_relayd_data_port | |
36 | ) | |
37 | ) | |
38 | session = client.create_session(output=output, live=True) | |
39 | ||
40 | # lttng enable-event --userspace --all | |
41 | channel = session.add_channel(lttngtest.lttngctl.TracingDomain.User) | |
42 | channel.add_recording_rule(lttngtest.lttngctl.UserTracepointEventRule()) | |
43 | ||
44 | session.start() | |
45 | test_app = test_env.launch_wait_trace_test_application(100) | |
46 | session.stop() | |
47 | session.clear() | |
48 | ||
c3200502 KS |
49 | viewer = test_env.launch_live_viewer(session.name) |
50 | viewer.wait_until_connected() | |
6a96f8df KS |
51 | |
52 | session.destroy() | |
53 | ||
c3200502 | 54 | viewer.wait() |
6a96f8df | 55 | tap.test( |
c3200502 KS |
56 | True, |
57 | "BT2 live viewer exited successfully", | |
6a96f8df | 58 | ) |
6a96f8df KS |
59 | |
60 | ||
61 | with lttngtest.test_environment( | |
62 | with_sessiond=True, log=tap.diagnostic, with_relayd=True | |
63 | ) as test_env: | |
64 | test_live_hang(tap, test_env) | |
65 | ||
66 | sys.exit(0 if tap.is_successful else 1) |