Support version ABI check for test_ust_app_vs_ust_tools
[deliverable/lttng-ivc.git] / lttng_ivc / utils / utils.py
index 23ce4bce20ae3d2700d0bb57ace4d1cf5cbb7dcb..b8a1b37a0ca2a95089a3e22c279467eb4e29c328 100644 (file)
@@ -1,5 +1,7 @@
 import signal
 import hashlib
+import os
+import time
 
 def line_count(file_path):
     line_count = 0
@@ -17,13 +19,42 @@ def sha256_checksum(filename, block_size=65536):
     return sha256.hexdigest()
 
 
+# TODO: timeout as a parameter or Settings
+# TODO: Custom exception
+def wait_for_file(path):
+    i = 0
+    timeout = 60
+    while not os.path.exists(path):
+        time.sleep(1)
+        i = i + 1
+        if i > timeout:
+            raise Exception("File still does not exists. Timeout expired")
+
+
+# TODO: find better exception
+def create_empty_file(path):
+    if os.path.exists(path):
+        raise Exception("Path already exist")
+    open(path, 'w').close()
+
+
 def __dummy_sigusr1_handler():
     pass
 
 
 def sessiond_spawn(runtime):
-        previous_handler = signal.signal(signal.SIGUSR1, __dummy_sigusr1_handler)
-        sessiond = runtime.spawn_subprocess("lttng-sessiond -vvv -S")
-        signal.sigtimedwait({signal.SIGUSR1}, 60)
-        previous_handler = signal.signal(signal.SIGUSR1, previous_handler)
-        return sessiond
+    previous_handler = signal.signal(signal.SIGUSR1, __dummy_sigusr1_handler)
+    sessiond = runtime.spawn_subprocess("lttng-sessiond -vvv -S")
+    signal.sigtimedwait({signal.SIGUSR1}, 60)
+    previous_handler = signal.signal(signal.SIGUSR1, previous_handler)
+    return sessiond
+
+
+
+
+def file_contains(stderr_file, list_of_string):
+    with open(stderr_file, 'r') as stderr:
+        for line in stderr:
+            for s in list_of_string:
+                if s in line:
+                    return True
This page took 0.02414 seconds and 5 git commands to generate.