Tests: Move python test app to `tests/utils/testapp` directory
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 13 May 2021 01:21:28 +0000 (21:21 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 14 May 2021 18:10:22 +0000 (14:10 -0400)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9bc55c0fc0b8de42157d64884c7e1ee08b800525

configure.ac
tests/regression/ust/Makefile.am
tests/regression/ust/python-logging/Makefile.am [deleted file]
tests/regression/ust/python-logging/test.py [deleted file]
tests/regression/ust/python-logging/test_python_logging.in
tests/utils/testapp/Makefile.am
tests/utils/testapp/gen-py-events/Makefile.am [new file with mode: 0644]
tests/utils/testapp/gen-py-events/gen-py-events.py [new file with mode: 0644]

index 549b6996258ee9c981e4e558ed7051d62a0d3dff..0b4d893f70eba32d65fd86453348d811b9c132ef 100644 (file)
@@ -1191,7 +1191,6 @@ AC_CONFIG_FILES([
        tests/regression/ust/ust-dl/Makefile
        tests/regression/ust/java-jul/Makefile
        tests/regression/ust/java-log4j/Makefile
-       tests/regression/ust/python-logging/Makefile
        tests/regression/ust/getcpu-override/Makefile
        tests/regression/ust/clock-override/Makefile
        tests/regression/ust/type-declarations/Makefile
@@ -1207,6 +1206,7 @@ AC_CONFIG_FILES([
        tests/utils/testapp/Makefile
        tests/utils/testapp/gen-ns-events/Makefile
        tests/utils/testapp/gen-kernel-test-events/Makefile
+       tests/utils/testapp/gen-py-events/Makefile
        tests/utils/testapp/gen-ust-events/Makefile
        tests/utils/testapp/gen-ust-events-ns/Makefile
        tests/utils/testapp/gen-syscall-events-callstack/Makefile
index 994fa6a689bfb6d89a4b25ee888334e5170f3d16..49a1811ff08d79f262b4fca4b2ae781ce1924222 100644 (file)
@@ -1,17 +1,40 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
 if HAVE_LIBLTTNG_UST_CTL
-SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \
-               overlap buffers-pid linking daemon exit-fast fork libc-wrapper \
-               periodical-metadata-flush java-jul java-log4j python-logging \
-               getcpu-override clock-override type-declarations \
-               rotation-destroy-flush blocking multi-lib namespaces
+SUBDIRS = \
+       before-after \
+       blocking \
+       buffers-pid \
+       clock-override \
+       daemon \
+       exit-fast \
+       fork \
+       getcpu-override \
+       high-throughput \
+       java-jul \
+       java-log4j \
+       libc-wrapper \
+       linking \
+       low-throughput \
+       multi-lib \
+       multi-session \
+       namespaces \
+       nprocesses \
+       overlap \
+       periodical-metadata-flush \
+       rotation-destroy-flush \
+       type-declarations
 
 if HAVE_OBJCOPY
-SUBDIRS += baddr-statedump ust-dl
+SUBDIRS += \
+       baddr-statedump \
+       ust-dl
 endif
 
-EXTRA_DIST = test_event_basic test_event_tracef test_event_perf
+EXTRA_DIST = \
+       test_event_basic \
+       test_event_perf \
+       test_event_tracef
 
 all-local:
        @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
diff --git a/tests/regression/ust/python-logging/Makefile.am b/tests/regression/ust/python-logging/Makefile.am
deleted file mode 100644 (file)
index b0b28a0..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-
-#if USE_PYTHON
-
-EXTRA_DIST = test.py
-
-#endif
diff --git a/tests/regression/ust/python-logging/test.py b/tests/regression/ust/python-logging/test.py
deleted file mode 100644 (file)
index de6afef..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-# Copyright (C) 2015 Philippe Proulx <pproulx@efficios.com>
-# Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
-#
-# SPDX-License-Identifier: LGPL-2.1-only
-
-from __future__ import unicode_literals, print_function
-import logging
-import time
-import sys
-import argparse
-import os
-
-
-def _perror(msg):
-    print(msg, file=sys.stderr)
-    sys.exit(1)
-
-
-try:
-    import lttngust
-except (ImportError) as e:
-    _perror('lttngust package not found: {}'.format(e))
-
-
-def _main():
-    ev1 = logging.getLogger('python-ev-test1');
-    ev2 = logging.getLogger('python-ev-test2');
-
-    logging.basicConfig()
-
-    parser = argparse.ArgumentParser()
-    parser.add_argument('-n', '--nr-iter', required=True)
-    parser.add_argument('-s', '--wait', required=True)
-    parser.add_argument('-d', '--fire-debug-event', action="store_true")
-    parser.add_argument('-e', '--fire-second-event', action="store_true")
-    parser.add_argument('-r', '--ready-file')
-    parser.add_argument('-g', '--go-file')
-    args = parser.parse_args()
-
-    nr_iter = int(args.nr_iter)
-    wait_time = float(args.wait)
-    fire_debug_ev = args.fire_debug_event
-    fire_second_ev = args.fire_second_event
-
-    ready_file = args.ready_file
-    go_file = args.go_file
-
-    if ready_file is not None and os.path.exists(ready_file):
-        raise ValueError('Ready file already exist')
-
-    if go_file is not None and os.path.exists(go_file):
-        raise ValueError('Go file already exist. Review synchronization')
-
-    if (ready_file is None) != (go_file is None):
-        raise ValueError('--go-file and --ready-file need each others, review'
-                'synchronization')
-
-
-    # Inform that we are ready, if necessary
-    if ready_file is not None:
-        open(ready_file, 'a').close()
-
-    # Wait for go, if necessary
-    while go_file is not None and not os.path.exists(go_file):
-        time.sleep(0.5)
-
-    for i in range(nr_iter):
-        ev1.info('{} fired [INFO]'.format(ev1.name))
-
-        if fire_debug_ev:
-            ev1.debug('{} fired [DEBUG]'.format(ev1.name))
-
-        time.sleep(wait_time)
-
-    if fire_second_ev:
-        ev2.info('{} fired [INFO]'.format(ev2.name))
-
-    if ready_file is not None:
-        try:
-            os.unlink(ready_file)
-        except:
-            print("Unexpected error on ready file unlink:", sys.exc_info()[0])
-            raise
-
-
-if __name__ == '__main__':
-    _main()
index bd370e7218904eae16d1307b9847d34924c12d7d..342bac2f65ca8b56105011d808e18eb1636a4861 100755 (executable)
@@ -11,9 +11,9 @@ CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../../..
 NR_ITER=5
 NR_SEC_WAIT=0
-TESTAPP_NAME="test"
+TESTAPP_NAME="gen-py-events"
 TESTAPP_BIN="$TESTAPP_NAME.py"
-TESTAPP_PATH="@abs_top_srcdir@/tests/regression/ust/python-logging"
+TESTAPP_PATH="$TESTDIR/utils/testapp/$TESTAPP_NAME/"
 SESSION_NAME="python-test"
 EVENT_NAME="python-ev-test1"
 EVENT_NAME2="python-ev-test2"
index a8642e931e4359e336135ef50c66a03d2e5c10a4..dcb83d2d96754bae8141315b634ff88af373521d 100644 (file)
@@ -1,11 +1,12 @@
 # SPDX-License-Identifier: GPL-2.0-only
 SUBDIRS = \
+         gen-kernel-test-events \
+         gen-py-events \
+         gen-syscall-events \
          gen-ust-events \
          gen-ust-nevents \
          gen-ust-nevents-str \
          gen-ust-tracef \
-         gen-syscall-events \
-         gen-kernel-test-events \
          userspace-probe-elf-binary
 
 if CXX_WORKS
diff --git a/tests/utils/testapp/gen-py-events/Makefile.am b/tests/utils/testapp/gen-py-events/Makefile.am
new file mode 100644 (file)
index 0000000..e729b3c
--- /dev/null
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+noinst_SCRIPTS = gen-py-events.py
+EXTRA_DIST = gen-py-events.py
+
+all-local:
+       @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+               for script in $(EXTRA_DIST); do \
+                       cp -f $(srcdir)/$$script $(builddir); \
+               done; \
+       fi
+
+clean-local:
+       @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+               for script in $(EXTRA_DIST); do \
+                       rm -f $(builddir)/$$script; \
+               done; \
+       fi
diff --git a/tests/utils/testapp/gen-py-events/gen-py-events.py b/tests/utils/testapp/gen-py-events/gen-py-events.py
new file mode 100644 (file)
index 0000000..de6afef
--- /dev/null
@@ -0,0 +1,87 @@
+# Copyright (C) 2015 Philippe Proulx <pproulx@efficios.com>
+# Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
+#
+# SPDX-License-Identifier: LGPL-2.1-only
+
+from __future__ import unicode_literals, print_function
+import logging
+import time
+import sys
+import argparse
+import os
+
+
+def _perror(msg):
+    print(msg, file=sys.stderr)
+    sys.exit(1)
+
+
+try:
+    import lttngust
+except (ImportError) as e:
+    _perror('lttngust package not found: {}'.format(e))
+
+
+def _main():
+    ev1 = logging.getLogger('python-ev-test1');
+    ev2 = logging.getLogger('python-ev-test2');
+
+    logging.basicConfig()
+
+    parser = argparse.ArgumentParser()
+    parser.add_argument('-n', '--nr-iter', required=True)
+    parser.add_argument('-s', '--wait', required=True)
+    parser.add_argument('-d', '--fire-debug-event', action="store_true")
+    parser.add_argument('-e', '--fire-second-event', action="store_true")
+    parser.add_argument('-r', '--ready-file')
+    parser.add_argument('-g', '--go-file')
+    args = parser.parse_args()
+
+    nr_iter = int(args.nr_iter)
+    wait_time = float(args.wait)
+    fire_debug_ev = args.fire_debug_event
+    fire_second_ev = args.fire_second_event
+
+    ready_file = args.ready_file
+    go_file = args.go_file
+
+    if ready_file is not None and os.path.exists(ready_file):
+        raise ValueError('Ready file already exist')
+
+    if go_file is not None and os.path.exists(go_file):
+        raise ValueError('Go file already exist. Review synchronization')
+
+    if (ready_file is None) != (go_file is None):
+        raise ValueError('--go-file and --ready-file need each others, review'
+                'synchronization')
+
+
+    # Inform that we are ready, if necessary
+    if ready_file is not None:
+        open(ready_file, 'a').close()
+
+    # Wait for go, if necessary
+    while go_file is not None and not os.path.exists(go_file):
+        time.sleep(0.5)
+
+    for i in range(nr_iter):
+        ev1.info('{} fired [INFO]'.format(ev1.name))
+
+        if fire_debug_ev:
+            ev1.debug('{} fired [DEBUG]'.format(ev1.name))
+
+        time.sleep(wait_time)
+
+    if fire_second_ev:
+        ev2.info('{} fired [INFO]'.format(ev2.name))
+
+    if ready_file is not None:
+        try:
+            os.unlink(ready_file)
+        except:
+            print("Unexpected error on ready file unlink:", sys.exc_info()[0])
+            raise
+
+
+if __name__ == '__main__':
+    _main()
This page took 0.031574 seconds and 4 git commands to generate.