4 ## Copyright (c) 2010-2017 Intel Corporation
6 ## Licensed under the Apache License, Version 2.0 (the "License");
7 ## you may not use this file except in compliance with the License.
8 ## You may obtain a copy of the License at
10 ## http://www.apache.org/licenses/LICENSE-2.0
12 ## Unless required by applicable law or agreed to in writing, software
13 ## distributed under the License is distributed on an "AS IS" BASIS,
14 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ## See the License for the specific language governing permissions and
16 ## limitations under the License.
21 from systemconfig import *
26 _output_file_name = None;
27 _input_file_name = None
28 _input_file_name2 = None
36 _dpiCoreList = range(1, 5)
37 _checkConditions = False;
38 _interCheckDuration = float(1)
40 def getInputFileName(self):
41 return self._input_file_name
43 def getInputFileName2(self):
44 return self._input_file_name2
48 ret += "Test systems: \n"
49 for ts in self._test_systems:
52 if (self._sut is not None):
54 ret += self._sut.toString();
56 ret += "Output file name: " + str(self._output_file_name) + "\n"
57 ret += "Max port rate: " + str(self._max_port_rate) + "\n"
58 ret += "Accuracy: " + str(self._accuracy) + " digits after point"
61 def getErrorTestOne(self):
62 if (len(self._test_systems) == 0):
63 return "Missing test systems";
64 if (self._output_file_name is None):
65 return "No output file or input file defined";
68 def getErrorTestTwo(self):
69 if (self._input_file_name is None):
70 return "Input file is missing"
71 if (self._input_file_name == self._output_file_name):
72 return "Input file and output file are the same"
73 return self.getErrorTestOne();
75 def getErrorMakeTable(self):
76 if (self._input_file_name is None):
77 return "Missing input file"
78 if (self._input_file_name2 is None):
79 return "Missing file with performance resuilts"
80 if (self._output_file_name is None):
81 return "No output file or input file defined";
82 if (self._input_file_name2 == self._input_file_name):
83 return "Input file used multiple times"
84 if (self._input_file_name == self._output_file_name):
85 return "output file is the same as the input file"
86 if (self._input_file_name2 == self._output_file_name):
87 return "output file is the same as the input file 2"
91 def usageAndExit(self, argv0):
92 print "Usage: " + str(argv0)
93 print "-t Add a test system, syntax: " + SystemConfig.expectedSyntax()
94 print "-s Add SUT, syntax: " + SystemConfig.expectedSyntax()
95 print "-o Ouput file name"
96 print "-a Accuracy, number of digits after point"
98 print "-j File with performance results"
99 print "-m Maximum per port rate, by default 0.85 (85%)"
100 print "-d Enable debugging"
101 print "-w Fraction of connections to reach, by default is 0.95 (95%)"
103 print "-q Run a single test iteration, syntax of argument "
104 print "-b Skip time, by default 10 sec"
105 print "-l Test length, by default 120 sec"
106 print "-n Maximum number of DPI cores to test"
107 print "-k Period between checking conditions, 1 second by default"
108 print "-c Check conditions during 10 second period after convergence"
109 print " is msr,conn,ss (i.e. -q 4000,100000,38.91)"
112 def parse(self, programName, args):
114 opts, args = getopt.getopt(args, "t:s:o:a:i:q:m:dhw:j:b:l:n:k:c")
115 except getopt.GetoptError as err:
118 for option, arg in opts:
120 for ts in arg.split(","):
121 syntaxErr = SystemConfig.checkSyntax(ts)
122 if (syntaxErr != ""):
125 self._test_systems.append(SystemConfig(ts));
126 elif(option == "-s"):
127 syntaxErr = SystemConfig.checkSyntax(ts)
128 if (syntaxErr != ""):
131 self._sut = SystemConfig(arg);
132 elif(option == "-w"):
133 self._threshold = float(arg)
134 elif(option == "-o"):
135 self._output_file_name = arg;
136 elif(option == '-a'):
137 self._accuracy = int(arg);
138 elif(option == "-i"):
139 self._input_file_name = arg;
140 elif(option == "-j"):
141 self._input_file_name2 = arg;
142 elif(option == "-q"):
143 self._once = arg.split(",")
144 elif(option == "-c"):
145 self._checkConditions = True;
146 elif(option == "-m"):
147 self._max_port_rate = float(arg);
148 elif(option == "-k"):
149 self._interCheckDuration = float(arg);
150 elif(option == "-d"):
152 elif(option == '-h'):
153 self.usageAndExit(programName)
154 elif(option == '-b'):
155 self._skipTime = int(arg)
156 elif(option == '-l'):
157 self._testLength = int(arg)
158 elif(option == '-n'):
159 self._dpiCoreList = self.strToList(arg)
161 self.usageAndExit(programName);
163 def strToList(self, arg):
165 tokens = arg.split(",");
168 if (a.count('-') == 0):
169 elements.append(int(a))
170 elif (a.count('-') == 1):
171 beg = int(a.split('-')[0]);
172 end = int(a.split('-')[1]);
174 raise Exception("Invalid list input format")
175 elements += range(beg, end + 1);
177 raise Exception("Invalid list input format")