1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
import unittest
import sh
# from test.helpers.iseelogger import MeasureTime
# from test.helpers.iseelogger import logObj
from test.helpers.utils import save_file_to_disk
class Qram(unittest.TestCase):
params = None
__memsize = None
__loops = None
__resultlist = [] # resultlist is a python list of python dictionaries
# varlist: memsize, loops
def __init__(self, testname, testfunc, varlist):
self.params = varlist
super(Qram, self).__init__(testfunc)
self._testMethodDoc = testname
self.__xmlObj = varlist["xml"]
self.__QramName = varlist.get('name', 'qram')
self.__loops = varlist.get('loops', self.__xmlObj.getKeyVal(self.__QramName, "loops", "1"))
self.__memsize = varlist.get('memsize', self.__xmlObj.getKeyVal(self.__QramName, "memsize", "50M"))
self.__toPath = varlist.get('to', self.__xmlObj.getKeyVal(self.__QramName, "to", "/mnt/station_ramdisk"))
self.__ram_res_file = varlist.get('ram_res_file', self.__xmlObj.getKeyVal(self.__QramName, "ram_res_file", "ram_res.txt"))
self.__dummytest = varlist.get('dummytest', self.__xmlObj.getKeyVal(self.__QramName, "dummytest", "0"))
self.__dummyresult = varlist.get('dummytestresult', self.__xmlObj.getKeyVal(self.__QramName, "dummytest", "0"))
memtesterPath = self.__xmlObj.getKeyVal(self.__QramName, "memtesterPath", '')
if memtesterPath == '':
self.myMemtester = sh.memtester
else:
self.myMemtester = sh.Command(memtesterPath)
def execute(self):
self.__resultlist = []
try:
# mytime = MeasureTime()
res = self.myMemtester(self.__memsize, '{}'.format(self.__loops))
save_file_to_disk(filePath='{}/{}'.format(self.__toPath, self.__ram_res_file),
description='Ram result test',
mime='text/plain',
data=res.stdout.decode('utf-8'),
result=self.__resultlist)
# mytime.stop()
except sh.ErrorReturnCode as e:
save_file_to_disk(filePath='{}/{}'.format(self.__toPath, self.__ram_res_file),
description='Ram result test',
mime='text/plain',
data=e.stdout.decode('utf-8'),
result=self.__resultlist)
self.fail("failed: memtester {}::{}".format(str(e.exit_code), e.stdout.decode('utf-8')))
except Exception as details:
self.fail('Error: {}'.format(details))
def getresults(self):
return self.__resultlist
def gettextresult(self):
return ""
|