403Webshell
Server IP : 172.67.216.182  /  Your IP : 162.158.190.110
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /www/server/mysql/src/plugin/innodb_memcached/daemon_memcached/testsuite/breakdancer/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/server/mysql/src/plugin/innodb_memcached/daemon_memcached/testsuite/breakdancer/breakdancer.py
#!/usr/bin/env python

import itertools

class Condition(object):
    """Something asserted to be true during the test.

    A given condition may be used as a precondition or a
    postcondition."""

    def __call__(self, k, state):
        """Called with a key and a state.  True if the condition is met."""
        return True

class Effect(object):
    """The affect an action will perform."""

    def __call__(self, k, state):
        """Called with a key and a state.

        The effect modifies the state as appropriate."""

class Action(object):
    """Actions are the operations that will be permuted into test cases.

    Each action has a collection of preconditions and postconditions
    that will be evaluated for checking input and output state for the
    action.

    Action.preconditions is the collection of conditions that must all
    be true upon input to the action.  If any condition is not true,
    the effect is not executed and the action state is considered
    "errored."

    Action.effect is the callable that is expected to alter the state
    to satisfy the postconditions of the action.

    Action.postconditions is the collection of conditions that must
    all be true after the effect of the action completes.
    """

    preconditions = []
    effect = None
    postconditions = []
    enabled = True

    @property
    def name(self):
        """The name of this action (default derived from class name)"""
        n = self.__class__.__name__
        return n[0].lower() + n[1:]

class Driver(object):
    """The driver "performs" the test."""

    def newState(self):
        """Initialize and return the state for a test."""
        return {}

    def preSuite(self, seq):
        """Invoked with the sequence of tests before any are run."""

    def startSequence(self, seq):
        """Invoked with the sequence of actions in a single test
        before it is performed."""

    def startAction(self, action):
        """Invoked when before starting an action."""

    def endAction(self, action, state, errored):
        """Invoked after the action is performed."""

    def endSequence(self, seq, state):
        """Invoked at the end of a sequence of tests."""

    def postSuite(self, seq):
        """Invoked with the sequence of tests after all of them are run."""

def runTest(actions, driver, duplicates=3, length=4):
    """Run a test with the given collection of actions and driver.

    The optional argument `duplicates' specifies how many times a
    given action may be duplicated in a sequence.

    The optional argument `length` specifies how long each test
    sequence is.
    """

    instances = itertools.chain(*itertools.repeat([a() for a in actions],
                                                  duplicates))
    tests = set(itertools.permutations(instances, length))
    driver.preSuite(tests)
    for seq in sorted(tests):
        state = driver.newState()
        driver.startSequence(seq)
        for a in seq:
            driver.startAction(a)
            haserror = not all(p(state) for p in a.preconditions)
            if not haserror:
                try:
                    a.effect(state)
                    haserror = not all(p(state) for p in a.postconditions)
                except:
                    haserror = True
            driver.endAction(a, state, haserror)
        driver.endSequence(seq, state)
    driver.postSuite(tests)

def findActions(classes):
    """Helper function to extract action subclasses from a collection
    of classes."""

    actions = []
    for __t in (t for t in classes if isinstance(type, type(t))):
        if Action in __t.__mro__ and __t != Action and __t.enabled:
            actions.append(__t)
    return actions

Youez - 2016 - github.com/yon3zu
LinuXploit