summaryrefslogtreecommitdiffstats
path: root/kernel/net/mac802154/trace.c
blob: 863e5e6b983dac118f31b23d26b655061c25e288 (plain)
1
2
3
4
5
6
7
8
9
#include <linux/module.h>

#ifndef __CHECKER__
#include <net/cfg802154.h>
#include "driver-ops.h"
#define CREATE_TRACE_POINTS
#include "trace.h"

#endif
9 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
# Copyright 2015 Intel Corporation.
#
# 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.

"""Class wrapper for controlling a TestPMD instance.

Wraps ``testpmd`` process.
"""

import os
import logging
import time
import pexpect

from conf import settings
from tools import tasks

_TESTPMD_PROMPT = 'Done'

_LOG_FILE_VSWITCHD = os.path.join(
    settings.getValue('LOG_DIR'), settings.getValue('LOG_FILE_VSWITCHD'))

class TestPMDProcess(tasks.Process):
    """Class wrapper for controlling a TestPMD instance.

    Wraps ``testpmd`` process.
    """
    _logfile = _LOG_FILE_VSWITCHD
    _proc_name = 'testpmd'

    def __init__(self, timeout=30, testpmd_args=None, expected_cmd=None):
        """Initialise the wrapper with a specific start timeout and extra
        parameters.

        :param timeout: Timeout to wait for application to start.
        :param testpmd_args: Command line parameters for testpmd.

        :returns: None
        """
        self._logger = logging.getLogger(__name__)
        self._timeout = timeout
        self._expect = expected_cmd
        if not self._expect:
            self._expect = _TESTPMD_PROMPT
        testpmd_args = testpmd_args or []
        self._cmd = ['sudo', '-E', settings.getValue('TOOLS')['testpmd']] + testpmd_args

    # startup/shutdown

    def start(self):
        """ Start ``testpmd`` instance.

        :returns: None
        :raises: pexpect.EOF, pexpect.TIMEOUT
        """

        try:
            super(TestPMDProcess, self).start()
            self.relinquish()
        except (pexpect.EOF, pexpect.TIMEOUT) as exc:
            logging.error("TestPMD start failed.")
            raise exc

    def kill(self, signal='-15', sleep=2):
        """Kill ``testpmd`` instance if it is alive.

        :returns: None
        """
        self._logger.info('Killing testpmd...')

        super(TestPMDProcess, self).kill(signal, sleep)

    # helper functions

    def send(self, cmd, delay=0):
        """
        Send ``cmd`` with no wait.

        Useful for asynchronous commands.

        :param cmd: Command to send to guest.
        :param timeout: Delay to wait after sending command before returning.

        :returns: None
        """
        self._logger.debug(cmd)
        self._child.sendline(cmd)
        time.sleep(delay)

    def wait(self, msg=_TESTPMD_PROMPT, timeout=30):
        """
        Wait for ``msg``.

        :param msg: Message to wait for from guest.
        :param timeout: Time to wait for message.

        :returns: None
        """
        self._child.expect(msg, timeout=timeout)