summaryrefslogtreecommitdiff
path: root/test-cli/test/tests/qnand.py
diff options
context:
space:
mode:
Diffstat (limited to 'test-cli/test/tests/qnand.py')
-rw-r--r--test-cli/test/tests/qnand.py44
1 files changed, 25 insertions, 19 deletions
diff --git a/test-cli/test/tests/qnand.py b/test-cli/test/tests/qnand.py
index 988ab60..6de1eaf 100644
--- a/test-cli/test/tests/qnand.py
+++ b/test-cli/test/tests/qnand.py
@@ -1,6 +1,7 @@
import unittest
import sh
-
+import uuid
+from test.helpers.utils import save_file_to_disk
class Qnand(unittest.TestCase):
params = None
@@ -11,29 +12,34 @@ class Qnand(unittest.TestCase):
def __init__(self, testname, testfunc, varlist):
self.params = varlist
super(Qnand, self).__init__(testfunc)
- if "device" in varlist:
- self.__device = varlist["device"]
- else:
- raise Exception('device param inside Qnand must be defined')
self._testMethodDoc = testname
+ self.__xmlObj = varlist["xml"]
+ self.__QNandName = varlist.get('name', 'qnand')
+ self.__device = varlist.get('device', self.__xmlObj.getKeyVal(self.__QNandName, "device", "/dev/mtd0"))
+ self.__nand_res_file = varlist.get('nand_res_file', self.__xmlObj.getKeyVal(self.__QNandName, "nand_res_file", "nand_test_{}.txt"))
+ self.__toPath = varlist.get('to', self.__xmlObj.getKeyVal(self.__QNandName, "to", "/mnt/station_ramdisk"))
+ self.__file_uuid = uuid.uuid4()
+ self.__nand_res_file = self.__nand_res_file.format(self.__file_uuid)
+ nandtestPath = self.__xmlObj.getKeyVal("qnand", "nandtestPath", '/root/hwtest-files/nandtest"')
+
+ if nandtestPath == '':
+ self.myNandTest = sh.nandtest
+ else:
+ self.myNandTest = sh.Command(nandtestPath)
self.__resultlist = []
def execute(self):
try:
- p = sh.nandtest("-m", self.__device)
- # save result
- with open('/mnt/station_ramdisk/nand-nandtest.txt', 'w') as outfile:
- n = outfile.write(p.stdout.decode('ascii'))
- outfile.close()
- self.__resultlist.append(
- {
- "description": "nandtest output",
- "filepath": "/mnt/station_ramdisk/nand-nandtest.txt",
- "mimetype": "text/plain"
- }
- )
- except sh.ErrorReturnCode as e:
- self.fail("failed: could not complete nandtest command")
+ res = self.myNandTest("-m", self.__device)
+ save_file_to_disk(filePath='{}/{}'.format(self.__toPath, self.__nand_res_file),
+ description='nand {} test'.format(self.__device),
+ mime='text/plain',
+ data=res.stdout.decode('utf-8'),
+ result=self.__resultlist)
+
+ except sh.ErrorReturnCode_1 as e:
+ self.fail("nandtest failed: {}".format(e.ErrorReturnCode.stdout))
+
def getresults(self):
return self.__resultlist