Commit af697451 authored by Christophe Bedard's avatar Christophe Bedard

Extract empty lttng interface functions to another file

parent 33e56b95
Pipeline #76730812 passed with stage
in 30 minutes and 56 seconds
......@@ -17,26 +17,14 @@
from typing import List
try:
import lttng
from . import lttng_impl
from .lttng_impl import _lttng_destroy
from .lttng_impl import _lttng_setup
from .lttng_impl import _lttng_start
from .lttng_impl import _lttng_stop
_lttng = lttng_impl
except ImportError:
lttng = None
# Fall back on empty functions
from . import lttng_stub
def _lttng_destroy(*args, **kwargs) -> None:
pass
def _lttng_setup(*args, **kwargs) -> None:
pass
def _lttng_start(*args, **kwargs) -> None:
pass
def _lttng_stop(*args, **kwargs) -> None:
pass
_lttng = lttng_stub
from .names import DEFAULT_CONTEXT
from .names import DEFAULT_EVENTS_KERNEL
......@@ -60,10 +48,8 @@ def lttng_init(
:param kernel_events: list of kernel events to enable
:param context_names: list of context elements to enable
"""
if lttng is None:
return None
_lttng_setup(session_name, base_path, ros_events, kernel_events, context_names)
_lttng_start(session_name)
_lttng.setup(session_name, base_path, ros_events, kernel_events, context_names)
_lttng.start(session_name)
def lttng_fini(session_name: str) -> None:
......@@ -72,7 +58,5 @@ def lttng_fini(session_name: str) -> None:
:param session_name: the name of the session
"""
if lttng is None:
return None
_lttng_stop(session_name)
_lttng_destroy(session_name)
_lttng.stop(session_name)
_lttng.destroy(session_name)
......@@ -25,7 +25,7 @@ from .path import DEFAULT_BASE_PATH
from .path import get_full_session_path
def _lttng_setup(
def setup(
session_name: str,
base_path: str = DEFAULT_BASE_PATH,
ros_events: List[str] = DEFAULT_EVENTS_ROS,
......@@ -113,7 +113,7 @@ def _lttng_setup(
_add_context(enabled_handles, context_list)
def _lttng_start(session_name: str) -> None:
def start(session_name: str) -> None:
"""
Start LTTng session, and check for errors.
......@@ -124,7 +124,7 @@ def _lttng_start(session_name: str) -> None:
raise RuntimeError(f'failed to start tracing: {lttng.strerror(result)}')
def _lttng_stop(session_name: str) -> None:
def stop(session_name: str) -> None:
"""
Stop LTTng session, and check for errors.
......@@ -135,7 +135,7 @@ def _lttng_stop(session_name: str) -> None:
raise RuntimeError(f'failed to stop tracing: {lttng.strerror(result)}')
def _lttng_destroy(session_name: str) -> None:
def destroy(session_name: str) -> None:
"""
Destroy LTTng session, and check for errors.
......@@ -175,7 +175,7 @@ def _create_session(session_name: str, full_path: str) -> None:
if result == -LTTNG_ERR_EXIST_SESS:
# Sessions seem to persist, so if it already exists,
# just destroy it and try again
_lttng_destroy(session_name)
destroy(session_name)
result = lttng.create(session_name, full_path)
if result < 0:
raise RuntimeError(f'session creation failed: {lttng.strerror(result)}')
......
# Copyright 2019 Robert Bosch GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Stub version of the interface for tracing with LTTng."""
def setup(*args, **kwargs) -> None:
pass
def start(*args, **kwargs) -> None:
pass
def stop(*args, **kwargs) -> None:
pass
def destroy(*args, **kwargs) -> None:
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment