Exemple #1
0
/**
 * Function to delete a TAP interface
 *
 * @param   string  $s                  Interface name
 * @return  int                         0 means ok
 */
function delTap($s)
{
    if (isInterface($s)) {
        // Remove interface from OVS switches
        $cmd = 'ovs-vsctl del-port ' . $s . ' 2>&1';
        exec($cmd, $o, $rc);
        // Delete TAP (so it's removed from bridges too)
        $cmd = 'tunctl -d ' . $s . ' 2>&1';
        exec($cmd, $o, $rc);
        if (isInterface($s)) {
            // Failed to delete the TAP interface
            error_log('ERROR: ' . $GLOBALS['messages'][80034]);
            error_log(implode("\n", $o));
            return 80034;
        } else {
            return 0;
        }
    } else {
        // Interface does not exist
        return 0;
    }
}
    $namespace .= '\\' . basename($path, '.php');
    passthru('phpunit-skelgen --bootstrap ' . $base . '/tests/autoload.php --test -- "' . $namespace . '" ' . $path);
} else {
    foreach ($sources as $dir) {
        $lambaIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::SELF_FIRST);
        foreach ($lambaIterator as $path => $value) {
            // get the target path where the test will be generated
            $targetPath = str_replace('.php', 'Test', $path);
            if (is_dir($path)) {
                continue;
            }
            // filter excluded paths
            if (anyInArray($exclude, $path) !== false) {
                continue;
            }
            if (isInterface(file($path)) === true) {
                continue;
            }
            if (isException(file($path)) === true) {
                continue;
            }
            // get the namespace for the class
            $namespace = getNameSpace(file($path));
            // if no namepsace then skip
            if (empty($namespace)) {
                continue;
            }
            // append the class name to the namespace
            $namespace .= '\\' . str_replace('.php', '', $value->getFileName());
            if (!is_dir(dirname($targetPath))) {
                mkdir(dirname($targetPath), 0775, true);