예제 #1
0
from __future__ import unicode_literals
from __future__ import division

from socket import ntohl

from pycopia import aid

TCP_CONNECTIONS_FILE = "/proc/net/tcp"

# from linux include/net/tcp_states.h
TCP_STATES = aid.Enums(TCP_ESTABLISHED=1,
                       TCP_SYN_SENT=2,
                       TCP_SYN_RECV=3,
                       TCP_FIN_WAIT1=4,
                       TCP_FIN_WAIT2=5,
                       TCP_TIME_WAIT=6,
                       TCP_CLOSE=7,
                       TCP_CLOSE_WAIT=8,
                       TCP_LAST_ACK=9,
                       TCP_LISTEN=10,
                       TCP_CLOSING=11)

(TCP_ESTABLISHED, TCP_SYN_SENT, TCP_SYN_RECV, TCP_FIN_WAIT1, TCP_FIN_WAIT2,
 TCP_TIME_WAIT, TCP_CLOSE, TCP_CLOSE_WAIT, TCP_LAST_ACK, TCP_LISTEN,
 TCP_CLOSING) = TCP_STATES


def itoa(address):
    return "%u.%u.%u.%u" % ((address >> 24) & 0x000000ff,
                            ((address & 0x00ff0000) >> 16),
                            ((address & 0x0000ff00) >> 8),
예제 #2
0
    pass


class RouterConstructorError(Error):
    """Raised if you try to do something that's not possible."""
    pass


# possible delay distribution values.
DIST_UNIFORM = "uniform"
DIST_NORMAL = "normal"
DIST_PARETO = "pareto"
DIST_PARETONORMAL = "paretonormal"

# Direction values
Up, Down, Level, Unknown = aid.Enums("up", "down", "level", "unknown")


class ImpairmentsConfigurer:
    """Simplified interface to configuring network interfaces and path
    impairments.

    Parameters
    ----------
    interfaces : list of str
        A list of the data interface names used in the path configuration.
    """

    def __init__(self, interfaces):
        self.interfaces = interfaces
예제 #3
0
  Raising TestSuiteAbort exception has the same effect.

- NA: A result that is not applicable (e.g. it is a holder of tests).

- EXPECTED_FAIL: Means the test is failing due to a bug, and is already
  known to fail.

"""

from pycopia import aid

# Default report message.
NO_MESSAGE = "no message"

### These enums should match exactly the enums in pycopia.db.types module.  ###
# results a test object can produce.
TESTRESULTS = aid.Enums(PASSED=1,
                        FAILED=0,
                        INCOMPLETE=-1,
                        ABORT=-2,
                        NA=-3,
                        EXPECTED_FAIL=-4)
TESTRESULTS.sort()
[EXPECTED_FAIL, NA, ABORT, INCOMPLETE, FAILED, PASSED] = TESTRESULTS

# Type of objects the TestRunner can run, and reports can be generated
# from.
OBJECTTYPES = aid.Enums("UseCase", "TestSuite", "Test", "TestRunner",
                        "unknown")
[USECASE, SUITE, TEST, RUNNER, UNKNOWN] = OBJECTTYPES
예제 #4
0
#!/usr/bin/python2.4
# vim:ts=2:sw=2:softtabstop=0:tw=74:smarttab:expandtab
#
# Copyright The Android Open Source Project
"""Droid universal constants and enumerations.

"""

__author__ = '[email protected] (Keith Dart)'

from pycopia import aid

# results a test object can produce.
TESTRESULTS = aid.Enums(PASSED=1,
                        FAILED=0,
                        INCOMPLETE=-1,
                        ABORT=-2,
                        NA=-3,
                        EXPECTED_FAIL=-4)
TESTRESULTS.sort()
[EXPECTED_FAIL, NA, ABORT, INCOMPLETE, FAILED, PASSED] = TESTRESULTS

# PASSED: Execute() passed, and the suite may continue.
# FAILED: Execute() failed, but the suite can continue. You may also raise a
# TestFailError exception.
# INCOMPLETE: Execute() could not complete, and the pass/fail criteria
# could not be determined. but the suite may continue. You may also raise
# a TestIncompleteError exception.
# ABORT: Execute() could not complete, and the suite cannot continue.
# Raising TestSuiteAbort has the same effect.
# NA: A result that is not applicable (e.g. it is a holder of tests).
# EXPECTED_FAIL: Means the test is failing due to a bug, and is already