fix: relayd: unaligned access in trace_chunk_registry_ht_key_hash
[lttng-tools.git] / tests / utils / testapp / gen-py-events / gen-py-events.py
CommitLineData
9d16b343
MJ
1# Copyright (C) 2015 Philippe Proulx <pproulx@efficios.com>
2# Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
dd238d2a 3#
9d16b343 4# SPDX-License-Identifier: LGPL-2.1-only
dd238d2a
PP
5
6from __future__ import unicode_literals, print_function
7import logging
8import time
9import sys
74f2abd5
JR
10import argparse
11import os
dd238d2a
PP
12
13
14def _perror(msg):
15 print(msg, file=sys.stderr)
16 sys.exit(1)
17
18
19try:
20 import lttngust
6a871bbe
KS
21except ImportError as e:
22 _perror("lttngust package not found: {}".format(e))
dd238d2a
PP
23
24
25def _main():
6a871bbe
KS
26 ev1 = logging.getLogger("python-ev-test1")
27 ev2 = logging.getLogger("python-ev-test2")
dd238d2a
PP
28
29 logging.basicConfig()
30
74f2abd5 31 parser = argparse.ArgumentParser()
6a871bbe
KS
32 parser.add_argument("-n", "--nr-iter", required=True)
33 parser.add_argument("-s", "--wait", required=True)
34 parser.add_argument("-d", "--fire-debug-event", action="store_true")
35 parser.add_argument("-e", "--fire-second-event", action="store_true")
36 parser.add_argument("-r", "--ready-file")
37 parser.add_argument("-g", "--go-file")
74f2abd5
JR
38 args = parser.parse_args()
39
40 nr_iter = int(args.nr_iter)
41 wait_time = float(args.wait)
42 fire_debug_ev = args.fire_debug_event
43 fire_second_ev = args.fire_second_event
44
45 ready_file = args.ready_file
46 go_file = args.go_file
47
48 if ready_file is not None and os.path.exists(ready_file):
6a871bbe 49 raise ValueError("Ready file already exist")
74f2abd5
JR
50
51 if go_file is not None and os.path.exists(go_file):
6a871bbe 52 raise ValueError("Go file already exist. Review synchronization")
74f2abd5
JR
53
54 if (ready_file is None) != (go_file is None):
6a871bbe
KS
55 raise ValueError(
56 "--go-file and --ready-file need each others, review" "synchronization"
57 )
74f2abd5
JR
58
59 # Inform that we are ready, if necessary
60 if ready_file is not None:
6a871bbe 61 open(ready_file, "a").close()
74f2abd5
JR
62
63 # Wait for go, if necessary
64 while go_file is not None and not os.path.exists(go_file):
65 time.sleep(0.5)
dd238d2a
PP
66
67 for i in range(nr_iter):
6a871bbe 68 ev1.info("{} fired [INFO]".format(ev1.name))
dd238d2a
PP
69
70 if fire_debug_ev:
6a871bbe 71 ev1.debug("{} fired [DEBUG]".format(ev1.name))
dd238d2a
PP
72
73 time.sleep(wait_time)
74
75 if fire_second_ev:
6a871bbe 76 ev2.info("{} fired [INFO]".format(ev2.name))
dd238d2a 77
74f2abd5
JR
78 if ready_file is not None:
79 try:
80 os.unlink(ready_file)
81 except:
82 print("Unexpected error on ready file unlink:", sys.exc_info()[0])
83 raise
84
dd238d2a 85
6a871bbe 86if __name__ == "__main__":
dd238d2a 87 _main()
This page took 0.056298 seconds and 4 git commands to generate.