Revision 461e26e8

View differences:

wcn_simulator.py
5 5

  
6 6
sys.path.append('test_code')
7 7

  
8
from os import path
8
import os 
9 9
from time import time
10 10

  
11 11
from parameters_parser import parameters
......
26 26
    confParams = {}
27 27
    className = None
28 28
    def __init__(self, fileName, stanza):
29
        # check if filename esists
30
        try:
31
            fd =  open(fileName, "r")
32
        except IOError:
29
        """ receives the configuration fileName and the stanza to be 
30
        parsed """
31

  
32
        if not os.path.isfile(fileName):
33 33
            error("Can not open the configuration file: " + fileName\
34 34
                + "\n")
35 35
            sys.exit(1)
36 36
        self.parser = ConfigParser.SafeConfigParser()
37 37
        self.parser.read(fileName)
38

  
39 38
        self.testName = stanza 
39

  
40 40
        if stanza not in self.parser.sections():
41 41
            error("Can not find configuration " + stanza \
42 42
                    + " in file " + fileName + "\n")
43 43
            sys.exit(1)
44

  
44 45
        for o in self.mandatoryOptions:
45 46
            self.mandatoryOptions[o] = \
46 47
                self.getConfigurations(o, raiseError=True)
47 48

  
49
        # this builds a module with the correct path in python namespace
48 50
        moduleName = "test_code." + self.mandatoryOptions['testModule']
51

  
49 52
        if moduleName not in sys.modules:
50 53
            errorString = "ERROR: no " \
51 54
                + self.mandatoryOptions['testModule'] \
......
58 61
            errorString = "ERROR: no " \
59 62
                + self.mandatoryOptions['testClass'] \
60 63
                + " simulation class is present in "\
61
                + moduleName + "\n"
64
                + moduleName.replace(".","/")+".py" + "\n"
62 65
            error(errorString)
63 66
            sys.exit(1)
64 67

  
......
85 88
            ("-f", ["configFile", True, "",
86 89
                "file with the available configurations", str]),
87 90
            ("-t", ["testName", True, "",
88
                "base name for test output", str])
91
                "name of the configuration to run", str])
89 92
           ]
90 93
    opt = [
91 94
            ("-d", ["drawGraph", False, False,
......
94 97
                "file with the topology (overrides configuration)", str])
95 98
          ]
96 99

  
97
    P = conf(path.basename(__file__),need, opt)
100
    P = conf(os.path.basename(__file__),need, opt)
98 101
    P.parseArgs()
99 102
    if P.checkCorrectness() == False:
100 103
        P.printUsage()
......
119 122
    net.start()
120 123
    net.enableForwarding()
121 124
    net.setShortestRoutes()
122
#    CLI(net)
123 125
    testPath = testName+"_"+str(int(time()))
126
    #CLI(net)
124 127
    for i in range(1):
125
        c = "peerstreamer.PSHostsTest"
126 128
        info("+++++++ Round: "+str(i+1) + '\n')
127 129
        test = C.className(net, testPath, C.confParams)
128 130
        test.runTest()

Also available in: Unified diff