summaryrefslogtreecommitdiff
path: root/test-cli/test/tests/qnand.py
blob: 988ab60b66ff464478309d48eff3c23f5ecd6110 (plain)
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
import unittest
import sh


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)
        if "device" in varlist:
            self.__device = varlist["device"]
        else:
            raise Exception('device param inside Qnand must be defined')
        self._testMethodDoc = testname
        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")

    def getresults(self):
        return self.__resultlist

    def gettextresult(self):
        return ""