initial changes to try and cleanup shell commands used within core
This commit is contained in:
parent
49a2f77f45
commit
6b8ee13f5d
22 changed files with 185 additions and 291 deletions
|
@ -3,13 +3,12 @@ Unit tests for testing basic CORE networks.
|
|||
"""
|
||||
|
||||
import os
|
||||
import stat
|
||||
import threading
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from xml.etree import ElementTree
|
||||
|
||||
import pytest
|
||||
from mock import MagicMock
|
||||
|
||||
from conftest import EMANE_SERVICES
|
||||
|
@ -18,6 +17,7 @@ from core.enumerations import MessageFlags
|
|||
from core.mobility import BasicRangeModel
|
||||
from core.netns import nodes
|
||||
from core.netns import vnodeclient
|
||||
from core.netns.vnodeclient import VnodeClient
|
||||
from core.phys.pnodes import PhysicalNode
|
||||
from core.service import ServiceManager
|
||||
from core.xml import xmlsession
|
||||
|
@ -29,6 +29,24 @@ _XML_VERSIONS = ["0.0", "1.0"]
|
|||
_NODE_CLASSES = [nodes.PtpNet, nodes.HubNode, nodes.SwitchNode]
|
||||
|
||||
|
||||
def createclients(sessiondir, clientcls=VnodeClient, cmdchnlfilterfunc=None):
|
||||
"""
|
||||
Create clients
|
||||
|
||||
:param str sessiondir: session directory to create clients
|
||||
:param class clientcls: class to create clients from
|
||||
:param func cmdchnlfilterfunc: command channel filter function
|
||||
:return: list of created clients
|
||||
:rtype: list
|
||||
"""
|
||||
direntries = map(lambda x: os.path.join(sessiondir, x), os.listdir(sessiondir))
|
||||
cmdchnls = filter(lambda x: stat.S_ISSOCK(os.stat(x).st_mode), direntries)
|
||||
if cmdchnlfilterfunc:
|
||||
cmdchnls = filter(cmdchnlfilterfunc, cmdchnls)
|
||||
cmdchnls.sort()
|
||||
return map(lambda x: clientcls(os.path.basename(x), x), cmdchnls)
|
||||
|
||||
|
||||
class TestCore:
|
||||
def test_import_service(self, core):
|
||||
"""
|
||||
|
@ -145,7 +163,7 @@ class TestCore:
|
|||
|
||||
# get node client for testing
|
||||
n1 = core.get_node("n1")
|
||||
client = n1.vnodeclient
|
||||
client = n1.client
|
||||
|
||||
# instantiate session
|
||||
core.session.instantiate()
|
||||
|
@ -178,7 +196,7 @@ class TestCore:
|
|||
assert not client.shcmd(command[0])
|
||||
|
||||
# check module methods
|
||||
assert vnodeclient.createclients(core.session.session_dir)
|
||||
assert createclients(core.session.session_dir)
|
||||
|
||||
# check convenience methods for interface information
|
||||
assert client.getaddr("eth0")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue