Base framework and liblttng-ust-ctl test
[deliverable/lttng-ivc.git] / lttng_ivc / utils / ProjectFactory.py
diff --git a/lttng_ivc/utils/ProjectFactory.py b/lttng_ivc/utils/ProjectFactory.py
new file mode 100644 (file)
index 0000000..93b32c1
--- /dev/null
@@ -0,0 +1,33 @@
+import os
+import logging
+import yaml
+
+import lttng_ivc.utils.project as Project
+
+
+_logger = logging.getLogger('project.factory')
+_conf_file = os.path.dirname(os.path.abspath(__file__)) + "/../run_configuration.yaml"
+_project_constructor = {
+        'babeltrace': Project.Babeltrace,
+        'lttng-modules': Project.Lttng_modules,
+        'lttng-tools': Project.Lttng_tools,
+        'lttng-ust': Project.Lttng_ust,
+}
+
+_markers = None
+with open(_conf_file, 'r') as stream:
+    # This is voluntary static across call, no need to perform this
+    # every time.
+    _markers = yaml.load(stream)
+
+
+def get(label, tmpdir):
+    if label not in _markers:
+        # TODO: specialized exception, handle it caller-side so the caller
+        # can decide to skip or fail test.
+        raise Exception('Label is no present')
+    marker = _markers[label]
+    constructor = _project_constructor[marker['project']]
+    path = marker['path']
+    sha1 = marker['sha1']
+    return constructor(label, path, sha1, tmpdir)
This page took 0.022849 seconds and 5 git commands to generate.