diff options
author | Manel Caro <mcaro@iatec.biz> | 2021-11-06 16:28:38 +0100 |
---|---|---|
committer | Manel Caro <mcaro@iatec.biz> | 2021-11-06 16:28:38 +0100 |
commit | cf19bfe18cbd283b188a858ee1629f9909c924f4 (patch) | |
tree | 1efb23519727130058401df090ab1b5f4cc8ba99 /test-cli/test/tests/qnand.py | |
parent | b6932fbaf898724ae87c29f8965621610f377084 (diff) | |
parent | d5b273a3b58a250742049df4ca0ef0ba54f53d33 (diff) | |
download | board-cf19bfe18cbd283b188a858ee1629f9909c924f4.zip board-cf19bfe18cbd283b188a858ee1629f9909c924f4.tar.gz board-cf19bfe18cbd283b188a858ee1629f9909c924f4.tar.bz2 |
Diffstat (limited to 'test-cli/test/tests/qnand.py')
-rw-r--r-- | test-cli/test/tests/qnand.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test-cli/test/tests/qnand.py b/test-cli/test/tests/qnand.py new file mode 100644 index 0000000..6de1eaf --- /dev/null +++ b/test-cli/test/tests/qnand.py @@ -0,0 +1,48 @@ +import unittest +import sh +import uuid +from test.helpers.utils import save_file_to_disk + +class Qnand(unittest.TestCase): + params = None + __device = "10M" + __resultlist = None # resultlist is a python list of python dictionaries + + # varlist: device + def __init__(self, testname, testfunc, varlist): + self.params = varlist + super(Qnand, self).__init__(testfunc) + 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: + 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 + + def gettextresult(self): + return "" |