code review comments and PROX commit ID
[samplevnf.git] / VNFs / DPPD-PROX / helper-scripts / dpi / proxdpisut.py
1 #!/bin/env python
2
3 ##
4 ## Copyright (c) 2010-2017 Intel Corporation
5 ##
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
9 ##
10 ##     http://www.apache.org/licenses/LICENSE-2.0
11 ##
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.
17 ##
18
19 from prox import *
20 from remotesystem import *
21 from time import *
22 from decimal import *
23
24 class ProxDpiSut(Prox):
25     def __init__(self, ts, coreCount):
26         super(ProxDpiSut, self).__init__(ts)
27
28         self._setDefaultArguments();
29         self._setDpiCoreCount(coreCount);
30
31     def _setDefaultArguments(self):
32         self.addArgument("-e");
33         self.addArgument("-t");
34         self.addArgument("-k");
35         self.addArgument("-d");
36         self.addArgument("-r 0.01");
37
38     def _setDpiCoreCount(self, count):
39         self.addArgument("-q dpi_core_count=" + str(count))
40
41     def _querySetup2(self):
42         self._query_cores();
43
44     def _query_cores(self):
45         print "querying cores"
46         self._wk = self._get_core_list("$wk");
47
48     def _get_core_list(self, var):
49         ret = []
50         result = self._send("echo " + var)._recv();
51         for e in result.split(","):
52             ret += [e];
53         return ret;
54
55     def getTsc(self):
56         cmd = "stats task.core(%s).task(0).tsc" % self._wk[-1]
57         res = int(self._send(cmd)._recv());
58         if (res == 0):
59             return self._getTsc();
60         else:
61             return res;